ARPACK-Armadillo
GenEigsSolver< Scalar, SelectionRule, OpType > Class Template Reference

#include <GenEigsSolver.h>

Inheritance diagram for GenEigsSolver< Scalar, SelectionRule, OpType >:
GenEigsRealShiftSolver< Scalar, SelectionRule, OpType >

Public Member Functions

 GenEigsSolver (OpType *op_, int nev_, int ncv_)
 
void init (Scalar *init_resid)
 
void init ()
 
int compute (int maxit=1000, Scalar tol=1e-10)
 
int num_iterations ()
 
int num_operations ()
 
ComplexVector eigenvalues ()
 
ComplexMatrix eigenvectors (int nvec)
 
ComplexMatrix eigenvectors ()
 

Detailed Description

template<typename Scalar = double, int SelectionRule = LARGEST_MAGN, typename OpType = DenseGenMatProd<double>>
class GenEigsSolver< Scalar, SelectionRule, OpType >

This class implements the eigen solver for general real matrices.

Most of the background information documented in the SymEigsSolver class also applies to the GenEigsSolver class here, except that the eigenvalues and eigenvectors of a general matrix can now be complex-valued.

Template Parameters
ScalarThe element type of the matrix. Currently supported types are float and double.
SelectionRuleAn enumeration value indicating the selection rule of the requested eigenvalues, for example LARGEST_MAGN to retrieve eigenvalues with the largest magnitude. The full list of enumeration values can be found in SelectionRule.h .
OpTypeThe name of the matrix operation class. Users could either use the DenseGenMatProd wrapper class, or define their own that impelemnts all the public member functions as in DenseGenMatProd.

An example that illustrates the usage of GenEigsSolver is give below:

#include <armadillo>
#include <GenEigsSolver.h> // Also includes <MatOp/DenseGenMatProd.h>
int main()
{
// We are going to calculate the eigenvalues of M
arma::mat M = arma::randu(10, 10);
// Construct matrix operation object using the wrapper class
// Construct eigen solver object, requesting the largest
// (in magnitude, or norm) three eigenvalues
// Initialize and compute
eigs.init();
int nconv = eigs.compute();
// Retrieve results
arma::cx_vec evalues;
if(nconv > 0)
evalues = eigs.eigenvalues();
evalues.print("Eigenvalues found:");
return 0;
}

Definition at line 83 of file GenEigsSolver.h.

Constructor & Destructor Documentation

template<typename Scalar = double, int SelectionRule = LARGEST_MAGN, typename OpType = DenseGenMatProd<double>>
GenEigsSolver< Scalar, SelectionRule, OpType >::GenEigsSolver ( OpType *  op_,
int  nev_,
int  ncv_ 
)
inline

Constructor to create a solver object.

Parameters
op_Pointer to the matrix operation object, which should implement the matrix-vector multiplication operation of \(A\): calculating \(Ay\) for any vector \(y\). Users could either create the object from the DenseGenMatProd wrapper class, or define their own that impelemnts all the public member functions as in DenseGenMatProd.
nev_Number of eigenvalues requested. This should satisfy \(1\le nev \le n-2\), where \(n\) is the size of matrix.
ncv_Parameter that controls the convergence speed of the algorithm. Typically a larger ncv_ means faster convergence, but it may also result in greater memory use and more matrix operations in each iteration. This parameter must satisfy \(nev+2 \le ncv \le n\), and is advised to take \(ncv \ge 2\cdot nev + 1\).

Definition at line 173 of file GenEigsSolver.h.

Member Function Documentation

template<typename Scalar , int SelectionRule, typename OpType >
void GenEigsSolver< Scalar, SelectionRule, OpType >::init ( Scalar *  init_resid)
inline

Providing the initial residual vector for the algorithm.

Parameters
init_residPointer to the initial residual vector.

ARPACK-Armadillo (and also ARPACK) uses an iterative algorithm to find eigenvalues. This function allows the user to provide the initial residual vector.

Definition at line 247 of file GenEigsSolver_Impl.h.

template<typename Scalar , int SelectionRule, typename OpType >
void GenEigsSolver< Scalar, SelectionRule, OpType >::init ( )
inline

Providing a random initial residual vector.

This overloaded function generates a random initial residual vector for the algorithm. Elements in the vector follow independent Uniform(-0.5, 0.5) distributions.

Definition at line 280 of file GenEigsSolver_Impl.h.

template<typename Scalar , int SelectionRule, typename OpType >
int GenEigsSolver< Scalar, SelectionRule, OpType >::compute ( int  maxit = 1000,
Scalar  tol = 1e-10 
)
inline

Conducting the major computation procedure.

Parameters
maxitMaximum number of iterations allowed in the algorithm.
tolPrecision parameter for the calculated eigenvalues.
Returns
Number of converged eigenvalues.

Definition at line 291 of file GenEigsSolver_Impl.h.

template<typename Scalar = double, int SelectionRule = LARGEST_MAGN, typename OpType = DenseGenMatProd<double>>
int GenEigsSolver< Scalar, SelectionRule, OpType >::num_iterations ( )
inline

Returning the number of iterations used in the computation.

Definition at line 222 of file GenEigsSolver.h.

template<typename Scalar = double, int SelectionRule = LARGEST_MAGN, typename OpType = DenseGenMatProd<double>>
int GenEigsSolver< Scalar, SelectionRule, OpType >::num_operations ( )
inline

Returning the number of matrix operations used in the computation.

Definition at line 227 of file GenEigsSolver.h.

template<typename Scalar , int SelectionRule, typename OpType >
GenEigsSolver< Scalar, SelectionRule, OpType >::ComplexVector GenEigsSolver< Scalar, SelectionRule, OpType >::eigenvalues ( )
inline

Returning the converged eigenvalues.

Returns
A complex-valued vector containing the eigenvalues. Returned vector type will be arma::cx_vec or arma::cx_fvec, depending on the template parameter Scalar defined.

Definition at line 319 of file GenEigsSolver_Impl.h.

template<typename Scalar , int SelectionRule, typename OpType >
GenEigsSolver< Scalar, SelectionRule, OpType >::ComplexMatrix GenEigsSolver< Scalar, SelectionRule, OpType >::eigenvectors ( int  nvec)
inline

Returning the eigenvectors associated with the converged eigenvalues.

Parameters
nvecThe number of eigenvectors to return.
Returns
A complex-valued matrix containing the eigenvectors. Returned matrix type will be arma::cx_mat or arma::cx_fmat, depending on the template parameter Scalar defined.

Definition at line 344 of file GenEigsSolver_Impl.h.

template<typename Scalar = double, int SelectionRule = LARGEST_MAGN, typename OpType = DenseGenMatProd<double>>
ComplexMatrix GenEigsSolver< Scalar, SelectionRule, OpType >::eigenvectors ( )
inline

Returning all converged eigenvectors.

Definition at line 251 of file GenEigsSolver.h.


The documentation for this class was generated from the following files: