Object-oriented Scientific Computing Library: Version 0.910
Public Member Functions | Data Fields | Protected Member Functions
lanczos< vec_t, mat_t, alloc_vec_t, alloc_t > Class Template Reference

Lanczos diagonalization. More...

#include <lanczos_base.h>


Detailed Description

template<class vec_t = o2scl::ovector_base, class mat_t = o2scl::omatrix_base, class alloc_vec_t = o2scl::ovector, class alloc_t = o2scl::ovector_alloc>
class lanczos< vec_t, mat_t, alloc_vec_t, alloc_t >

This class approximates the largest eigenvalues of a symmetric matrix.

The vector and matrix types can be any type which provides access via operator[] or operator(), given a suitable vector allocation type. See Vector types for template classes in the User's guide for more details.

The tridiagonalization routine was rewritten from the EISPACK routines imtql1.f (but uses gsl_hypot() instead of pythag.f).

Idea for Future:
The function eigen_tdiag() automatically sorts the eigenvalues, which may not be necessary.
Idea for Future:
Do something better than the naive matrix-vector product. For example, use dgemm() and allow user to specify column or row-major.
Idea for Future:
Rework memory allocation to perform as needed.

Definition at line 54 of file lanczos_base.h.

Public Member Functions

int eigenvalues (size_t size, mat_t &mat, size_t n_iter, vec_t &eigen, vec_t &diag, vec_t &off_diag)
 Approximate the largest eigenvalues of a symmetric matrix mat using the Lanczos method.
int eigen_tdiag (size_t n, vec_t &diag, vec_t &off_diag)
 In-place diagonalization of a tridiagonal matrix.

Data Fields

size_t td_iter
 Number of iterations for finding the eigenvalues of the tridiagonal matrix (default 30)
size_t td_lasteval
 The index for the last eigenvalue not determined if tridiagonalization fails.

Protected Member Functions

void product (size_t n, mat_t &a, vec_t &w, vec_t &prod)
 Naive matrix-vector product.

Member Function Documentation

template<class vec_t = o2scl::ovector_base, class mat_t = o2scl::omatrix_base, class alloc_vec_t = o2scl::ovector, class alloc_t = o2scl::ovector_alloc>
int lanczos< vec_t, mat_t, alloc_vec_t, alloc_t >::eigenvalues ( size_t  size,
mat_t &  mat,
size_t  n_iter,
vec_t &  eigen,
vec_t &  diag,
vec_t &  off_diag 
) [inline]

Given a square matrix mat with size size, this function applies n_iter iterations of the Lanczos algorithm to produce n_iter approximate eigenvalues stored in eigen. As a by-product, this function also partially tridiagonalizes the matrix placing the result in diag and off_diag. Before calling this function, space must have already been allocated for eigen, diag, and off_diag. All three of these arrays must have at least enough space for n_iter elements.

Choosing /c n_iter = size will produce all of the exact eigenvalues and the corresponding tridiagonal matrix, but this may be slower than diagonalizing the matrix directly.

Definition at line 90 of file lanczos_base.h.

template<class vec_t = o2scl::ovector_base, class mat_t = o2scl::omatrix_base, class alloc_vec_t = o2scl::ovector, class alloc_t = o2scl::ovector_alloc>
int lanczos< vec_t, mat_t, alloc_vec_t, alloc_t >::eigen_tdiag ( size_t  n,
vec_t &  diag,
vec_t &  off_diag 
) [inline]

On input, the vectors diag and off_diag should both be vectors of size n. The diagonal entries stored in diag, and the $ n-1 $ off-diagonal entries should be stored in off_diag, starting with off_diag[1]. The value in off_diag[0] is unused. The vector off_diag is destroyed by the computation.

This uses an implict QL method from the EISPACK routine imtql1. The value of ierr from the original Fortran routine is stored in td_lasteval.

Definition at line 174 of file lanczos_base.h.

template<class vec_t = o2scl::ovector_base, class mat_t = o2scl::omatrix_base, class alloc_vec_t = o2scl::ovector, class alloc_t = o2scl::ovector_alloc>
void lanczos< vec_t, mat_t, alloc_vec_t, alloc_t >::product ( size_t  n,
mat_t &  a,
vec_t &  w,
vec_t &  prod 
) [inline, protected]

It is assumed that memory is already allocated for prod.

Definition at line 311 of file lanczos_base.h.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).

Get Object-oriented Scientific Computing
Lib at SourceForge.net. Fast, secure and Free Open Source software
downloads.