Anasazi  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
List of all members
Anasazi::BlockDavidson< ScalarType, MV, OP > Class Template Reference

This class implements a Block Davidson iteration, a preconditioned iteration for solving linear Hermitian eigenproblems. More...

#include <AnasaziBlockDavidson.hpp>

Inheritance diagram for Anasazi::BlockDavidson< ScalarType, MV, OP >:
Anasazi::Eigensolver< ScalarType, MV, OP >

Public Member Functions

Constructor/Destructor
 BlockDavidson (const Teuchos::RCP< Eigenproblem< ScalarType, MV, OP > > &problem, const Teuchos::RCP< SortManager< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > > &sorter, const Teuchos::RCP< OutputManager< ScalarType > > &printer, const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &tester, const Teuchos::RCP< MatOrthoManager< ScalarType, MV, OP > > &ortho, Teuchos::ParameterList &params)
 BlockDavidson constructor with eigenproblem, solver utilities, and parameter list of solver options. More...
 
virtual ~BlockDavidson ()
 Anasazi::BlockDavidson destructor. More...
 
Solver methods
void iterate ()
 This method performs BlockDavidson iterations until the status test indicates the need to stop or an error occurs (in which case, an appropriate exception is thrown). More...
 
void initialize (BlockDavidsonState< ScalarType, MV > &newstate)
 Initialize the solver to an iterate, optionally providing the current basis and projected problem matrix, the current Ritz vectors and values, and the current residual. More...
 
void initialize ()
 Initialize the solver with the initial vectors from the eigenproblem or random data. More...
 
bool isInitialized () const
 Indicates whether the solver has been initialized or not. More...
 
BlockDavidsonState< ScalarType,
MV > 
getState () const
 Get access to the current state of the eigensolver. More...
 
Status methods
int getNumIters () const
 Get the current iteration count. More...
 
void resetNumIters ()
 Reset the iteration count. More...
 
Teuchos::RCP< const MV > getRitzVectors ()
 Get access to the current Ritz vectors. More...
 
std::vector< Value< ScalarType > > getRitzValues ()
 Get the Ritz values for the previous iteration. More...
 
std::vector< int > getRitzIndex ()
 Get the index used for extracting individual Ritz vectors from getRitzVectors(). More...
 
std::vector< typename
Teuchos::ScalarTraits
< ScalarType >::magnitudeType > 
getResNorms ()
 Get the current residual norms, computing the norms if they are not up-to-date with the current residual vectors. More...
 
std::vector< typename
Teuchos::ScalarTraits
< ScalarType >::magnitudeType > 
getRes2Norms ()
 Get the current residual 2-norms, computing the norms if they are not up-to-date with the current residual vectors. More...
 
std::vector< typename
Teuchos::ScalarTraits
< ScalarType >::magnitudeType > 
getRitzRes2Norms ()
 Get the 2-norms of the residuals. More...
 
int getCurSubspaceDim () const
 Get the dimension of the search subspace used to generate the current eigenvectors and eigenvalues. More...
 
int getMaxSubspaceDim () const
 Get the maximum dimension allocated for the search subspace. For BlockDavidson, this always returns numBlocks*blockSize. More...
 
Accessor routines from Eigensolver
void setStatusTest (Teuchos::RCP< StatusTest< ScalarType, MV, OP > > test)
 Set a new StatusTest for the solver. More...
 
Teuchos::RCP< StatusTest
< ScalarType, MV, OP > > 
getStatusTest () const
 Get the current StatusTest used by the solver. More...
 
const Eigenproblem< ScalarType,
MV, OP > & 
getProblem () const
 Get a constant reference to the eigenvalue problem. More...
 
void setBlockSize (int blockSize)
 Set the blocksize. More...
 
int getBlockSize () const
 Get the blocksize used by the iterative solver. More...
 
void setAuxVecs (const Teuchos::Array< Teuchos::RCP< const MV > > &auxvecs)
 Set the auxiliary vectors for the solver. More...
 
Teuchos::Array< Teuchos::RCP
< const MV > > 
getAuxVecs () const
 Get the auxiliary vectors for the solver. More...
 
BlockDavidson-specific accessor routines
void setSize (int blockSize, int numBlocks)
 Set the blocksize and number of blocks to be used by the iterative solver in solving this eigenproblem. More...
 
Output methods
void currentStatus (std::ostream &os)
 This method requests that the solver print out its current status to the given output stream. More...
 
- Public Member Functions inherited from Anasazi::Eigensolver< ScalarType, MV, OP >
 Eigensolver ()
 Default Constructor. More...
 
 Eigensolver (const Teuchos::RCP< Eigenproblem< ScalarType, MV, OP > > &problem, const Teuchos::RCP< SortManager< ScalarType > > &sorter, const Teuchos::RCP< OutputManager< ScalarType > > &printer, const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &tester, const Teuchos::RCP< OrthoManager< ScalarType, MV > > &ortho, Teuchos::ParameterList &params)
 Basic Constructor. More...
 
virtual ~Eigensolver ()
 Destructor. More...
 

Detailed Description

template<class ScalarType, class MV, class OP>
class Anasazi::BlockDavidson< ScalarType, MV, OP >

This class implements a Block Davidson iteration, a preconditioned iteration for solving linear Hermitian eigenproblems.

This method is described in A Comparison of Eigensolvers for Large-scale 3D Modal Analysis Using AMG-Preconditioned Iterative Methods, P. Arbenz, U. L. Hetmaniuk, R. B. Lehoucq, R. S. Tuminaro, Internat. J. for Numer. Methods Engrg., 64, pp. 204-236 (2005)

Author
Chris Baker, Ulrich Hetmaniuk, Rich Lehoucq, Heidi Thornquist

Definition at line 132 of file AnasaziBlockDavidson.hpp.

Constructor & Destructor Documentation

template<class ScalarType , class MV , class OP >
Anasazi::BlockDavidson< ScalarType, MV, OP >::BlockDavidson ( const Teuchos::RCP< Eigenproblem< ScalarType, MV, OP > > &  problem,
const Teuchos::RCP< SortManager< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > > &  sorter,
const Teuchos::RCP< OutputManager< ScalarType > > &  printer,
const Teuchos::RCP< StatusTest< ScalarType, MV, OP > > &  tester,
const Teuchos::RCP< MatOrthoManager< ScalarType, MV, OP > > &  ortho,
Teuchos::ParameterList params 
)

BlockDavidson constructor with eigenproblem, solver utilities, and parameter list of solver options.

This constructor takes pointers required by the eigensolver, in addition to a parameter list of options for the eigensolver. These options include the following:

  • "Block Size" - an int specifying the block size used by the algorithm. This can also be specified using the setBlockSize() method.
  • "Num Blocks" - an int specifying the maximum number of blocks allocated for the solver basis.

Definition at line 521 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
Anasazi::BlockDavidson< ScalarType, MV, OP >::~BlockDavidson ( )
virtual

Anasazi::BlockDavidson destructor.

Definition at line 597 of file AnasaziBlockDavidson.hpp.

Member Function Documentation

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::iterate ( )
virtual

This method performs BlockDavidson iterations until the status test indicates the need to stop or an error occurs (in which case, an appropriate exception is thrown).

iterate() will first determine whether the solver is uninitialized; if not, it will call initialize(). After initialization, the solver performs block Davidson iterations until the status test evaluates as Passed, at which point the method returns to the caller.

The block Davidson iteration proceeds as follows:

  1. The current residual (R) is preconditioned to form H
  2. H is orthogonalized against the auxiliary vectors and the previous basis vectors, and made orthonormal.
  3. The current basis is expanded with H and used to project the problem matrix.
  4. The projected eigenproblem is solved, and the desired eigenvectors and eigenvalues are selected.
  5. These are used to form the new eigenvector estimates (X).
  6. The new residual (R) is formed.

The status test is queried at the beginning of the iteration.

Possible exceptions thrown include std::invalid_argument or one of the BlockDavidson-specific exceptions.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 1245 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::initialize ( BlockDavidsonState< ScalarType, MV > &  newstate)

Initialize the solver to an iterate, optionally providing the current basis and projected problem matrix, the current Ritz vectors and values, and the current residual.

The BlockDavidson eigensolver contains a certain amount of state, including the current Krylov basis, the current eigenvectors, the current residual, etc. (see getState())

initialize() gives the user the opportunity to manually set these, although this must be done with caution, as the validity of the user input will not be checked.

Only the first newstate.curDim columns of newstate.V and newstate.KK and the first newstate.curDim rows of newstate.KK will be used.

If newstate.V == getState().V, then the data is not copied. The same holds for newstate.KK, newstate.X, newstate.KX, newstate.MX, and newstate.R Only the upper triangular half of newstate.KK is used to initialize the state of the solver.

Postcondition
isInitialized() == true (see post-conditions of isInitialize())

The user has the option of specifying any component of the state using initialize(). However, these arguments are assumed to match the post-conditions specified under isInitialized(). Any component of the state (i.e., KX) not given to initialize() will be generated.

Note, for any pointer in newstate which directly points to the multivectors in the solver, the data is not copied.

Definition at line 866 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::initialize ( )
virtual

Initialize the solver with the initial vectors from the eigenproblem or random data.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 1235 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
bool Anasazi::BlockDavidson< ScalarType, MV, OP >::isInitialized ( ) const
virtual

Indicates whether the solver has been initialized or not.

Returns
bool indicating the state of the solver.
Postcondition
If isInitialized() == true:
  • getCurSubspaceDim() > 0 and is a multiple of getBlockSize()
  • the first getCurSubspaceDim() vectors of V are orthogonal to auxiliary vectors and have orthonormal columns
  • the principal submatrix of order getCurSubspaceDim() of KK contains the project eigenproblem matrix
  • X contains the Ritz vectors with respect to the current Krylov basis
  • T contains the Ritz values with respect to the current Krylov basis
  • KX == Op*X
  • MX == M*X if M != Teuchos::null
    Otherwise, MX == Teuchos::null
  • R contains the residual vectors with respect to X

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 736 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
BlockDavidsonState< ScalarType, MV > Anasazi::BlockDavidson< ScalarType, MV, OP >::getState ( ) const

Get access to the current state of the eigensolver.

The data is only valid if isInitialized() == true.

The data for the preconditioned residual is only meaningful in the scenario that the solver throws a ::BlockDavidsonRitzFailure exception during iterate().

Returns
A BlockDavidsonState object containing const pointers to the current solver state. Note, these are direct pointers to the multivectors; they are not pointers to views of the multivectors.

Definition at line 709 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
int Anasazi::BlockDavidson< ScalarType, MV, OP >::getNumIters ( ) const
virtual

Get the current iteration count.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 701 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::resetNumIters ( )
virtual

Reset the iteration count.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 693 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP< const MV > Anasazi::BlockDavidson< ScalarType, MV, OP >::getRitzVectors ( )
virtual

Get access to the current Ritz vectors.

Returns
A multivector with getBlockSize() vectors containing the sorted Ritz vectors corresponding to the most significant Ritz values. The i-th vector of the return corresponds to the i-th Ritz vector; there is no need to use getRitzIndex().

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 685 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
std::vector< Value< ScalarType > > Anasazi::BlockDavidson< ScalarType, MV, OP >::getRitzValues ( )
virtual

Get the Ritz values for the previous iteration.

Returns
A vector of length getCurSubspaceDim() containing the Ritz values from the previous projected eigensolve.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 672 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
std::vector< int > Anasazi::BlockDavidson< ScalarType, MV, OP >::getRitzIndex ( )
virtual

Get the index used for extracting individual Ritz vectors from getRitzVectors().

Because BlockDavidson is a Hermitian solver, all Ritz values are real and all Ritz vectors can be represented in a single column of a multivector. Therefore, getRitzIndex() is not needed when using the output from getRitzVectors().

Returns
An int vector of size getCurSubspaceDim() composed of zeros.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 663 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > Anasazi::BlockDavidson< ScalarType, MV, OP >::getResNorms ( )
virtual

Get the current residual norms, computing the norms if they are not up-to-date with the current residual vectors.

Returns
A vector of length getCurSubspaceDim() containing the norms of the residuals, with respect to the orthogonalization manager's norm() method.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 1504 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > Anasazi::BlockDavidson< ScalarType, MV, OP >::getRes2Norms ( )
virtual

Get the current residual 2-norms, computing the norms if they are not up-to-date with the current residual vectors.

Returns
A vector of length getCurSubspaceDim() containing the 2-norms of the current residuals.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 1518 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > Anasazi::BlockDavidson< ScalarType, MV, OP >::getRitzRes2Norms ( )
virtual

Get the 2-norms of the residuals.

The Ritz residuals are not defined for the LOBPCG iteration. Hence, this method returns the 2-norms of the direct residuals, and is equivalent to calling getRes2Norms().

Returns
A vector of length getBlockSize() containing the 2-norms of the direct residuals.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 655 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
int Anasazi::BlockDavidson< ScalarType, MV, OP >::getCurSubspaceDim ( ) const
virtual

Get the dimension of the search subspace used to generate the current eigenvectors and eigenvalues.

Returns
An integer specifying the rank of the Krylov subspace currently in use by the eigensolver. If isInitialized() == false, the return is 0. Otherwise, it will be some strictly positive multiple of getBlockSize().

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 645 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
int Anasazi::BlockDavidson< ScalarType, MV, OP >::getMaxSubspaceDim ( ) const
virtual

Get the maximum dimension allocated for the search subspace. For BlockDavidson, this always returns numBlocks*blockSize.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 638 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::setStatusTest ( Teuchos::RCP< StatusTest< ScalarType, MV, OP > >  test)
virtual

Set a new StatusTest for the solver.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 1530 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP< StatusTest< ScalarType, MV, OP > > Anasazi::BlockDavidson< ScalarType, MV, OP >::getStatusTest ( ) const
virtual

Get the current StatusTest used by the solver.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 1539 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
const Eigenproblem< ScalarType, MV, OP > & Anasazi::BlockDavidson< ScalarType, MV, OP >::getProblem ( ) const
virtual

Get a constant reference to the eigenvalue problem.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 630 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::setBlockSize ( int  blockSize)
virtual

Set the blocksize.

This method is required to support the interface provided by Eigensolver. However, the preferred method of setting the allocated size for the BlockDavidson eigensolver is setSize(). In fact, setBlockSize() simply calls setSize(), maintaining the current number of blocks.

The block size determines the number of Ritz vectors and values that are computed on each iteration, thereby determining the increase in the Krylov subspace at each iteration.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 604 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
int Anasazi::BlockDavidson< ScalarType, MV, OP >::getBlockSize ( ) const
virtual

Get the blocksize used by the iterative solver.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 622 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::setAuxVecs ( const Teuchos::Array< Teuchos::RCP< const MV > > &  auxvecs)
virtual

Set the auxiliary vectors for the solver.

Because the current basis V cannot be assumed orthogonal to the new auxiliary vectors, a call to setAuxVecs() will reset the solver to the uninitialized state. This happens only in the case where the new auxiliary vectors have a combined dimension of greater than zero.

In order to preserve the current state, the user will need to extract it from the solver using getState(), orthogonalize it against the new auxiliary vectors, and reinitialize using initialize().

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 829 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::Array< Teuchos::RCP< const MV > > Anasazi::BlockDavidson< ScalarType, MV, OP >::getAuxVecs ( ) const
virtual

Get the auxiliary vectors for the solver.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 613 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::setSize ( int  blockSize,
int  numBlocks 
)

Set the blocksize and number of blocks to be used by the iterative solver in solving this eigenproblem.

Changing either the block size or the number of blocks will reset the solver to an uninitialized state.

The requested block size must be strictly positive; the number of blocks must be greater than one. Invalid arguments will result in a std::invalid_argument exception.

Definition at line 742 of file AnasaziBlockDavidson.hpp.

template<class ScalarType , class MV , class OP >
void Anasazi::BlockDavidson< ScalarType, MV, OP >::currentStatus ( std::ostream &  os)
virtual

This method requests that the solver print out its current status to the given output stream.

Implements Anasazi::Eigensolver< ScalarType, MV, OP >.

Definition at line 1691 of file AnasaziBlockDavidson.hpp.


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