Class xlifepp::OrthoManager#
-
template<class ScalarType, class MV>
class OrthoManager#
-
Inheritence diagram for xlifepp::OrthoManager:
Collaboration diagram for xlifepp::OrthoManager:
xlifepp’s templated virtual class for providing routines for orthogonalization and orthonormalization of multivectors.
This class defines concepts of orthogonality through the definition of an inner product. It also provides computational routines for orthogonalization.
A concrete implementation of this class is necessary. The user can create their own implementation if those supplied are not suitable for their needs.
Subclassed by xlifepp::MatOrthoManager< ScalarType, MV, OP >
Constructor/Destructor
-
inline OrthoManager()#
-
Default constructor.
-
inline virtual ~OrthoManager()#
-
Destructor.
Orthogonalization methods
-
virtual void innerProd(const MV &X, const MV &Y, MatrixEigenDense<ScalarType> &Z) const = 0#
-
Provides the inner product defining the orthogonality concepts.
All concepts of orthogonality discussed in this class are defined with respect to this inner product.
- Parameters:
-
X, Y – multi vectors
-
Z – [out]
Z(i,j)
contains the inner product ofX[i]
andY[i]
:\[ Z(i,j) = \langle X[i], Y[i] \rangle \]
Note
This is potentially different from MultiVecTraits::MvTransMv(). For example, it is customary in many eigensolvers to exploit a mass matrix
M
for the inner product: \(x^HMx\).
-
virtual void norm(const MV &X, std::vector<typename NumTraits<ScalarType>::RealScalar> &normvec) const = 0#
-
Provides the norm induced by innerProd().
This computes the norm for each column of a multivector. This is the norm induced by innerProd():
\[ \|x\| = \sqrt{\langle x, x \rangle} \]- Parameters:
-
normvec – [out] Vector of norms, whose
i-th
entry corresponds to thei-th
column ofX
X – [in] multi vector
- Pre:
-
normvec.size() == GetNumberVecs(X)
-
virtual void project(MV &X, std::vector<SmartPtr<const MV>> Q, std::vector<SmartPtr<MatrixEigenDense<ScalarType>>> C) const = 0#
-
Given a list of mutually orthogonal and internally orthonormal bases
Q
, this method projects a multivectorX
onto the space orthogonal to the individualQ[i]
, optionally returning the coefficients ofX
for the individualQ[i]
.All of this is done with respect to the inner product innerProd().
After calling this routine,
X
will be orthogonal to each of theQ[i]
.- Parameters:
-
-
X –
[in/out] The multivector to be modified.
On output, the columns of
X
will be orthogonal to eachQ[i]
, satisfying\[ \langle Q[i], X_{out} \rangle = 0 \]Also,\[ X_{out} = X_{in} - \sum_i Q[i] \langle Q[i], X_{in} \rangle \] -
Q – [in] A list of multivector bases specifying the subspaces to be orthogonalized against, satisfying
\[ \langle Q[i], Q[j] \rangle = I \quad\textrm{if}\quad i=j \]and\[ \langle Q[i], Q[j] \rangle = 0 \quad\textrm{if}\quad i \neq j\ . \] -
C – [out] The coefficients of
X
in the basesQ[i]
. IfC[i]
is a non-null pointer andC[i]
matches the dimensions ofX
andQ[i]
, then the coefficients computed during the orthogonalization routine will be stored in the matrixC[i]
, similar to callinginnerProd(Q[i], X, C[i]);
C[i]
points to a Teuchos::SerialDenseMatrix with size inconsistent withX
and[i]
, then a std::invalid_argument exception will be thrown.
Otherwise, if
C.size() < i
orC[i]
is a null pointer, the caller will not have access to the computed coefficients.
-
-
virtual int normalize(MV &X, SmartPtr<MatrixEigenDense<ScalarType>> B = _smPtrNull) const = 0#
-
This method takes a multivector
X
and attempts to compute a basis for \(colspan(X)\).This basis is orthonormal with respect to innerProd().
This routine returns an integer
rank
stating the rank of the computed basis. IfX
does not have full rank and the normalize() routine does not attempt to augment the subspace, thenrank
may be smaller than the number of columns inX
. In this case, only the firstrank
columns of outputX
and firstrank
rows ofB
will be valid.- Parameters:
-
-
X –
[in/out] The multivector to be modified.
On output, the first
rank
columns ofX
satisfy\[ \langle X[i], X[j] \rangle = \delta_{ij}\ . \]Also,\[ X_{in}(1:m,1:n) = X_{out}(1:m,1:rank) B(1:rank,1:n)\ , \]wherem
is the number of rows inX
andn
is the number of columns inX
. -
B – [out] The coefficients of the original
X
with respect to the computed basis. IfB
is a non-null pointer andB
matches the dimensions ofB
, then the coefficients computed during the orthogonalization routine will be stored inB
, similar to callinginnerProd(X_{out}, X_{in}, B);
B
points to a Teuchos::SerialDenseMatrix with size inconsistent withX
, then a std::invalid_argument exception will be thrown.
Otherwise, if
B
is null, the caller will not have access to the computed coefficients.
-
- Returns:
-
Rank of the basis computed by this method, less than or equal to the number of columns in
X
. This specifies how many columns in the returnedX
and rows in the returnedB
are valid.
Note
This matrix is not necessarily triangular (as in a QR factorization); see the documentation of specific orthogonalization managers.
-
virtual int projectAndNormalize(MV &X, std::vector<SmartPtr<const MV>> Q, std::vector<SmartPtr<MatrixEigenDense<ScalarType>>> C = std::vector<SmartPtr<MatrixEigenDense<ScalarType>>>(1, _smPtrNull), SmartPtr<MatrixEigenDense<ScalarType>> B = _smPtrNull) const = 0#
-
Given a set of bases
Q[i]
and a multivectorX
, this method computes an orthonormal basis for \(colspan(X) - \sum_i colspan(Q[i])\).This routine returns an integer
rank
stating the rank of the computed basis. If the subspace \(colspan(X) - \sum_i colspan(Q[i])\) does not have dimension as large as the number of columns ofX
and the orthogonalization manager does not attempt to augment the subspace, thenrank
may be smaller than the number of columns ofX
. In this case, only the firstrank
columns of outputX
and firstrank
rows ofB
will be valid.- Parameters:
-
-
X – [in/out] On output, the first
rank
columns ofX
satisfy\[ \langle X[i], X[j] \rangle = \delta_{ij} \quad \textrm{and} \quad \langle X, Q[i] \rangle = 0\ . \]Also,\[ X_{in}(1:m,1:n) = X_{out}(1:m,1:rank) B(1:rank,1:n) + \sum_i Q[i] C[i] \]wherem
is the number of rows inX
andn
is the number of columns inX
. -
Q – [in] A list of multivector bases specifying the subspaces to be orthogonalized against, satisfying
\[ \langle Q[i], Q[j] \rangle = I \quad\textrm{if}\quad i=j \]and\[ \langle Q[i], Q[j] \rangle = 0 \quad\textrm{if}\quad i \neq j\ . \] -
C – [out] The coefficients of
X
in theQ[i]
. IfC[i]
is a non-null pointer andC[i]
matches the dimensions ofX
andQ[i]
, then the coefficients computed during the orthogonalization routine will be stored in the matrixC[i]
, similar to callinginnerProd(Q[i], X, C[i]);
C[i]
points to a Teuchos::SerialDenseMatrix with size inconsistent withX
and[i]
, then a std::invalid_argument exception will be thrown.
Otherwise, if
C.size() < i
orC[i]
is a null pointer, the caller will not have access to the computed coefficients. -
B – [out] The coefficients of the original
X
with respect to the computed basis. IfB
is a non-null pointer andB
matches the dimensions ofB
, then the coefficients computed during the orthogonalization routine will be stored inB
, similar to callinginnerProd(Sout, Sin, B);
B
points to a Teuchos::SerialDenseMatrix with size inconsistent withX
, then a std::invalid_argument exception will be thrown.
Otherwise, if
B
is null, the caller will not have access to the computed coefficients.
-
- Returns:
-
Rank of the basis computed by this method, less than or equal to the number of columns in
X
. This specifies how many columns in the returnedX
and rows in the returnedB
are valid.
Note
This routine guarantees both the orthogonality of the returned basis against the
Q[i]
as well as the orthonormality of the returned basis. Therefore, this method is not necessarily equivalent to calling project() followed by a call to normalize(); see the documentation for specific orthogonalization managers.Note
This matrix is not necessarily triangular (as in a QR factorization); see the documentation of specific orthogonalization managers.
Error methods
-
virtual NumTraits<ScalarType>::RealScalar orthonormError(const MV &X) const = 0#
-
This method computes the error in orthonormality of a multivector.
This method return some measure of \(\| \langle X, X \rangle - I \| \)
.
See the documentation of specific orthogonalization managers.
-
virtual NumTraits<ScalarType>::RealScalar orthogError(const MV &X1, const MV &X2) const = 0#
-
This method computes the error in orthogonality of two multivectors.
This method return some measure of \(\| \langle X1, X2 \rangle \| \)
.
See the documentation of specific orthogonalization managers.
-
inline OrthoManager()#