Chombo + EB  3.2
Public Member Functions | Static Public Attributes | Private Attributes | Friends | List of all members
LAPACKMatrix Class Reference

#include <LAPACKMatrix.H>

Public Member Functions

 LAPACKMatrix (int a_nrow, int a_ncol)
 main constructor. Matrix of Chombo Real type. values are unintitialized More...
 
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 More...
 
 LAPACKMatrix ()
 null constructor builds matrix with nullptr and size=[0,0] More...
 
 LAPACKMatrix (const LAPACKMatrix &a_input)
 deep copy constructor More...
 
 LAPACKMatrix (LAPACKMatrix &&a_input)
 move copy constructor More...
 
void clear ()
 
Real normLTwo () const
 return sqrt(sum of squares of all values) More...
 
void setToIdentity ()
 
 ~LAPACKMatrix ()
 
void setVal (const Real &a_val)
 
RealdataPtr ()
 
const RealdataPtr () const
 
void truncate (int a_nrow, int a_ncol)
 
Real maxNorm () const
 
const Realoperator() (int irow, int icol) const
 
Realoperator() (int irow, int icol)
 
std::pair< int, int > dims () const
 
LAPACKMatrixoperator= (const LAPACKMatrix &a_matrix)
 deep assign. More...
 
LAPACKMatrixoperator= (LAPACKMatrix &&a_matrix)
 move assignment More...
 
LAPACKMatrixoperator+= (const LAPACKMatrix &a_matrix)
 
LAPACKMatrixoperator-= (const LAPACKMatrix &a_matrix)
 
LAPACKMatrixoperator*= (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 More...
 
int invertUsingSVD (int a_maxiter, Real a_tol)
 inverts this matrix using SVD More...
 
int pseudoInvertUsingSVD (int a_maxiter, Real a_tol)
 
int pseudoInvertUsingQR ()
 
int invertUsingLeastSquares ()
 inverts this matrix using least squares More...
 
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 More...
 
static bool s_verbose
 
static bool s_outputStenData
 

Private Attributes

int m_nrow
 
int m_ncol
 
Realm_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 More...
 
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)
 

Detailed Description

Getting sick of writing the basics here over and over. Silly class but it will cut down on the typing.

Constructor & Destructor Documentation

◆ LAPACKMatrix() [1/5]

LAPACKMatrix::LAPACKMatrix ( int  a_nrow,
int  a_ncol 
)
inline

main constructor. Matrix of Chombo Real type. values are unintitialized

◆ LAPACKMatrix() [2/5]

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() [3/5]

LAPACKMatrix::LAPACKMatrix ( )
inline

null constructor builds matrix with nullptr and size=[0,0]

◆ LAPACKMatrix() [4/5]

LAPACKMatrix::LAPACKMatrix ( const LAPACKMatrix a_input)

deep copy constructor

◆ LAPACKMatrix() [5/5]

LAPACKMatrix::LAPACKMatrix ( LAPACKMatrix &&  a_input)
inline

move copy constructor

References m_data.

◆ ~LAPACKMatrix()

LAPACKMatrix::~LAPACKMatrix ( )

Referenced by clear().

Member Function Documentation

◆ define()

void LAPACKMatrix::define ( int  nrow,
int  ncol 
)
inline

References m_data, m_ncol, and m_nrow.

Referenced by clear().

◆ clear()

void LAPACKMatrix::clear ( )
inline

◆ normLTwo()

Real LAPACKMatrix::normLTwo ( ) const

return sqrt(sum of squares of all values)

Referenced by clear().

◆ setToIdentity()

void LAPACKMatrix::setToIdentity ( )

if(i==j) M=1 else M=0

Referenced by clear().

◆ setVal()

void LAPACKMatrix::setVal ( const Real a_val)

Referenced by clear().

◆ dataPtr() [1/2]

Real* LAPACKMatrix::dataPtr ( )

Referenced by clear().

◆ dataPtr() [2/2]

const Real* LAPACKMatrix::dataPtr ( ) const

◆ truncate()

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.

Referenced by clear().

◆ maxNorm()

Real LAPACKMatrix::maxNorm ( ) const

Get the maximum absolute value of the matrix (for iterative solves)

Referenced by clear().

◆ operator()() [1/2]

const Real& LAPACKMatrix::operator() ( int  irow,
int  icol 
) const

Referenced by clear().

◆ operator()() [2/2]

Real& LAPACKMatrix::operator() ( int  irow,
int  icol 
)

◆ dims()

std::pair<int, int> LAPACKMatrix::dims ( ) const
inline

References m_ncol, m_nrow, and operator=().

◆ operator=() [1/2]

LAPACKMatrix& LAPACKMatrix::operator= ( const LAPACKMatrix a_matrix)

deep assign.

Referenced by dims().

◆ operator=() [2/2]

LAPACKMatrix& LAPACKMatrix::operator= ( LAPACKMatrix &&  a_matrix)
inline

◆ operator+=()

LAPACKMatrix& LAPACKMatrix::operator+= ( const LAPACKMatrix a_matrix)

Referenced by operator=().

◆ operator-=()

LAPACKMatrix& LAPACKMatrix::operator-= ( const LAPACKMatrix a_matrix)

Referenced by operator=().

◆ operator*=()

LAPACKMatrix& LAPACKMatrix::operator*= ( const Real a_scalingFactor)

Referenced by operator=().

◆ offset()

int LAPACKMatrix::offset ( int  irow,
int  icol 
) const

Referenced by operator=().

◆ poutAll()

void LAPACKMatrix::poutAll ( ) const

Referenced by operator=().

◆ poutDiag()

void LAPACKMatrix::poutDiag ( ) const

Referenced by operator=().

◆ poutDiagMatlab()

void LAPACKMatrix::poutDiagMatlab ( ) const

Referenced by operator=().

◆ poutMatlab()

void LAPACKMatrix::poutMatlab ( ) const

Referenced by operator=().

◆ invert()

int LAPACKMatrix::invert ( )

inverts this matix

fails if matrix is not square if return value != 0, probably a singular matrix

Referenced by operator=().

◆ invertUsingSVD()

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

Referenced by operator=().

◆ pseudoInvertUsingSVD()

int LAPACKMatrix::pseudoInvertUsingSVD ( int  a_maxiter,
Real  a_tol 
)

Referenced by operator=().

◆ pseudoInvertUsingQR()

int LAPACKMatrix::pseudoInvertUsingQR ( )

Referenced by operator=().

◆ invertUsingLeastSquares()

int LAPACKMatrix::invertUsingLeastSquares ( )

inverts this matrix using least squares

Get Ainverse using least squares with svd if return value != 0, lapack was unhappy somehow

Referenced by operator=().

◆ setSmallCellRow()

void LAPACKMatrix::setSmallCellRow ( const int &  irow)
inline

◆ transpose()

void LAPACKMatrix::transpose ( )

Referenced by setSmallCellRow().

◆ checkConditionNumber()

void LAPACKMatrix::checkConditionNumber ( ) const

Referenced by setSmallCellRow().

◆ checkUpperTriangularConditionNumber()

void LAPACKMatrix::checkUpperTriangularConditionNumber ( ) const

Referenced by setSmallCellRow().

Friends And Related Function Documentation

◆ multiply

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

Referenced by setSmallCellRow().

◆ solveLeastSquares

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

Referenced by setSmallCellRow().

◆ solveLeastSquaresTranspose

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

Referenced by setSmallCellRow().

◆ solveLSTSVD [1/2]

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

Referenced by setSmallCellRow().

◆ solveLSTSVD [2/2]

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

◆ solveLSTSVDOnce [1/2]

int solveLSTSVDOnce ( LAPACKMatrix X,
LAPACKMatrix B 
)
friend

Referenced by setSmallCellRow().

◆ solveLSTSVDOnce [2/2]

int solveLSTSVDOnce ( LAPACKMatrix X,
const LAPACKMatrix A,
const LAPACKMatrix B 
)
friend

Solves A*X = B using least squares with SVD, for X

◆ solveEqualityConstrainedLS

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

Referenced by setSmallCellRow().

◆ solveReducedRankLS

int solveReducedRankLS ( LAPACKMatrix A,
LAPACKMatrix b 
)
friend

Solves A'*X = B using reduced rank least squares, for vector b

Referenced by setSmallCellRow().

◆ getInverseOfConditionNumber

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.

Referenced by setSmallCellRow().

◆ getInverseOfUpperTriangularConditionNumber

Real getInverseOfUpperTriangularConditionNumber ( const LAPACKMatrix A)
friend

Referenced by setSmallCellRow().

Member Data Documentation

◆ s_checkConditionNumber

bool LAPACKMatrix::s_checkConditionNumber
static

turn on if you want every solve to check the condition number

◆ s_verbose

bool LAPACKMatrix::s_verbose
static

◆ s_outputStenData

bool LAPACKMatrix::s_outputStenData
static

◆ m_nrow

int LAPACKMatrix::m_nrow
private

Referenced by define(), dims(), and operator=().

◆ m_ncol

int LAPACKMatrix::m_ncol
private

◆ m_data

Real* LAPACKMatrix::m_data
private

Referenced by define(), LAPACKMatrix(), and operator=().

◆ m_alias

bool LAPACKMatrix::m_alias =false
private

Referenced by operator=().


The documentation for this class was generated from the following file: