Class xlifepp::BlockKrylovSchur#
-
template<class ScalarType, class MV, class OP>
class BlockKrylovSchur : public xlifepp::EigenSolver<ScalarType, MV, OP>#
-
Inheritence diagram for xlifepp::BlockKrylovSchur:
Collaboration diagram for xlifepp::BlockKrylovSchur:
This class implements the block Krylov-Schur iteration, for solving linear eigenvalue problems.
This method is a block version of the iteration presented by G.W. Stewart in “A Krylov-Schur Algorithm for Large Eigenproblems”, SIAM J. Matrix Anal. Appl., Vol 23(2001), No. 3, pp. 601-614.
Block-Krylov Schur compute routines
- friend struct internalEigenSolver::SortSchurForm< MatrixEigenDense< ScalarType >, NumTraits< ScalarType >::IsComplex >
-
void computeRitzVectors()#
-
Compute the Ritz vectors using the current Krylov factorization.
-
void computeRitzValueEigenSolvers()#
-
Compute the Ritz values using the current Krylov factorization.
-
void computeSchurForm(const bool sort = true)#
-
Compute the Schur form of the projected eigenproblem from the current Krylov factorization.
Constructor/Destructor
-
BlockKrylovSchur(const SmartPtr<EigenProblem<ScalarType, MV, OP>> &problem, const SmartPtr<SortManager<typename NumTraits<ScalarType>::magnitudeType>> &sorter, const SmartPtr<OutputManager<ScalarType>> &printer, const SmartPtr<StatusTest<ScalarType, MV, OP>> &tester, const SmartPtr<OrthoManager<ScalarType, MV>> &ortho, Parameters ¶ms)#
-
BlockKrylovSchur 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. Default: 1”Num Blocks” - an
int
specifying the maximum number of blocks allocated for the solver basis. Default: 3*problem->getNEV()”Step Size” - an
int
specifying how many iterations are performed between computations of eigenvalues and eigenvectors.”Number of Ritz Vectors” - an
int
specifying how many Ritz vectors are computed on calls to getRitzVectors(). Default: 0”Print Number of Ritz ValueEigenSolvers” - an
int
specifying how many Ritz values are printed on calls to currentStatus(). Default: “Block Size”
Note
This parameter is mandatory.
-
inline virtual ~BlockKrylovSchur()#
-
BlockKrylovSchur destructor.
Solver methods
-
virtual void iterate()#
-
This method performs Block Krylov-Schur iterations until the status test indicates the need to stop or an error occurs (in which case, an exception is thrown).
iterate() will first determine whether the solver is inintialized; if not, it will call initialize() using default arguments. After initialization, the solver performs Block Krylov-Schur iterations until the status test evaluates as _passed, at which point the method returns to the caller.
The Block Krylov-Schur iteration proceeds as follows:
The operator problem->getOperator() is applied to the newest
blockSize
vectors in the Krylov basis.The resulting vectors are orthogonalized against the auxiliary vectors and the previous basis vectors, and made orthonormal.
The Hessenberg matrix is updated.
If we have performed
stepSize
iterations since the last update, update the Ritz values and Ritz residuals.
The status test is queried at the beginning of the iteration.
-
void initialize(BlockKrylovSchurState<ScalarType, MV> state)#
-
Initialize the solver to an iterate, providing a Krylov basis and Hessenberg matrix.
The BlockKrylovSchur eigensolver contains a certain amount of state, consisting of the current Krylov basis and the associated Hessenberg matrix.
initialize() gives the user the opportunity to manually set these, although this must be done with caution, abiding by the rules given below. All notions of orthogonality and orthonormality are derived from the inner product specified by the orthogonalization manager.
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 necessary component of the state 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.
-
inline 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:
the first getCurSubspaceDim() vectors of V are orthogonal to auxiliary vectors and have orthonormal columns
the principal Hessenberg submatrix of of H contains the Hessenberg matrix associated with V
-
inline BlockKrylovSchurState<ScalarType, MV> getState() const#
-
Get the current state of the eigensolver.
The data is only valid if isInitialized() ==
true
.- Returns:
-
A BlockKrylovSchurState object containing const pointers to the current solver state.
Status methods
-
inline virtual int getNumIters() const#
-
Get the current iteration count.
-
inline virtual void resetNumIters()#
-
Reset the iteration count.
-
inline virtual SmartPtr<const MV> getRitzVectors()#
-
Get the Ritz vectors.
- Returns:
-
A multivector of columns not exceeding the maximum dimension of the subspace containing the Ritz vectors from the most recent call to computeRitzVectors().
Note
To see if the returned Ritz vectors are current, call isRitzVecsCurrent().
-
inline virtual std::vector<ValueEigenSolver<ScalarType>> getRitzValues()#
-
Get the Ritz values.
- Returns:
-
A vector of length not exceeding the maximum dimension of the subspace containing the Ritz values from the most recent Schur form update.
Note
To see if the returned Ritz values are current, call isRitzValsCurrent().
-
inline virtual std::vector<int> getRitzIndex()#
-
Get the Ritz index vector.
- Returns:
-
A vector of length not exceeding the maximum dimension of the subspace containing the index vector for the Ritz values and Ritz vectors, if they are computed.
-
inline virtual std::vector<typename NumTraits<ScalarType>::magnitudeType> getResNorms()#
-
Get the current residual norms.
Note
Block Krylov-Schur cannot provide this so a zero length vector will be returned.
-
inline virtual std::vector<typename NumTraits<ScalarType>::magnitudeType> getRes2Norms()#
-
Get the current residual 2-norms.
Note
Block Krylov-Schur cannot provide this so a zero length vector will be returned.
-
inline virtual std::vector<typename NumTraits<ScalarType>::magnitudeType> getRitzRes2Norms()#
-
Get the current Ritz residual 2-norms.
- Returns:
-
A vector of length blockSize containing the 2-norms of the Ritz residuals.
Accessor routines
-
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.
-
inline virtual const EigenProblem<ScalarType, MV, OP> &getProblem() const#
-
Get a constant reference to the eigenvalue problem.
-
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.
-
virtual void setBlockSize(int blockSize)#
-
Set the blocksize.
-
void setStepSize(int stepSize)#
-
Set the step size.
-
void setNumRitzVectors(int numRitzVecs)#
-
Set the number of Ritz vectors to compute.
-
inline int getStepSize() const#
-
Get the step size.
-
inline virtual int getBlockSize() const#
-
Get the blocksize to be used by the iterative solver in solving this eigenproblem.
-
inline int getNumRitzVectors() const#
-
Get the number of Ritz vectors to compute.
-
inline 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.
-
inline virtual int getMaxSubspaceDim() const#
-
Get the maximum dimension allocated for the search subspace.
-
virtual void setAuxVecs(const std::vector<SmartPtr<const MV>> &auxvecs)#
-
Set the auxiliary vectors for the solver.
Because the current Krylov subspace 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().
Output methods
-
virtual void currentStatus(std::ostream &os)#
-
This method requests that the solver print out its current status to screen.
Block-Krylov Schur status routines
-
inline bool isRitzVecsCurrent() const#
-
Get the status of the Ritz vectors currently stored in the eigensolver.
-
inline bool isRitzValsCurrent() const#
-
Get the status of the Ritz values currently stored in the eigensolver.
-
inline bool isSchurCurrent() const#
-
Get the status of the Schur form currently stored in the eigensolver.