Class xlifepp::BlockDavidson#

template<class ScalarType, class MV, class OP>
class BlockDavidson : public xlifepp::EigenSolver<ScalarType, MV, OP>#

Inheritence diagram for xlifepp::BlockDavidson:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "1" [label="xlifepp::BlockDavidson< ScalarType, MV, OP >" tooltip="xlifepp::BlockDavidson< ScalarType, MV, OP >" fillcolor="#BFBFBF"] "2" [label="xlifepp::EigenSolver< ScalarType, MV, OP >" tooltip="xlifepp::EigenSolver< ScalarType, MV, OP >"] "1" -> "2" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for xlifepp::BlockDavidson:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "35" [label="CheckingPolicy< StoragePolicy< MV >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< MV >::StoredType >"] "11" [label="CheckingPolicy< StoragePolicy< T >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< T >::StoredType >"] "31" [label="CheckingPolicy< StoragePolicy< const OP >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< const OP >::StoredType >"] "6" [label="CheckingPolicy< StoragePolicy< xlifepp::EigenProblem< ScalarType, MV, OP > >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< xlifepp::EigenProblem< ScalarType, MV, OP > >::StoredType >"] "27" [label="CheckingPolicy< StoragePolicy< xlifepp::MatOrthoManager< ScalarType, MV, OP > >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< xlifepp::MatOrthoManager< ScalarType, MV, OP > >::StoredType >"] "39" [label="CheckingPolicy< StoragePolicy< xlifepp::MatrixEigenDense< ScalarType > >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< xlifepp::MatrixEigenDense< ScalarType > >::StoredType >"] "19" [label="CheckingPolicy< StoragePolicy< xlifepp::OutputManager< ScalarType > >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< xlifepp::OutputManager< ScalarType > >::StoredType >"] "15" [label="CheckingPolicy< StoragePolicy< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >::StoredType >"] "23" [label="CheckingPolicy< StoragePolicy< xlifepp::StatusTest< ScalarType, MV, OP > >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< xlifepp::StatusTest< ScalarType, MV, OP > >::StoredType >"] "7" [label="ConversionPolicy" tooltip="ConversionPolicy"] "34" [label="OwnershipPolicy< StoragePolicy< MV >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< MV >::InitPointerType >"] "10" [label="OwnershipPolicy< StoragePolicy< T >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< T >::InitPointerType >"] "30" [label="OwnershipPolicy< StoragePolicy< const OP >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< const OP >::InitPointerType >"] "5" [label="OwnershipPolicy< StoragePolicy< xlifepp::EigenProblem< ScalarType, MV, OP > >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< xlifepp::EigenProblem< ScalarType, MV, OP > >::InitPointerType >"] "26" [label="OwnershipPolicy< StoragePolicy< xlifepp::MatOrthoManager< ScalarType, MV, OP > >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< xlifepp::MatOrthoManager< ScalarType, MV, OP > >::InitPointerType >"] "38" [label="OwnershipPolicy< StoragePolicy< xlifepp::MatrixEigenDense< ScalarType > >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< xlifepp::MatrixEigenDense< ScalarType > >::InitPointerType >"] "18" [label="OwnershipPolicy< StoragePolicy< xlifepp::OutputManager< ScalarType > >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< xlifepp::OutputManager< ScalarType > >::InitPointerType >"] "14" [label="OwnershipPolicy< StoragePolicy< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >::InitPointerType >"] "22" [label="OwnershipPolicy< StoragePolicy< xlifepp::StatusTest< ScalarType, MV, OP > >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< xlifepp::StatusTest< ScalarType, MV, OP > >::InitPointerType >"] "32" [label="xlifepp::SmartPtr< MV >" tooltip="xlifepp::SmartPtr< MV >"] "28" [label="xlifepp::SmartPtr< const OP >" tooltip="xlifepp::SmartPtr< const OP >"] "3" [label="xlifepp::SmartPtr< xlifepp::EigenProblem< ScalarType, MV, OP > >" tooltip="xlifepp::SmartPtr< xlifepp::EigenProblem< ScalarType, MV, OP > >"] "24" [label="xlifepp::SmartPtr< xlifepp::MatOrthoManager< ScalarType, MV, OP > >" tooltip="xlifepp::SmartPtr< xlifepp::MatOrthoManager< ScalarType, MV, OP > >"] "36" [label="xlifepp::SmartPtr< xlifepp::MatrixEigenDense< ScalarType > >" tooltip="xlifepp::SmartPtr< xlifepp::MatrixEigenDense< ScalarType > >"] "16" [label="xlifepp::SmartPtr< xlifepp::OutputManager< ScalarType > >" tooltip="xlifepp::SmartPtr< xlifepp::OutputManager< ScalarType > >"] "12" [label="xlifepp::SmartPtr< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >" tooltip="xlifepp::SmartPtr< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >"] "20" [label="xlifepp::SmartPtr< xlifepp::StatusTest< ScalarType, MV, OP > >" tooltip="xlifepp::SmartPtr< xlifepp::StatusTest< ScalarType, MV, OP > >"] "33" [label="StoragePolicy< MV >" tooltip="StoragePolicy< MV >"] "9" [label="StoragePolicy< T >" tooltip="StoragePolicy< T >"] "29" [label="StoragePolicy< const OP >" tooltip="StoragePolicy< const OP >"] "4" [label="StoragePolicy< xlifepp::EigenProblem< ScalarType, MV, OP > >" tooltip="StoragePolicy< xlifepp::EigenProblem< ScalarType, MV, OP > >"] "25" [label="StoragePolicy< xlifepp::MatOrthoManager< ScalarType, MV, OP > >" tooltip="StoragePolicy< xlifepp::MatOrthoManager< ScalarType, MV, OP > >"] "37" [label="StoragePolicy< xlifepp::MatrixEigenDense< ScalarType > >" tooltip="StoragePolicy< xlifepp::MatrixEigenDense< ScalarType > >"] "17" [label="StoragePolicy< xlifepp::OutputManager< ScalarType > >" tooltip="StoragePolicy< xlifepp::OutputManager< ScalarType > >"] "13" [label="StoragePolicy< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >" tooltip="StoragePolicy< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >"] "21" [label="StoragePolicy< xlifepp::StatusTest< ScalarType, MV, OP > >" tooltip="StoragePolicy< xlifepp::StatusTest< ScalarType, MV, OP > >"] "41" [label="std::vector< T >" tooltip="std::vector< T >"] "42" [label="std::vector< MagnitudeType >" tooltip="std::vector< MagnitudeType >"] "40" [label="std::vector< xlifepp::SmartPtr< const MV > >" tooltip="std::vector< xlifepp::SmartPtr< const MV > >"] "1" [label="xlifepp::BlockDavidson< ScalarType, MV, OP >" tooltip="xlifepp::BlockDavidson< ScalarType, MV, OP >" fillcolor="#BFBFBF"] "2" [label="xlifepp::EigenSolver< ScalarType, MV, OP >" tooltip="xlifepp::EigenSolver< ScalarType, MV, OP >"] "8" [label="xlifepp::SmartPtr< T, OwnershipPolicy, ConversionPolicy, CheckingPolicy, StoragePolicy, ConstnessPolicy >" tooltip="xlifepp::SmartPtr< T, OwnershipPolicy, ConversionPolicy, CheckingPolicy, StoragePolicy, ConstnessPolicy >"] "32" -> "33" [dir=forward tooltip="public-inheritance"] "32" -> "34" [dir=forward tooltip="public-inheritance"] "32" -> "35" [dir=forward tooltip="public-inheritance"] "32" -> "7" [dir=forward tooltip="public-inheritance"] "32" -> "8" [dir=forward tooltip="template-instance"] "28" -> "29" [dir=forward tooltip="public-inheritance"] "28" -> "30" [dir=forward tooltip="public-inheritance"] "28" -> "31" [dir=forward tooltip="public-inheritance"] "28" -> "7" [dir=forward tooltip="public-inheritance"] "28" -> "8" [dir=forward tooltip="template-instance"] "3" -> "4" [dir=forward tooltip="public-inheritance"] "3" -> "5" [dir=forward tooltip="public-inheritance"] "3" -> "6" [dir=forward tooltip="public-inheritance"] "3" -> "7" [dir=forward tooltip="public-inheritance"] "3" -> "8" [dir=forward tooltip="template-instance"] "24" -> "25" [dir=forward tooltip="public-inheritance"] "24" -> "26" [dir=forward tooltip="public-inheritance"] "24" -> "27" [dir=forward tooltip="public-inheritance"] "24" -> "7" [dir=forward tooltip="public-inheritance"] "24" -> "8" [dir=forward tooltip="template-instance"] "36" -> "37" [dir=forward tooltip="public-inheritance"] "36" -> "38" [dir=forward tooltip="public-inheritance"] "36" -> "39" [dir=forward tooltip="public-inheritance"] "36" -> "7" [dir=forward tooltip="public-inheritance"] "36" -> "8" [dir=forward tooltip="template-instance"] "16" -> "17" [dir=forward tooltip="public-inheritance"] "16" -> "18" [dir=forward tooltip="public-inheritance"] "16" -> "19" [dir=forward tooltip="public-inheritance"] "16" -> "7" [dir=forward tooltip="public-inheritance"] "16" -> "8" [dir=forward tooltip="template-instance"] "12" -> "13" [dir=forward tooltip="public-inheritance"] "12" -> "14" [dir=forward tooltip="public-inheritance"] "12" -> "15" [dir=forward tooltip="public-inheritance"] "12" -> "7" [dir=forward tooltip="public-inheritance"] "12" -> "8" [dir=forward tooltip="template-instance"] "20" -> "21" [dir=forward tooltip="public-inheritance"] "20" -> "22" [dir=forward tooltip="public-inheritance"] "20" -> "23" [dir=forward tooltip="public-inheritance"] "20" -> "7" [dir=forward tooltip="public-inheritance"] "20" -> "8" [dir=forward tooltip="template-instance"] "42" -> "41" [dir=forward tooltip="template-instance"] "40" -> "41" [dir=forward tooltip="template-instance"] "1" -> "2" [dir=forward tooltip="public-inheritance"] "1" -> "3" [dir=forward tooltip="usage"] "1" -> "12" [dir=forward tooltip="usage"] "1" -> "16" [dir=forward tooltip="usage"] "1" -> "20" [dir=forward tooltip="usage"] "1" -> "24" [dir=forward tooltip="usage"] "1" -> "28" [dir=forward tooltip="usage"] "1" -> "32" [dir=forward tooltip="usage"] "1" -> "36" [dir=forward tooltip="usage"] "1" -> "40" [dir=forward tooltip="usage"] "1" -> "42" [dir=forward tooltip="usage"] "8" -> "9" [dir=forward tooltip="public-inheritance"] "8" -> "10" [dir=forward tooltip="public-inheritance"] "8" -> "11" [dir=forward tooltip="public-inheritance"] "8" -> "7" [dir=forward tooltip="public-inheritance"] }

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)

Output methods

virtual void currentStatus(std::ostream &os)#

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

Constructor/Destructor

BlockDavidson(const SmartPtr<EigenProblem<ScalarType, MV, OP>> &problem, const SmartPtr<SortManager<typename NumTraits<ScalarType>::RealScalar>> &sorter, const SmartPtr<OutputManager<ScalarType>> &printer, const SmartPtr<StatusTest<ScalarType, MV, OP>> &tester, const SmartPtr<MatOrthoManager<ScalarType, MV, OP>> &ortho, Parameters &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.

virtual ~BlockDavidson()#

BlockDavidson destructor.

Solver methods

virtual 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).

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.

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.

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.

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.

Post:

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

Note

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

virtual void initialize()#

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

virtual bool isInitialized() const#

Indicates whether the solver has been initialized or not.

Returns:

bool indicating the state of the solver.

Post:

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 != _smPtrNull

    Otherwise, MX == _smPtrNull

  • R contains the residual vectors with respect to X

BlockDavidsonState<ScalarType, MV> 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.

Status methods

virtual int getNumIters() const#

Get the current iteration count.

virtual void resetNumIters()#

Reset the iteration count.

virtual SmartPtr<const MV> getRitzVectors()#

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().

virtual std::vector<ValueEigenSolver<ScalarType>> getRitzValues()#

Get the Ritz values for the previous iteration.

Returns:

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

virtual std::vector<int> getRitzIndex()#

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.

virtual std::vector<typename NumTraits<ScalarType>::RealScalar> getResNorms()#

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.

virtual std::vector<typename NumTraits<ScalarType>::RealScalar> getRes2Norms()#

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.

virtual std::vector<typename NumTraits<ScalarType>::RealScalar> getRitzRes2Norms()#

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.

virtual int getCurSubspaceDim() const#

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().

virtual int getMaxSubspaceDim() const#

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

Accessor routines from EigenSolver

virtual void setStatusTest(SmartPtr<StatusTest<ScalarType, MV, OP>> test)#

Set a new StatusTest for the solver.

virtual SmartPtr<StatusTest<ScalarType, MV, OP>> getStatusTest() const#

Get the current StatusTest used by the solver.

virtual const EigenProblem<ScalarType, MV, OP> &getProblem() const#

Get a constant reference to the eigenvalue problem.

virtual void setBlockSize(int blockSize)#

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.

virtual int getBlockSize() const#

Get the blocksize used by the iterative solver.

virtual void setAuxVecs(const std::vector<SmartPtr<const MV>> &auxvecs)#

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().

virtual std::vector<SmartPtr<const MV>> getAuxVecs() const#

Get the auxiliary vectors for the solver.

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.

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.