chombo-discharge
Functions
LaPackUtils Namespace Reference

Namespace containing various useful linear algebra routines using LaPACK. More...

Functions

int linearIndex (const int irow, const int jcol, const int M, const int N)
 Get the index in the linearized matrix of size MxN. More...
 
bool computeSVD (std::vector< double > &a_linU, std::vector< double > &a_linSigma, std::vector< double > &a_linVtran, const std::vector< double > &a_linA, const int &a_M, const int &a_N)
 Compute the singular value decomposition of a matrix. More...
 
bool computeSVD (std::vector< float > &a_linU, std::vector< float > &a_linSigma, std::vector< float > &a_linVtran, const std::vector< float > &a_linA, const int &a_M, const int &a_N)
 Compute the singular value decomposition of a matrix. More...
 
bool computePseudoInverse (std::vector< double > &a_linAplus, const std::vector< double > &a_linA, const int &a_M, const int &a_N)
 Compute the pseudoinverse of matrix through singular value decomposition. More...
 
bool computePseudoInverse (std::vector< float > &a_linAplus, const std::vector< float > &a_linA, const int &a_M, const int &a_N)
 Compute the pseudoinverse of matrix through singular value decomposition. More...
 
void linearizeMatrix (std::vector< double > &a_linA, int &a_M, int &a_N, const std::vector< std::vector< double >> &a_A, const char &a_format)
 Linearize a matrix to column major Fortran form by assuming row or major colum format of the input matrix. More...
 
void linearizeColumnMajorMatrix (std::vector< double > &a_linA, int &a_M, int &a_N, const std::vector< std::vector< double >> &a_A)
 Linearize a matrix to column major Fortran form by column major format of the input matrix. More...
 
void linearizeRowMajorMatrix (std::vector< double > &a_linA, int &a_M, int &a_N, const std::vector< std::vector< double >> &a_A)
 Linearize a matrix to column major Fortran form by row major format of the input matrix. More...
 
void deLinearizeMatrix (std::vector< std::vector< double >> &a_A, const int &a_M, const int &a_N, const std::vector< double > &a_linA, const char &a_format)
 Delinearize a linearized matrix from column major Fortran to row or major colum matrix format. More...
 
void deLinearizeColumnMajorMatrix (std::vector< std::vector< double >> &a_A, const int &a_M, const int &a_N, const std::vector< double > &a_linA)
 Delinearize a linearized matrix from column major Fortran to column major form. More...
 
void deLinearizeRowMajorMatrix (std::vector< std::vector< double >> &a_A, const int &a_M, const int &a_N, const std::vector< double > &a_linA)
 Delinearize a linearized matrix from column major Fortran to row major form. More...
 

Detailed Description

Namespace containing various useful linear algebra routines using LaPACK.

Function Documentation

◆ computePseudoInverse() [1/2]

bool LaPackUtils::computePseudoInverse ( std::vector< double > &  a_linAplus,
const std::vector< double > &  a_linA,
const int &  a_M,
const int &  a_N 
)

Compute the pseudoinverse of matrix through singular value decomposition.

Parameters
[out]a_linAplusPseudoinverse in column major Fortran order.
[in]a_linAInput matrix in column major Fortran order
[in]a_MNumber of rows in A
[in]a_NNumber of colums in A

◆ computePseudoInverse() [2/2]

bool LaPackUtils::computePseudoInverse ( std::vector< float > &  a_linAplus,
const std::vector< float > &  a_linA,
const int &  a_M,
const int &  a_N 
)

Compute the pseudoinverse of matrix through singular value decomposition.

Parameters
[out]a_linAplusPseudoinverse in column major Fortran order.
[in]a_linAInput matrix in column major Fortran order
[in]a_MNumber of rows in A
[in]a_NNumber of colums in A

◆ computeSVD() [1/2]

bool LaPackUtils::computeSVD ( std::vector< double > &  a_linU,
std::vector< double > &  a_linSigma,
std::vector< double > &  a_linVtran,
const std::vector< double > &  a_linA,
const int &  a_M,
const int &  a_N 
)

Compute the singular value decomposition of a matrix.

Parameters
[out]a_linU\(U\)-matrix. Linearized in column major Fortran order.
[out]a_linSigma\(\Sigma\)-matrix. Linearized in column major Fortran order.
[out]a_linVtran\(V^\intercal\)-matrix. Linearized in column major Fortran order.
[in]a_linA\(A\)-matrix. Stored in column-major Fortran form
[in]a_MNumber of rows in A
[in]a_NNumber of columns in A

This routine will compute the singular value decomposition of the input matrix \(A\) in the form

\[ A = U\Sigma V^\intercal. \]

The input and output matrices are assumed to be stored column-major so that a_A[0] is the first column of \(A\).

◆ computeSVD() [2/2]

bool LaPackUtils::computeSVD ( std::vector< float > &  a_linU,
std::vector< float > &  a_linSigma,
std::vector< float > &  a_linVtran,
const std::vector< float > &  a_linA,
const int &  a_M,
const int &  a_N 
)

Compute the singular value decomposition of a matrix.

Parameters
[out]a_linU\(U\)-matrix. Linearized in column major Fortran order.
[out]a_linSigma\(\Sigma\)-matrix. Linearized in column major Fortran order.
[out]a_linVtran\(V^\intercal\)-matrix. Linearized in column major Fortran order.
[in]a_linA\(A\)-matrix. Stored in column-major Fortran form
[in]a_MNumber of rows in A
[in]a_NNumber of columns in A

This routine will compute the singular value decomposition of the input matrix \(A\) in the form

\[ A = U\Sigma V^\intercal. \]

The input and output matrices are assumed to be stored column-major so that a_A[0] is the first column of \(A\).

◆ deLinearizeColumnMajorMatrix()

void LaPackUtils::deLinearizeColumnMajorMatrix ( std::vector< std::vector< double >> &  a_A,
const int &  a_M,
const int &  a_N,
const std::vector< double > &  a_linA 
)

Delinearize a linearized matrix from column major Fortran to column major form.

Parameters
[out]a_AOutput matrix
[in]a_MNumber of rows
[in]a_NNumber of columns
[in]a_linALinearized matrix

◆ deLinearizeMatrix()

void LaPackUtils::deLinearizeMatrix ( std::vector< std::vector< double >> &  a_A,
const int &  a_M,
const int &  a_N,
const std::vector< double > &  a_linA,
const char &  a_format 
)

Delinearize a linearized matrix from column major Fortran to row or major colum matrix format.

Parameters
[out]a_AOutput matrix
[in]a_MNumber of rows
[in]a_NNumber of columns
[in]a_linALinearized matrix
[in]a_formatFormat of input matrix, either 'C' or 'R'. If 'C', then a_A[0] is the first column of the matrix. Likewise, if 'R' then a_A[0] is the first row of the matrix.

◆ deLinearizeRowMajorMatrix()

void LaPackUtils::deLinearizeRowMajorMatrix ( std::vector< std::vector< double >> &  a_A,
const int &  a_M,
const int &  a_N,
const std::vector< double > &  a_linA 
)

Delinearize a linearized matrix from column major Fortran to row major form.

Parameters
[out]a_AOutput matrix
[in]a_MNumber of rows
[in]a_NNumber of columns
[in]a_linALinearized matrix

◆ linearIndex()

int LaPackUtils::linearIndex ( const int  irow,
const int  jcol,
const int  M,
const int  N 
)

Get the index in the linearized matrix of size MxN.

Parameters
[in]irowThe row number
[in]jcolThe column number
[in]MNumber of rows
[in]NNumber columns

◆ linearizeColumnMajorMatrix()

void LaPackUtils::linearizeColumnMajorMatrix ( std::vector< double > &  a_linA,
int &  a_M,
int &  a_N,
const std::vector< std::vector< double >> &  a_A 
)

Linearize a matrix to column major Fortran form by column major format of the input matrix.

Parameters
[out]a_linALinearized matrix
[out]a_MNumber of rows
[out]a_NNumber of columns
[in]a_AInput matrix

◆ linearizeMatrix()

void LaPackUtils::linearizeMatrix ( std::vector< double > &  a_linA,
int &  a_M,
int &  a_N,
const std::vector< std::vector< double >> &  a_A,
const char &  a_format 
)

Linearize a matrix to column major Fortran form by assuming row or major colum format of the input matrix.

Parameters
[out]a_linALinearized matrix
[out]a_MNumber of rows
[out]a_NNumber of columns
[in]a_AInput matrix
[in]a_formatFormat of input matrix, either 'C' or 'R'. If 'C', then a_A[0] is the first column of the matrix. Likewise, if 'R' then a_A[0] is the first row of the matrix.

◆ linearizeRowMajorMatrix()

void LaPackUtils::linearizeRowMajorMatrix ( std::vector< double > &  a_linA,
int &  a_M,
int &  a_N,
const std::vector< std::vector< double >> &  a_A 
)

Linearize a matrix to column major Fortran form by row major format of the input matrix.

Parameters
[out]a_linALinearized matrix
[out]a_MNumber of rows
[out]a_NNumber of columns
[in]a_AInput matrix