IETL Documentation - power.h

IETL library: power.h

This header implements the power method, the simplest iterative eigenvalue algorithm, discussed, e.g. in Reference [2]. 



namespace ietl {

template <class MATRIX, class GEN, class IT, class VS>
std::pair<typename vectorspace_traits<VS>::scalar_type,
typename vectorspace_traits<VS>::vector_type>
power(const MATRIX& m, GEN& start, IT& iter, const VS& vec);

The power function takes four arguments:
It returns a pair consisting of the last estimate for the eigenvalue with largest absolute value and the corresponding eigenvector.


The implementation of the power method is so simple that we show it here as an example of how the IETL is implemented. The implementation closely follows the algorithmic template in the templates book [2].
    typedef typename vectorspace_traits<VS>::vector_type vector_type;
typedef typename vectorspace_traits<VS>::scalar_type scalar_type;
typedef typename vectorspace_traits<VS>::magnitude_type magnitude_type;

vector_type vec1 = new_vector(vec);

vector_type vec2 = new_vector(vec);
scalar_type lambda;

magnitude_type residual;

do {
lambda = ietl::dot(vec1,vec2);
vec1 *= -lambda;
residual = ietl::two_norm(vec1);
} while(!iter.finished(residual,lambda));

return std::make_pair(lambda,vec1);

copyright 2002-2004 by Matthias Troyer and Prakash Dayal