#include <LAPACKMatrix.H>
Public Member Functions | |
LAPACKMatrix (int a_nrow, int a_ncol) | |
main constructor. Matrix of Chombo Real type. values are unintitialized | |
void | define (int nrow, int ncol) |
LAPACKMatrix (int a_nrow, int a_ncol, Real *a_data) | |
alias constructor. Use a_data as m_data, does not delete it in destructor | |
LAPACKMatrix () | |
null constructor builds matrix with nullptr and size=[0,0] | |
LAPACKMatrix (const LAPACKMatrix &a_input) | |
deep copy constructor | |
LAPACKMatrix (LAPACKMatrix &&a_input) | |
move copy constructor | |
void | clear () |
Real | normLTwo () const |
return sqrt(sum of squares of all values) | |
void | setToIdentity () |
~LAPACKMatrix () | |
void | setVal (const Real &a_val) |
Real * | dataPtr () |
const Real * | dataPtr () const |
void | truncate (int a_nrow, int a_ncol) |
Real | maxNorm () const |
const Real & | operator() (int irow, int icol) const |
Real & | operator() (int irow, int icol) |
std::pair< int, int > | dims () const |
LAPACKMatrix & | operator= (const LAPACKMatrix &a_matrix) |
deep assign. | |
LAPACKMatrix & | operator= (LAPACKMatrix &&a_matrix) |
move assignment | |
LAPACKMatrix & | operator+= (const LAPACKMatrix &a_matrix) |
LAPACKMatrix & | operator-= (const LAPACKMatrix &a_matrix) |
LAPACKMatrix & | operator*= (const Real &a_scalingFactor) |
int | offset (int irow, int icol) const |
void | poutAll () const |
void | poutDiag () const |
void | poutDiagMatlab () const |
void | poutMatlab () const |
int | invert () |
inverts this matix | |
int | invertUsingSVD (int a_maxiter, Real a_tol) |
inverts this matrix using SVD | |
int | pseudoInvertUsingSVD (int a_maxiter, Real a_tol) |
int | pseudoInvertUsingQR () |
int | invertUsingLeastSquares () |
inverts this matrix using least squares | |
void | setSmallCellRow (const int &irow) |
void | transpose () |
void | checkConditionNumber () const |
void | checkUpperTriangularConditionNumber () const |
Static Public Attributes | |
static bool | s_checkConditionNumber |
turn on if you want every solve to check the condition number | |
static bool | s_verbose |
static bool | s_outputStenData |
Private Attributes | |
int | m_nrow |
int | m_ncol |
Real * | m_data |
bool | m_alias = false |
Friends | |
void | multiply (LAPACKMatrix &a_product, const LAPACKMatrix &a_left, const LAPACKMatrix &a_right) |
int | solveLeastSquares (LAPACKMatrix &A, LAPACKMatrix &B) |
below stuff is shamelessly stolen from lapackwrapper class | |
int | solveLeastSquaresTranspose (LAPACKMatrix &A, LAPACKMatrix &B) |
int | solveLSTSVD (LAPACKMatrix &A, LAPACKMatrix &B, int a_maxiter, Real a_tol) |
int | solveLSTSVD (LAPACKMatrix &X, const LAPACKMatrix &A, const LAPACKMatrix &B, int a_maxiter, Real a_tol) |
int | solveLSTSVDOnce (LAPACKMatrix &X, LAPACKMatrix &B) |
int | solveLSTSVDOnce (LAPACKMatrix &X, const LAPACKMatrix &A, const LAPACKMatrix &B) |
int | solveEqualityConstrainedLS (LAPACKMatrix &A, LAPACKMatrix &c, LAPACKMatrix &B, LAPACKMatrix &d, LAPACKMatrix &x) |
int | solveReducedRankLS (LAPACKMatrix &A, LAPACKMatrix &b) |
Real | getInverseOfConditionNumber (const LAPACKMatrix &A) |
Real | getInverseOfUpperTriangularConditionNumber (const LAPACKMatrix &A) |
LAPACKMatrix::LAPACKMatrix | ( | int | a_nrow, | |
int | a_ncol | |||
) | [inline] |
main constructor. Matrix of Chombo Real type. values are unintitialized
LAPACKMatrix::LAPACKMatrix | ( | int | a_nrow, | |
int | a_ncol, | |||
Real * | a_data | |||
) | [inline] |
alias constructor. Use a_data as m_data, does not delete it in destructor
LAPACKMatrix::LAPACKMatrix | ( | ) | [inline] |
null constructor builds matrix with nullptr and size=[0,0]
LAPACKMatrix::LAPACKMatrix | ( | const LAPACKMatrix & | a_input | ) |
deep copy constructor
LAPACKMatrix::LAPACKMatrix | ( | LAPACKMatrix && | a_input | ) | [inline] |
move copy constructor
LAPACKMatrix::~LAPACKMatrix | ( | ) |
void LAPACKMatrix::define | ( | int | nrow, | |
int | ncol | |||
) | [inline] |
void LAPACKMatrix::clear | ( | ) | [inline] |
References define().
Real LAPACKMatrix::normLTwo | ( | ) | const |
return sqrt(sum of squares of all values)
void LAPACKMatrix::setToIdentity | ( | ) |
if(i==j) M=1 else M=0
void LAPACKMatrix::setVal | ( | const Real & | a_val | ) |
Real* LAPACKMatrix::dataPtr | ( | ) |
const Real* LAPACKMatrix::dataPtr | ( | ) | const |
void LAPACKMatrix::truncate | ( | int | a_nrow, | |
int | a_ncol | |||
) |
make nrows = a_nrows etc. Useful when you want to discard the last few rows of the matrix.
Real LAPACKMatrix::maxNorm | ( | ) | const |
Get the maximum absolute value of the matrix (for iterative solves)
const Real& LAPACKMatrix::operator() | ( | int | irow, | |
int | icol | |||
) | const |
Real& LAPACKMatrix::operator() | ( | int | irow, | |
int | icol | |||
) |
LAPACKMatrix& LAPACKMatrix::operator= | ( | const LAPACKMatrix & | a_matrix | ) |
deep assign.
LAPACKMatrix& LAPACKMatrix::operator= | ( | LAPACKMatrix && | a_matrix | ) | [inline] |
LAPACKMatrix& LAPACKMatrix::operator+= | ( | const LAPACKMatrix & | a_matrix | ) |
LAPACKMatrix& LAPACKMatrix::operator-= | ( | const LAPACKMatrix & | a_matrix | ) |
LAPACKMatrix& LAPACKMatrix::operator*= | ( | const Real & | a_scalingFactor | ) |
int LAPACKMatrix::offset | ( | int | irow, | |
int | icol | |||
) | const |
void LAPACKMatrix::poutAll | ( | ) | const |
void LAPACKMatrix::poutDiag | ( | ) | const |
void LAPACKMatrix::poutDiagMatlab | ( | ) | const |
void LAPACKMatrix::poutMatlab | ( | ) | const |
int LAPACKMatrix::invert | ( | ) |
inverts this matix
fails if matrix is not square if return value != 0, probably a singular matrix
int LAPACKMatrix::invertUsingSVD | ( | int | a_maxiter, | |
Real | a_tol | |||
) |
inverts this matrix using SVD
Get Ainverse using least squares with svd if return value != 0, lapack was unhappy somehow
int LAPACKMatrix::pseudoInvertUsingSVD | ( | int | a_maxiter, | |
Real | a_tol | |||
) |
int LAPACKMatrix::pseudoInvertUsingQR | ( | ) |
int LAPACKMatrix::invertUsingLeastSquares | ( | ) |
inverts this matrix using least squares
Get Ainverse using least squares with svd if return value != 0, lapack was unhappy somehow
void LAPACKMatrix::setSmallCellRow | ( | const int & | irow | ) | [inline] |
References m_ncol.
void LAPACKMatrix::transpose | ( | ) |
void LAPACKMatrix::checkConditionNumber | ( | ) | const |
void LAPACKMatrix::checkUpperTriangularConditionNumber | ( | ) | const |
void multiply | ( | LAPACKMatrix & | a_product, | |
const LAPACKMatrix & | a_left, | |||
const LAPACKMatrix & | a_right | |||
) | [friend] |
sets product = a_left* a_right fails if a_left.m_col != a_right.m_rows
sets product = a_left* a_right fails if a_left.m_col != a_right.m_rows
int solveLeastSquares | ( | LAPACKMatrix & | A, | |
LAPACKMatrix & | B | |||
) | [friend] |
below stuff is shamelessly stolen from lapackwrapper class
Solves A*X = B using general least squares, for each column of B
Solves A*X = B using general least squares, for each column of B
int solveLeastSquaresTranspose | ( | LAPACKMatrix & | A, | |
LAPACKMatrix & | B | |||
) | [friend] |
Solves A'*X = B using least squares, for vector b. Answer goes back into B I think
Solves A'*X = B using least squares, for vector b
int solveLSTSVD | ( | LAPACKMatrix & | A, | |
LAPACKMatrix & | B, | |||
int | a_maxiter, | |||
Real | a_tol | |||
) | [friend] |
Solves A^T X = B using least squares with SVD, for vector b
int solveLSTSVD | ( | LAPACKMatrix & | X, | |
const LAPACKMatrix & | A, | |||
const LAPACKMatrix & | B, | |||
int | a_maxiter, | |||
Real | a_tol | |||
) | [friend] |
Solves A*X = B using least squares with SVD, for X
int solveLSTSVDOnce | ( | LAPACKMatrix & | X, | |
LAPACKMatrix & | B | |||
) | [friend] |
int solveLSTSVDOnce | ( | LAPACKMatrix & | X, | |
const LAPACKMatrix & | A, | |||
const LAPACKMatrix & | B | |||
) | [friend] |
Solves A*X = B using least squares with SVD, for X
int solveEqualityConstrainedLS | ( | LAPACKMatrix & | A, | |
LAPACKMatrix & | c, | |||
LAPACKMatrix & | B, | |||
LAPACKMatrix & | d, | |||
LAPACKMatrix & | x | |||
) | [friend] |
Solves equality constrained least squares problem Find x, s.t. min norm(A x - c) with B x = d
int solveReducedRankLS | ( | LAPACKMatrix & | A, | |
LAPACKMatrix & | b | |||
) | [friend] |
Solves A'*X = B using reduced rank least squares, for vector b
Real getInverseOfConditionNumber | ( | const LAPACKMatrix & | A | ) | [friend] |
Following Lapack, gets inverse of condition number. Returning a number near zero means the matrix is not really solvable.
Real getInverseOfUpperTriangularConditionNumber | ( | const LAPACKMatrix & | A | ) | [friend] |
bool LAPACKMatrix::s_checkConditionNumber [static] |
turn on if you want every solve to check the condition number
bool LAPACKMatrix::s_verbose [static] |
bool LAPACKMatrix::s_outputStenData [static] |
int LAPACKMatrix::m_nrow [private] |
Referenced by define(), dims(), and operator=().
int LAPACKMatrix::m_ncol [private] |
Referenced by define(), dims(), operator=(), and setSmallCellRow().
Real* LAPACKMatrix::m_data [private] |
Referenced by define(), and operator=().
bool LAPACKMatrix::m_alias = false [private] |
Referenced by operator=().