Class xlifepp::BasicOrthoManager#
-
template<class ScalarType, class MV, class OP>
class BasicOrthoManager : public xlifepp::MatOrthoManager<ScalarType, MV, OP>#
-
Inheritence diagram for xlifepp::BasicOrthoManager:
Collaboration diagram for xlifepp::BasicOrthoManager:
An implementation of the MatOrthoManager that performs orthogonalization using (potentially) multiple steps of classical Gram-Schmidt.
Accessor routines
-
inline void setKappa(typename NumTraits<ScalarType>::RealScalar kappa)#
-
Set parameter for re-orthogonalization threshold.
-
inline NumTraits<ScalarType>::RealScalar getKappa() const#
-
Return parameter for re-orthogonalization threshold.
Constructor/Destructor
-
BasicOrthoManager(SmartPtr<const OP> Op = _smPtrNull, typename NumTraits<ScalarType>::RealScalar kappa = sqrtOf2_, typename NumTraits<ScalarType>::RealScalar eps = 0.0, typename NumTraits<ScalarType>::RealScalar tol = 0.20)#
-
Constructor specifying re-orthogonalization tolerance.
-
inline ~BasicOrthoManager()#
-
Destructor.
Methods implementing MatOrthoManager
-
virtual void projectMat(MV &X, std::vector<SmartPtr<const MV>> Q, std::vector<SmartPtr<MatrixEigenDense<ScalarType>>> C, SmartPtr<MV> MX, std::vector<SmartPtr<const MV>> MQ) const#
-
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 – [inout]
The multivector to be modified.
On output, the columns of
X
will be orthogonal to eachQ[i]
, satisfying\[ X_{out} = X_{in} - \sum_i Q[i] \langle Q[i], X_{in} \rangle \] MX – [inout] The image of
X
under the inner product operatorOp
. If \( MX != 0\): On input, this is expected to be consistent withOp
. X. On output, this is updated consistent with updates toX
. If \( MX == 0\) or \( Op == 0\):MX
is not referenced.-
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 MatrixEigenDense with size inconsistent withX
and[i]
, then a std::invalid_argument exception will be thrown. Otherwise, ifC.size() < i
orC[i]
is a null pointer, the caller will not have access to the computed coefficients. -
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\ . \] MQ –
-
-
virtual int normalizeMat(MV &X, SmartPtr<MatrixEigenDense<ScalarType>> B = _smPtrNull, SmartPtr<MV> MX = _smPtrNull) const#
-
This method takes a multivector
X
and attempts to compute an orthonormal basis for \(colspan(X)\), with respect to innerProd().The method uses classical Gram-Schmidt with selective reorthogonalization. As a result, the coefficient matrix
B
is upper triangular.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.The method attempts to find a basis with dimension equal to the number of columns in
X
. It does this by augmenting linearly dependent vectors inX
with random directions. A finite number of these attempts will be made; therefore, it is possible that the dimension of the computed basis is less than the number of vectors inX
.- Parameters:
-
-
X – [inout]
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
. MX – [inout] The image of
X
under the inner product operatorOp
. If \( MX != 0\): On input, this is expected to be consistent withOp
. X. On output, this is updated consistent with updates toX
. If \( MX == 0\) or \( Op == 0\):MX
is not referenced.-
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(Xout, Xin, B);
B
points to a MatrixEigenDense with size inconsistent withX
, then a std::invalid_argument exception will be thrown. Otherwise, ifB
is null, the caller will not have access to the computed coefficients. This matrix is not necessarily triangular (as in a QR factorization); see the documentation of specific orthogonalization managers.
The first rows in
B
corresponding to the valid columns inX
will be upper triangular.
-
- 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.
-
virtual int projectAndNormalizeMat(MV &X, std::vector<SmartPtr<const MV>> Q, std::vector<SmartPtr<MatrixEigenDense<ScalarType>>> C, SmartPtr<MatrixEigenDense<ScalarType>> B, SmartPtr<MV> MX = _smPtrNull, std::vector<SmartPtr<const MV>> MQ = std::vector<SmartPtr<const MV>>(1, _smPtrNull)) const#
-
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 doe 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.The method attempts to find a basis with dimension the same as the number of columns in
X
. It does this by augmenting linearly dependent vectors with random directions. A finite number of these attempts will be made; therefore, it is possible that the dimension of the computed basis is less than the number of vectors inX
.- Parameters:
-
-
X – [inout]
The multivector to be modified.
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
. MX – [inout] The image of
X
under the inner product operatorOp
. If \( MX != 0\): On input, this is expected to be consistent withOp
. X. On output, this is updated consistent with updates toX
. If \( MX == 0\) or \( Op == 0\):MX
is not referenced.-
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 MatrixEigenDense with size inconsistent withX
and[i]
, then a std::invalid_argument exception will be thrown. Otherwise, ifC.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(Xout, Xin, B);
B
points to a MatrixEigenDense with size inconsistent withX
, then a std::invalid_argument exception will be thrown. Otherwise, ifB
is null, the caller will not have access to the computed coefficients. This matrix is not necessarily triangular (as in a QR factorization); see the documentation of specific orthogonalization managers.
The first rows in
B
corresponding to the valid columns inX
will be upper triangular. -
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\ . \] MQ –
-
- 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.
Error methods
-
virtual NumTraits<ScalarType>::RealScalar orthonormErrorMat(const MV &X, SmartPtr<const MV> MX = _smPtrNull) const#
-
This method computes the error in orthonormality of a multivector, measured as the Frobenius norm of the difference
innerProd(X,Y) - I
.The method has the option of exploiting a caller-provided
MX
.
-
virtual NumTraits<ScalarType>::RealScalar orthogErrorMat(const MV &X1, const MV &X2, SmartPtr<const MV> MX1, SmartPtr<const MV> MX2) const#
-
This method computes the error in orthogonality of two multivectors, measured as the Frobenius norm of
innerProd(X,Y)
.The method has the option of exploiting a caller-provided
MX
.
-
inline void setKappa(typename NumTraits<ScalarType>::RealScalar kappa)#