preCICE v3.2.0
|
Class that provides functionality for a dynamic QR-decomposition, that can be updated in O(mn) flops if a column is inserted or deleted. The new column is orthogonalized to the existing columns in Q using a modified GramSchmidt algorithm. The zero-elements are generated using suitable givens-roatations. The Interface provides functions such as insertColumn, deleteColumn at arbitrary position an push or pull column at front or back, resp. More...
#include <QRFactorization.hpp>
Classes | |
struct | givensRot |
Public Member Functions | |
QRFactorization (int filter=0, double omega=0, double theta=1./0.7, double sigma=std::numeric_limits< double >::min()) | |
Constructor. | |
QRFactorization (Eigen::MatrixXd A, int filter, double omega=0, double theta=1./0.7, double sigma=std::numeric_limits< double >::min()) | |
Constructor. | |
QRFactorization (Eigen::MatrixXd Q, Eigen::MatrixXd R, int rows, int cols, int filter, double omega=0, double theta=1./0.7, double sigma=std::numeric_limits< double >::min()) | |
Constructor. | |
virtual | ~QRFactorization ()=default |
Destructor, empty. | |
void | resetFilter (double singularityLimit, std::vector< int > &delIndices, Eigen::MatrixXd &V) |
Performs a reset of A = QR using the QR2 Filter. This eliminates columns during the reconstruction of the QR decomposition. | |
void | reset () |
resets the QR factorization zo zero Q(0:0, 0:0)R(0:0, 0:0) | |
void | reset (Eigen::MatrixXd const &Q, Eigen::MatrixXd const &R, int rows, int cols, double omega=0, double theta=1./0.7, double sigma=std::numeric_limits< double >::min()) |
resets the QR factorization to the given factorization Q, R | |
void | reset (Eigen::MatrixXd const &A, int globalRows, double omega=0, double theta=1./0.7, double sigma=std::numeric_limits< double >::min()) |
resets the QR factorization to be the factorization of A = QR | |
bool | insertColumn (int k, const Eigen::VectorXd &v, double singularityLimit=0) |
inserts a new column at arbitrary position and updates the QR factorization This function works on the memory of v, thus changes the Vector v. | |
void | deleteColumn (int k) |
updates the factorization A=Q[1:n,1:m]R[1:m,1:n] when the kth column of A is deleted. Returns the deleted column v(1:n) | |
void | pushFront (const Eigen::VectorXd &v) |
inserts a new column at position 0, i.e., shifts right and inserts at first position and updates the QR factorization. This function works on the memory of v, thus changes the Vector v. | |
void | pushBack (const Eigen::VectorXd &v) |
inserts a new column at position _cols-1, i.e., appends a column at the end and updates the QR factorization This function works on the memory of v, thus changes the Vector v. | |
void | popFront () |
deletes the column at position 0, i.e., deletes and shifts columns to the left and updates the QR factorization | |
void | popBack () |
deletes the column at position _cols-1, i.e., deletes the last column and updates the QR factorization | |
void | applyFilter (double singularityLimit, std::vector< int > &delIndices, Eigen::MatrixXd &V) |
filters the least squares system, i.e., the decomposition Q*R = V according to the defined filter technique. This is done to ensure good conditioning | |
Eigen::MatrixXd & | matrixQ () |
returns a matrix representation of the orthogonal matrix Q | |
Eigen::MatrixXd & | matrixR () |
returns a matrix representation of the upper triangular matrix R | |
int | cols () const |
int | rows () const |
void | setfstream (std::fstream *stream) |
void | setGlobalRows (int gr) |
void | setFilter (int filter) |
size_t | getResetFilterCounter () const |
Private Member Functions | |
int | orthogonalize_stable (Eigen::VectorXd &v, Eigen::VectorXd &r, double &rho, int colNum) |
assuming Q(1:n,1:m) has nearly orthonormal columns, this procedure orthogonlizes v(1:n) to the columns of Q, and normalizes the result. r(1:n) is the array of Fourier coefficients, and rho is the distance from v to range of Q, r and its corrections are computed in double precision. This method tries to re-orthogonalize the matrix Q for a maximum of 4 iterations if ||v_orth|| / ||v|| <= 1/theta is too small, i.e. the gram schmidt process is iterated. If ||v_orth|| / ||v|| <= std::numeric_limit, a unit vector that is orthogonal to Q is inserted and rho is set to 0. i.e., R has a zero on the diagonal in the respective column. | |
int | orthogonalize (Eigen::VectorXd &v, Eigen::VectorXd &r, double &rho, int colNum) |
assuming Q(1:n,1:m) has nearly orthonormal columns, this procedure orthogonlizes v(1:n) to the columns of Q, and normalizes the result. r(1:n) is the array of Fourier coefficients, and rho is the distance from v to range of Q, r and its corrections are computed in double precision. This method tries to re-orthogonalize the matrix Q for a maximum of 4 iterations if ||v_orth|| / ||v|| <= 1/theta is toot small, i.e. the gram schmidt process is iterated. | |
void | computeReflector (givensRot &grot, double &x, double &y) |
computes parameters for givens matrix G for which (x,y)G = (z,0). replaces (x,y) by (z,0) | |
void | applyReflector (const givensRot &grot, int k, int l, Eigen::VectorXd &p, Eigen::VectorXd &q) |
this procedure replaces the two column matrix [p(k:l-1), q(k:l-1)] by [p(k:l), q(k:l)]*G, where G is the Givens matrix grot, determined by sigma and gamma. | |
Private Attributes | |
logging::Logger | _log {"acceleration::QRFactorization"} |
Eigen::MatrixXd | _Q |
Eigen::MatrixXd | _R |
int | _rows |
int | _cols |
int | _filter |
double | _omega |
double | _theta |
double | _sigma |
bool | _computeQR2Filter = true |
size_t | _resetFilterCounter = 0 |
std::fstream * | _infostream |
bool | _fstream_set |
int | _globalRows |
Class that provides functionality for a dynamic QR-decomposition, that can be updated in O(mn) flops if a column is inserted or deleted. The new column is orthogonalized to the existing columns in Q using a modified GramSchmidt algorithm. The zero-elements are generated using suitable givens-roatations. The Interface provides functions such as insertColumn, deleteColumn at arbitrary position an push or pull column at front or back, resp.
Definition at line 21 of file QRFactorization.hpp.
precice::acceleration::impl::QRFactorization::QRFactorization | ( | int | filter = 0, |
double | omega = 0, | ||
double | theta = 1. / 0.7, | ||
double | sigma = std::numeric_limits<double>::min() ) |
Constructor.
theta | - singularity limit for reothogonalization ||v_orth|| / ||v|| <= 1/theta |
Constructor
Definition at line 86 of file QRFactorization.cpp.
precice::acceleration::impl::QRFactorization::QRFactorization | ( | Eigen::MatrixXd | A, |
int | filter, | ||
double | omega = 0, | ||
double | theta = 1. / 0.7, | ||
double | sigma = std::numeric_limits<double>::min() ) |
Constructor.
theta | - singularity limit for reothogonalization ||v_orth|| / ||v|| <= 1/theta |
Constructor
Definition at line 53 of file QRFactorization.cpp.
precice::acceleration::impl::QRFactorization::QRFactorization | ( | Eigen::MatrixXd | Q, |
Eigen::MatrixXd | R, | ||
int | rows, | ||
int | cols, | ||
int | filter, | ||
double | omega = 0, | ||
double | theta = 1. / 0.7, | ||
double | sigma = std::numeric_limits<double>::min() ) |
Constructor.
theta | - singularity limit for reothogonalization ||v_orth|| / ||v|| <= 1/theta |
Definition at line 22 of file QRFactorization.cpp.
|
virtualdefault |
Destructor, empty.
void precice::acceleration::impl::QRFactorization::applyFilter | ( | double | singularityLimit, |
std::vector< int > & | delIndices, | ||
Eigen::MatrixXd & | V ) |
filters the least squares system, i.e., the decomposition Q*R = V according to the defined filter technique. This is done to ensure good conditioning
[out] | delIndices | - a vector of indices of deleted columns from the LS-system |
Definition at line 105 of file QRFactorization.cpp.
|
private |
this procedure replaces the two column matrix [p(k:l-1), q(k:l-1)] by [p(k:l), q(k:l)]*G, where G is the Givens matrix grot, determined by sigma and gamma.
Definition at line 672 of file QRFactorization.cpp.
int precice::acceleration::impl::QRFactorization::cols | ( | ) | const |
Definition at line 704 of file QRFactorization.cpp.
|
private |
computes parameters for givens matrix G for which (x,y)G = (z,0). replaces (x,y) by (z,0)
Definition at line 647 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::deleteColumn | ( | int | k | ) |
updates the factorization A=Q[1:n,1:m]R[1:m,1:n] when the kth column of A is deleted. Returns the deleted column v(1:n)
updates the factorization A=Q[1:n,1:m]R[1:m,1:n] when the kth column of A is deleted. Returns the deleted column v(1:n)
Definition at line 194 of file QRFactorization.cpp.
size_t precice::acceleration::impl::QRFactorization::getResetFilterCounter | ( | ) | const |
Definition at line 714 of file QRFactorization.cpp.
bool precice::acceleration::impl::QRFactorization::insertColumn | ( | int | k, |
const Eigen::VectorXd & | v, | ||
double | singularityLimit = 0 ) |
inserts a new column at arbitrary position and updates the QR factorization This function works on the memory of v, thus changes the Vector v.
Definition at line 236 of file QRFactorization.cpp.
Eigen::MatrixXd & precice::acceleration::impl::QRFactorization::matrixQ | ( | ) |
returns a matrix representation of the orthogonal matrix Q
Definition at line 694 of file QRFactorization.cpp.
Eigen::MatrixXd & precice::acceleration::impl::QRFactorization::matrixR | ( | ) |
returns a matrix representation of the upper triangular matrix R
Definition at line 699 of file QRFactorization.cpp.
|
private |
assuming Q(1:n,1:m) has nearly orthonormal columns, this procedure orthogonlizes v(1:n) to the columns of Q, and normalizes the result. r(1:n) is the array of Fourier coefficients, and rho is the distance from v to range of Q, r and its corrections are computed in double precision. This method tries to re-orthogonalize the matrix Q for a maximum of 4 iterations if ||v_orth|| / ||v|| <= 1/theta is toot small, i.e. the gram schmidt process is iterated.
assuming Q(1:n,1:m) has nearly orthonormal columns, this procedure orthogonlizes v(1:n) to the columns of Q, and normalizes the result. r(1:n) is the array of Fourier coefficients, and rho is the distance from v to range of Q, r and its corrections are computed in double precision.
Difference to the method orthogonalize_stable(): if ||v_orth||/||v|| approx 0, no unit vector is inserted.
re-orthogonalize if: ||v_orth|| / ||v|| <= 1/theta
Definition at line 344 of file QRFactorization.cpp.
|
private |
assuming Q(1:n,1:m) has nearly orthonormal columns, this procedure orthogonlizes v(1:n) to the columns of Q, and normalizes the result. r(1:n) is the array of Fourier coefficients, and rho is the distance from v to range of Q, r and its corrections are computed in double precision. This method tries to re-orthogonalize the matrix Q for a maximum of 4 iterations if ||v_orth|| / ||v|| <= 1/theta is too small, i.e. the gram schmidt process is iterated. If ||v_orth|| / ||v|| <= std::numeric_limit, a unit vector that is orthogonal to Q is inserted and rho is set to 0. i.e., R has a zero on the diagonal in the respective column.
assuming Q(1:n,1:m) has nearly orthonormal columns, this procedure orthogonlizes v(1:n) to the columns of Q, and normalizes the result. r(1:n) is the array of Fourier coefficients, and rho is the distance from v to range of Q, r and its corrections are computed in double precision.
re-orthogonalize if: ||v_orth|| / ||v|| <= 1/theta
Definition at line 459 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::popBack | ( | ) |
deletes the column at position _cols-1, i.e., deletes the last column and updates the QR factorization
Definition at line 800 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::popFront | ( | ) |
deletes the column at position 0, i.e., deletes and shifts columns to the left and updates the QR factorization
Definition at line 795 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::pushBack | ( | const Eigen::VectorXd & | v | ) |
inserts a new column at position _cols-1, i.e., appends a column at the end and updates the QR factorization This function works on the memory of v, thus changes the Vector v.
Definition at line 790 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::pushFront | ( | const Eigen::VectorXd & | v | ) |
inserts a new column at position 0, i.e., shifts right and inserts at first position and updates the QR factorization. This function works on the memory of v, thus changes the Vector v.
Definition at line 785 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::reset | ( | ) |
resets the QR factorization zo zero Q(0:0, 0:0)R(0:0, 0:0)
Definition at line 719 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::reset | ( | Eigen::MatrixXd const & | A, |
int | globalRows, | ||
double | omega = 0, | ||
double | theta = 1. / 0.7, | ||
double | sigma = std::numeric_limits<double>::min() ) |
resets the QR factorization to be the factorization of A = QR
Definition at line 751 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::reset | ( | Eigen::MatrixXd const & | Q, |
Eigen::MatrixXd const & | R, | ||
int | rows, | ||
int | cols, | ||
double | omega = 0, | ||
double | theta = 1. / 0.7, | ||
double | sigma = std::numeric_limits<double>::min() ) |
resets the QR factorization to the given factorization Q, R
Definition at line 728 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::resetFilter | ( | double | singularityLimit, |
std::vector< int > & | delIndices, | ||
Eigen::MatrixXd & | V ) |
Performs a reset of A = QR using the QR2 Filter. This eliminates columns during the reconstruction of the QR decomposition.
Recomputes QR factorization using the QR2 filter. This removes columns during the QR factorization step. Returns Q and R.
Definition at line 171 of file QRFactorization.cpp.
int precice::acceleration::impl::QRFactorization::rows | ( | ) | const |
Definition at line 709 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::setFilter | ( | int | filter | ) |
Definition at line 811 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::setfstream | ( | std::fstream * | stream | ) |
Definition at line 805 of file QRFactorization.cpp.
void precice::acceleration::impl::QRFactorization::setGlobalRows | ( | int | gr | ) |
Definition at line 689 of file QRFactorization.cpp.
|
private |
Definition at line 219 of file QRFactorization.hpp.
|
private |
Definition at line 226 of file QRFactorization.hpp.
|
private |
Definition at line 221 of file QRFactorization.hpp.
|
private |
Definition at line 231 of file QRFactorization.hpp.
|
private |
Definition at line 233 of file QRFactorization.hpp.
|
private |
Definition at line 230 of file QRFactorization.hpp.
|
private |
Definition at line 213 of file QRFactorization.hpp.
|
private |
Definition at line 222 of file QRFactorization.hpp.
|
private |
Definition at line 215 of file QRFactorization.hpp.
|
private |
Definition at line 216 of file QRFactorization.hpp.
|
private |
Definition at line 227 of file QRFactorization.hpp.
|
private |
Definition at line 218 of file QRFactorization.hpp.
|
private |
Definition at line 224 of file QRFactorization.hpp.
|
private |
Definition at line 223 of file QRFactorization.hpp.