15 : _preconditioner(
std::move(preconditioner)),
82 Q = Matrix::Zero(A.rows(), A.cols());
83 R = Matrix::Zero(A.cols(), A.cols());
94 for (
int colIndex = 0; colIndex < A.cols(); colIndex++) {
100 Vector col = A.col(colIndex);
104 PRECICE_WARN(
"The matrix that is about to be factorized is quadratic, i.e., the new column cannot be orthogonalized; discard.");
111 Vector r = Vector::Zero(R.rows());
112 Vector s = Vector::Zero(R.rows());
113 Vector u = Vector::Zero(A.rows());
114 double rho_orth = 0.;
119 bool termination =
false;
120 bool orthogonalized =
true;
122 while (!termination) {
125 u = Vector::Zero(A.rows());
126 for (
int j = 0; j < colsQ; j++) {
135 u += Q.col(j) * r_ij;
151 PRECICE_DEBUG(
"The norm of v_orthogonal is almost zero, i.e., failed to orthogonalize column v; discard.");
152 orthogonalized =
false;
168 if (rho_orth * theta <= rho0 + omega * norm_coefficients) {
171 PRECICE_WARN(
"Matrix Q is not sufficiently orthogonal. Failed to orthogonalize new column after 4 iterations. New column will be discarded.");
172 orthogonalized =
false;
186 orthogonalized =
false;
190 double rho = orthogonalized ? rho_orth : 1.0;
210 if (not orthogonalized) {
217 Q.col(colsQ) = Vector::Zero(A.rows());
223 R.row(rowsR) = Vector::Zero(A.cols());
227 Q.conservativeResize(A.rows(), colsQ);
228 R.conservativeResize(rowsR, colsR);
#define PRECICE_WARN(...)
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_ASSERT(...)
int _cols
Number of columns, i.e., rank of the truncated svd.
PtrParMatrixOps _parMatrixOps
: object for parallel matrix operations, i.e., parallel mat-mat/ mat-vec multiplications
void setApplyFilterQR(bool b, double eps=1e-3)
: enables or disables an additional QR-2 filter for the QR-decomposition
int _rows
Number of rows (on each proc, i.e., local)
double _truncationEps
Truncation parameter for the updated SVD decomposition.
bool _initialSVD
true, if at least one update has been made, i.e., the number of rows is known and a initial rank is g...
double getThreshold()
: returns the truncation threshold for the SVD
bool _preconditionerApplied
true if the preconditioner has been applied appropriate to the updated SVD decomposition
void setThreshold(double eps)
: sets the threshold for the truncation of the SVD factorization
int _globalRows
Number of global rows, i.e., sum of _rows for all procs.
Matrix _psi
: SVD factorization of the matrix J = _psi * _sigma * _phi^T
void setPrecondApplied(bool b)
: applies the preconditioner to the factorized and truncated representation of the Jacobian matrix
Matrix & matrixPhi()
: returns a matrix representation of the orthogonal matrix Phi, A = Psi * Sigma * Phi^T
void initialize(PtrParMatrixOps parMatOps, int globalRows)
: initializes the updated SVD factorization, i.e., sets the object for parallel matrix-matrix operati...
Vector & singularValues()
: returns a matrix representation of the orthogonal matrix Sigma, A = Psi * Sigma * Phi^T
void reset()
: resets the SVD factorization
Rank rank()
: returns the rank of the truncated SVD factorization
double _epsQR2
Threshold for the QR2 filter for the QR decomposition.
Matrix & matrixPsi()
: returns a matrix representation of the orthogonal matrix Psi, A = Psi * Sigma * Phi^bs
bool _initialized
true, if ParallelMatrixOperations object is set, i.e., initialized
int cols()
: returns the number of columns in the QR-decomposition
SVDFactorization(double eps, PtrPreconditioner preconditioner)
Constructor.
int rows()
: returns the number of rows in the QR-decomposition
void computeQRdecomposition(Matrix const &A, Matrix &Q, Matrix &R)
: computes the QR decomposition of a matrix A of type A = PSI^T*A \in R^(rank x n)
int getWaste()
: returns the total number of truncated modes since last call to this method
static double l2norm(const Eigen::VectorXd &vec)
The l2 norm of a vector is calculated on distributed data.
static double dot(const Eigen::VectorXd &vec1, const Eigen::VectorXd &vec2)