xlifepp – Functions – Q#

QR#

template<typename T, typename K>
void xlifepp::QR(const LargeMatrix<T> &mat, LargeMatrix<T> *&matR, bool computeQ, LargeMatrix<T> *&matQ, std::vector<K> *rhs, bool &withColPermutation, std::vector<number_t> *&numcol_p, number_t &stop, real_t epsStop = 1.e-10)#

QR factorization of rectangular matrix pxn using Housolder method generic algorithm using a column algorithm with dynamic storage creation of matrix results.

mat: matrix to factorize matR: upper triangular matrix p x n stored as ColCsStorage (pointer) matQ: unitary matrix of size p x p stored as RowCsStorage (pointer) computeQ: if true the matrix Q is computed else not rhs: right hand side vector pointer (modified), if 0 no rhs withColPermutation: if true, column may be permuted (more stable factorization). if false and algorithm fails, withColPermutation is forced to true and algorithm is rerun numcol_p: renumbering of columns if they have been permuted (pointer) stop: iteration number when the algorithm stops: stop = nbr when algorithm exits normally epsStop: relative tolerance, the process stops when the pivot is less than epsStop times the largest norm of the columns of the matrix (remaining rows are considered as redundant or conflicting); a relative test is required because the rounding errors accumulated over the Householder steps of a large system may exceed an absolute tolerance

Note 1 : to avoid unsightly rounding effect in reduction, values < 10*theEspsilon (~10^-15) are rounded to 0 Note 2 : when there are constraint redanduncies, it may occur some average effects. For instance, two Dirichlet conditions at the same point (in Lagrange interpolation) with different right hand side produce a Dirichlet condition with a mean of right hand sides It may be inconvenient !

void xlifepp::QR(const MatrixEntry &mat, MatrixEntry &matR, bool computeQ, MatrixEntry &matQ, VectorEntry *rhs, bool &withColPermutation, std::vector<number_t> *&numcol, number_t &stop, real_t epsStop)#

QR factorization of rectangular matrix pxn with p<=n using Housolder method generic algorithm using a column algorithm with dynamic storage creation of matrix results mat: matrix to factorize matR: upper triangular matrix p x n stored as ColCsStorage matQ: unitary matrix of size p x p stored as RowCsStorage computeQ: if true the matrix Q is computed else not rhs: right hand side vector pointer (if 0 not reduction for rhs) withColPermutation: if true, column may be permuted (more stable factorization), may be forced by algorithm numcol_p: renumbering of columns if they have been permuted (pointer) stop: iteration number when the algorithm stops: stop = nbr when algorithm exits normally.

QR factorisation (relative stopping tolerance)

qr#

template<typename T>
void xlifepp::qr(const Matrix<T> &A, Matrix<T> &Q, Matrix<T> &R)#

QR factorization.

template<typename T>
void xlifepp::qr(const T *A, number_t m, number_t n, T *Q, T *R)#

general template QR using Eigen, assuming A, Q, R are pointers to first value of dense row matrix A: pointer to dense row matrix m,n: number of rows and cols of A Q, R: pointer to QR factors as dense row matrices, has to be allocated before

QRSolve#

template<typename T, typename K>
void xlifepp::QRSolve(const LargeMatrix<T> &mat, LargeMatrix<T> *mat2, std::vector<K> *rhs)#
template<typename T, typename K>
void xlifepp::QRSolve(const LargeMatrix<T> &mat, std::vector<std::vector<std::pair<number_t, K>>> &rhss)#

solve upper triangular system pxp with diag = Id with a list of right hand sides each right hand side is a vector of pairs (row index, value) using a column algorithm with dynamic storage update p | 1 x … x | | 0 1 … x | at = | … | | 0 0 1 x | | 0 0 1 |

mat: upper triangular matrix rhss: list of right hand sides

rhss is overwritten !

void xlifepp::QRSolve(const MatrixEntry &mat, MatrixEntry *matR, VectorEntry *rhs)#

solve an pxp upper triangular system mat: pxp upper triangular matrix with its diagonal coeffs = 1, matR: rectangular matrix p x m, understood as a list of right hand side vectors of size p (if 0 no computation for matR) rhs: a unique right hand side vector pointer (if 0 no computation for rhs)

QR solver (only in scalar representation)

At the end, rhs contains the vector x solution of mat * x = rhs and matR contains the vectors x1, x2, …xm solutions of mat * xj = matRj Note: at the end, matR is stored using a cs column storage

quadrangleQuadrature#

Quadrature *xlifepp::quadrangleQuadrature(QuadRule, number_t)#

find or create quadrature rule over the unit square

quadratic#

std::vector<complex_t> xlifepp::quadratic(complex_t a, complex_t b, complex_t c)#

computes roots of degree 2 complex polynomial

std::vector<complex_t> xlifepp::quadratic(real_t a, real_t b, real_t c)#

computes roots of degree 2 real polynomial