PowerEigenSolver.h

Go to the documentation of this file.
00001 //
00002 //  Copyright (C) 2004-2006 Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved  @@
00005 //
00006 
00007 #ifndef _RD_POWER_EIGENSOLVER_H
00008 #define _RD_POWER_EIGENSOLVER_H
00009 
00010 #include <Numerics/Vector.h>
00011 #include <Numerics/Matrix.h>
00012 #include <Numerics/SymmMatrix.h>
00013 
00014 namespace RDNumeric {
00015   namespace EigenSolvers {
00016     //! Compute the \c numEig largest eigenvalues and, optionally,  the corresponding
00017     //! eigenvectors. 
00018     /*!
00019       
00020     \param numEig       the number of eigenvalues we are interested in
00021     \param mat          symmetric input matrix of dimension N*N
00022     \param eigenValues  Vector used to return the eigenvalues (size = numEig)
00023     \param eigenVectors Optional matrix used to return the eigenvectors (size = N*numEig)
00024     \param seed         Optional values to seed the random value generator used to 
00025                         initialize the eigen vectors
00026     \return a boolean indicating whether or not the calculation converged.
00027     
00028     <b>Notes:</b>
00029     - The matrix, \c mat, is changed in this function
00030     
00031     <b>Algorithm:</b>
00032     
00033     We use the iterative power method, which works like this:
00034 
00035     \verbatim
00036      u = arbitrary unit vector
00037      tol = 0.001
00038      currEigVal = 0.0;
00039      prevEigVal = -1.0e100
00040      while (abs(currEigVal - prevEigVal) > tol) :
00041          v = Au
00042          prevEigVal = currEigVal
00043          currEigVal = v[i] // where i is the id os the largest absolute component
00044          u = c*v
00045     \endverbatim
00046 
00047       
00048     */
00049     bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
00050                           DoubleVector &eigenValues,
00051                           DoubleMatrix *eigenVectors=0, 
00052                           int seed=-1);
00053     //! \overload
00054     static bool powerEigenSolver(unsigned int numEig, DoubleSymmMatrix &mat,
00055                           DoubleVector &eigenValues,
00056                           DoubleMatrix &eigenVectors, 
00057                           int seed=-1) {
00058       return powerEigenSolver(numEig,mat,eigenValues,&eigenVectors,seed);
00059     }
00060   };
00061 };
00062 
00063 #endif
00064                            
00065 
00066 

Generated on Tue Oct 7 06:10:11 2008 for RDCode by  doxygen 1.5.5