libROM  v1.0
Data-driven physical simulation library
Public Member Functions | List of all members
CAROM::Matrix Class Reference

#include <Matrix.h>

Public Member Functions

 Matrix ()
 
 Matrix (int num_rows, int num_cols, bool distributed, bool randomized=false)
 
 Matrix (double *mat, int num_rows, int num_cols, bool distributed, bool copy_data=true)
 
 Matrix (const Matrix &other)
 Copy constructor. More...
 
 ~Matrix ()
 Destructor.
 
Matrixoperator= (const Matrix &rhs)
 Assignment operator. More...
 
Matrixoperator= (const double a)
 Assignment operator. More...
 
Matrixoperator+= (const Matrix &rhs)
 Addition operator. More...
 
Matrixoperator-= (const Matrix &rhs)
 Subtraction operator. More...
 
void setSize (int num_rows, int num_cols)
 Sets the number of rows and columns of the matrix and reallocates storage if needed. All values are initialized to zero. More...
 
bool distributed () const
 Returns true if the Matrix is distributed. More...
 
bool balanced () const
 Returns true if rows of matrix are load-balanced.
 
int numRows () const
 Returns the number of rows of the Matrix on this processor. More...
 
int numDistributedRows () const
 Returns the number of rows of the Matrix across all processors. More...
 
int numColumns () const
 Returns the number of columns in the Matrix. This method will return the same value from each processor. More...
 
MatrixgetFirstNColumns (int n) const
 Get the first N columns of a matrix. More...
 
void getFirstNColumns (int n, Matrix *&result) const
 Get the first N columns of a matrix. More...
 
void getFirstNColumns (int n, Matrix &result) const
 Get the first N columns of a matrix. More...
 
Matrixmult (const Matrix &other) const
 Multiplies this Matrix with other and returns the product, reference version. More...
 
Matrixmult (const Matrix *other) const
 Multiplies this Matrix with other and returns the product, pointer version. More...
 
void mult (const Matrix &other, Matrix *&result) const
 Multiplies this Matrix with other and fills result with the answer. More...
 
void mult (const Matrix &other, Matrix &result) const
 Multiplies this Matrix with other and fills result with the answer. More...
 
Vectormult (const Vector &other) const
 Multiplies this Matrix with other and returns the product, reference version. More...
 
Vectormult (const Vector *other) const
 Multiplies this Matrix with other and returns the product, pointer version. More...
 
void mult (const Vector &other, Vector *&result) const
 Multiplies this Matrix with other and fills result with the answer. More...
 
void mult (const Vector &other, Vector &result) const
 Multiplies this Matrix with other and fills result with the answer. More...
 
void pointwise_mult (int this_row, const Vector &other, Vector &result) const
 Multiplies a specified row of this Matrix with other pointwise. More...
 
void pointwise_mult (int this_row, Vector &other) const
 Multiplies a specified row of this Matrix with other pointwise. This modifies other. More...
 
Matrixelementwise_mult (const Matrix &other) const
 Multiplies two matrices element-wise. More...
 
Matrixelementwise_mult (const Matrix *other) const
 Multiplies two matrices element-wise and returns the product, pointer version. More...
 
void elementwise_mult (const Matrix &other, Matrix *&result) const
 Multiplies two matrices element-wise and fills result with the answer. More...
 
void elementwise_mult (const Matrix &other, Matrix &result) const
 Multiplies two matrices element-wise and fills result with the answer. More...
 
Matrixelementwise_square () const
 Square every element in the matrix. More...
 
void elementwise_square (Matrix *&result) const
 Square every element in the matrix. More...
 
void elementwise_square (Matrix &result) const
 Square every element in the matrix. More...
 
void multPlus (Vector &a, const Vector &b, double c) const
 Computes a += this*b*c. More...
 
MatrixtransposeMult (const Matrix &other) const
 Multiplies the transpose of this Matrix with other and returns the product, reference version. More...
 
MatrixtransposeMult (const Matrix *other) const
 Multiplies the transpose of this Matrix with other and returns the product, pointer version. More...
 
void transposeMult (const Matrix &other, Matrix *&result) const
 Multiplies the transpose of this Matrix with other and fills result with the answer. More...
 
void transposeMult (const Matrix &other, Matrix &result) const
 Multiplies the transpose of this Matrix with other and fills result with the answer. More...
 
VectortransposeMult (const Vector &other) const
 Multiplies the transpose of this Matrix with other and returns the product, reference version. More...
 
VectortransposeMult (const Vector *other) const
 Multiplies the transpose of this Matrix with other and returns the product, pointer version. More...
 
void transposeMult (const Vector &other, Vector *&result) const
 Multiplies the transpose of this Matrix with other and fills result with the answer. More...
 
void transposeMult (const Vector &other, Vector &result) const
 Multiplies the transpose of this Matrix with other and fills result with the answer. More...
 
Matrixinverse () const
 Computes and returns the inverse of this. More...
 
void inverse (Matrix *&result) const
 Computes and returns the inverse of this. More...
 
void inverse (Matrix &result) const
 Computes and returns the inverse of this. More...
 
void inverse ()
 Computes the inverse of this and stores result in this. More...
 
VectorgetColumn (int column) const
 Returns a column of the matrix (not owned by Matrix). More...
 
void getColumn (int column, Vector *&result) const
 Returns a column of the matrix (not owned by Matrix). More...
 
void getColumn (int column, Vector &result) const
 Returns a column of the matrix (not owned by Matrix). More...
 
void transpose ()
 Replaces this Matrix with its transpose (in place), in the serial square case only. More...
 
void transposePseudoinverse ()
 Computes the transposePseudoinverse of this. More...
 
Matrixqr_factorize () const
 Computes and returns the Q of the QR factorization of this. More...
 
void qrcp_pivots_transpose (int *row_pivot, int *row_pivot_owner, int pivots_requested) const
 Compute the leading numColumns() column pivots from a QR decomposition with column pivots (QRCP) of the transpose of this. More...
 
void orthogonalize ()
 Orthogonalizes the matrix.
 
void rescale_rows_max ()
 Rescale every matrix row by its maximum absolute value.
 
void rescale_cols_max ()
 Rescale every matrix column by its maximum absolute value.
 
const double & item (int row, int col) const
 Const Matrix member access. Matrix data is stored in row-major format. More...
 
double & item (int row, int col)
 Non-const Matrix member access. Matrix data is stored in row-major format. More...
 
const double & operator() (int row, int col) const
 Const Matrix member access. More...
 
double & operator() (int row, int col)
 Non-const Matrix member access. More...
 
void print (const char *prefix) const
 print Matrix into (a) ascii file(s). More...
 
void write (const std::string &base_file_name) const
 write Matrix into (a) HDF file(s). More...
 
void read (const std::string &base_file_name)
 read Matrix into (a) HDF file(s). More...
 
void local_read (const std::string &base_file_name, int rank)
 read a single rank of a distributed Matrix into (a) HDF file(s). More...
 
double * getData () const
 Get the matrix data as a pointer.
 
void distribute (const int &local_num_rows)
 Distribute this matrix rows among MPI processes, based on the specified local number of rows. This becomes distributed after this function is executed. More...
 
void gather ()
 Gather all the distributed rows among MPI processes. This becomes not distributed after this function is executed. More...
 

Detailed Description

Class Matrix is a simple matrix class in which the rows may be distributed across multiple processes. This class supports only the basic operations that are needed by the SVD library.

Constructor & Destructor Documentation

◆ Matrix() [1/4]

CAROM::Matrix::Matrix ( )

Empty Constructor

◆ Matrix() [2/4]

CAROM::Matrix::Matrix ( int  num_rows,
int  num_cols,
bool  distributed,
bool  randomized = false 
)

Constructor creating a Matrix with uninitialized values.

Precondition
num_rows > 0
num_cols > 0
Parameters
[in]num_rowsWhen undistributed, the total number of rows of the Matrix. When distributed, the part of the total number of rows of the Matrix on this processor.
[in]num_colsThe total number of columns of the Matrix.
[in]distributedIf true the rows of the Matrix are spread over all processors.
[in]randomizedIf true the matrix will be a standard normally distributed random matrix.

◆ Matrix() [3/4]

CAROM::Matrix::Matrix ( double *  mat,
int  num_rows,
int  num_cols,
bool  distributed,
bool  copy_data = true 
)

Constructor creating a Matrix with uninitialized values.

Precondition
mat != 0
num_rows > 0
num_cols > 0
Parameters
[in]matThe initial values of the Matrix.
[in]num_rowsWhen undistributed, the total number of rows of the Matrix. When distributed, the part of the total number of rows of the Matrix on this processor.
[in]num_colsThe total number of columns of the Matrix.
[in]distributedIf true the rows of the Matrix are spread over all processors.
[in]copy_dataIf true the matrix allocates its own storage and copies the contents of mat into its own storage. Otherwise it uses mat as its storage.

◆ Matrix() [4/4]

CAROM::Matrix::Matrix ( const Matrix other)

Copy constructor.

Parameters
[in]otherThe Matrix to copy.

Member Function Documentation

◆ distribute()

void CAROM::Matrix::distribute ( const int &  local_num_rows)

Distribute this matrix rows among MPI processes, based on the specified local number of rows. This becomes distributed after this function is executed.

Precondition
!distributed()
d_owns_data
Parameters
[in]local_num_rowsnumber of rows for local MPI rank.

◆ distributed()

bool CAROM::Matrix::distributed ( ) const
inline

Returns true if the Matrix is distributed.

Returns
True if the Matrix is distributed.

◆ elementwise_mult() [1/4]

Matrix* CAROM::Matrix::elementwise_mult ( const Matrix other) const
inline

Multiplies two matrices element-wise.

Precondition
result.distributed() == distributed()
distributed() == other.distributed()
numRows() == other.numRows()
numColumns() == other.numColumns()
Parameters
[in]otherThe Matrix to multiply with this.
Returns
The product Matrix.

◆ elementwise_mult() [2/4]

void CAROM::Matrix::elementwise_mult ( const Matrix other,
Matrix result 
) const

Multiplies two matrices element-wise and fills result with the answer.

Precondition
result == 0 || result->distributed() == distributed()
distributed() == other.distributed()
numRows() == other.numRows()
numColumns() == other.numColumns()
Parameters
[in]otherThe Matrix to multiply with this.
[out]resultThe product Matrix.

◆ elementwise_mult() [3/4]

void CAROM::Matrix::elementwise_mult ( const Matrix other,
Matrix *&  result 
) const

Multiplies two matrices element-wise and fills result with the answer.

Precondition
result == 0 || result->distributed() == distributed()
distributed() == other.distributed()
numRows() == other.numRows()
numColumns() == other.numColumns()
Parameters
[in]otherThe Matrix to multiply with this.
[out]resultThe product Matrix.

◆ elementwise_mult() [4/4]

Matrix* CAROM::Matrix::elementwise_mult ( const Matrix other) const
inline

Multiplies two matrices element-wise and returns the product, pointer version.

Precondition
other != 0
distributed() == other.distributed()
numRows() == other.numRows()
numColumns() == other.numColumns()
Parameters
[in]otherThe Matrix to multiply with this.
Returns
The product Matrix.

◆ elementwise_square() [1/3]

Matrix* CAROM::Matrix::elementwise_square ( ) const
inline

Square every element in the matrix.

Returns
The product Matrix.

◆ elementwise_square() [2/3]

void CAROM::Matrix::elementwise_square ( Matrix result) const

Square every element in the matrix.

Precondition
result == 0 || result->distributed() == distributed()
Parameters
[out]resultThe product Matrix.

◆ elementwise_square() [3/3]

void CAROM::Matrix::elementwise_square ( Matrix *&  result) const

Square every element in the matrix.

Precondition
result == 0 || result->distributed() == distributed()
Parameters
[out]resultThe product Matrix.

◆ gather()

void CAROM::Matrix::gather ( )

Gather all the distributed rows among MPI processes. This becomes not distributed after this function is executed.

Precondition
distributed()
d_owns_data

◆ getColumn() [1/3]

Vector* CAROM::Matrix::getColumn ( int  column) const
inline

Returns a column of the matrix (not owned by Matrix).

Returns
A column of the matrix (not owned by Matrix).

◆ getColumn() [2/3]

void CAROM::Matrix::getColumn ( int  column,
Vector result 
) const

Returns a column of the matrix (not owned by Matrix).

Returns
A column of the matrix (not owned by Matrix).

◆ getColumn() [3/3]

void CAROM::Matrix::getColumn ( int  column,
Vector *&  result 
) const

Returns a column of the matrix (not owned by Matrix).

Returns
A column of the matrix (not owned by Matrix).

◆ getFirstNColumns() [1/3]

Matrix * CAROM::Matrix::getFirstNColumns ( int  n) const

Get the first N columns of a matrix.

Precondition
0 < n < numColumns()
Parameters
[in]nThe number of columns to return.
Returns
The truncated Matrix.

◆ getFirstNColumns() [2/3]

void CAROM::Matrix::getFirstNColumns ( int  n,
Matrix result 
) const

Get the first N columns of a matrix.

Precondition
result.distributed() == distributed()
0 < n < numColumns()
Parameters
[in]nThe number of columns to return.
[out]resultThe truncated Matrix.

◆ getFirstNColumns() [3/3]

void CAROM::Matrix::getFirstNColumns ( int  n,
Matrix *&  result 
) const

Get the first N columns of a matrix.

Precondition
result.distributed() == distributed()
0 < n < numColumns()
Parameters
[in]nThe number of columns to return.
[out]resultThe truncated Matrix.

◆ inverse() [1/4]

void CAROM::Matrix::inverse ( )

Computes the inverse of this and stores result in this.

Precondition
!distributed()
numRows() == numColumns()

◆ inverse() [2/4]

Matrix* CAROM::Matrix::inverse ( ) const
inline

Computes and returns the inverse of this.

Precondition
!distributed()
numRows() == numColumns()
Returns
The inverse of this.

◆ inverse() [3/4]

void CAROM::Matrix::inverse ( Matrix result) const

Computes and returns the inverse of this.

Result will be sized accordingly.

Precondition
!result.distributed() && result.numRows() == numRows() && result.numColumns() == numColumns()
!distributed()
numRows() == numColumns()
Parameters
[out]resultThe inverse of this.

◆ inverse() [4/4]

void CAROM::Matrix::inverse ( Matrix *&  result) const

Computes and returns the inverse of this.

If result has not been allocated it will be, otherwise it will be sized accordingly.

Precondition
result == 0 || (!result->distributed() && result->numRows() == numRows() && result->numColumns() == numColumns())
!distributed()
numRows() == numColumns()
Parameters
[out]resultThe inverse of this.

◆ item() [1/2]

double& CAROM::Matrix::item ( int  row,
int  col 
)
inline

Non-const Matrix member access. Matrix data is stored in row-major format.

Allows constructs of the form mat[i, j] = val;

Precondition
(0 <= row) && (row < numRows())
(0 <= col) && (col < numColumns())
Parameters
[in]rowThe row of the Matrix value on this processor requested.
[in]colThe column of the Matrix value requested.

◆ item() [2/2]

const double& CAROM::Matrix::item ( int  row,
int  col 
) const
inline

Const Matrix member access. Matrix data is stored in row-major format.

Precondition
(0 <= row) && (row < numRows())
(0 <= col) && (col < numColumns())
Parameters
[in]rowThe row of the Matrix value on this processor requested.
[in]colThe column of the Matrix value requested.

◆ local_read()

void CAROM::Matrix::local_read ( const std::string &  base_file_name,
int  rank 
)

read a single rank of a distributed Matrix into (a) HDF file(s).

Parameters
[in]base_file_nameThe base part of the file name.
[in]rankThe rank to read from.

◆ mult() [1/8]

Matrix* CAROM::Matrix::mult ( const Matrix other) const
inline

Multiplies this Matrix with other and returns the product, reference version.

Supports multiplication of two undistributed matrices returning an undistributed Matrix, and multiplication of a distributed Matrix with an undistributed Matrix returning a distributed Matrix.

Precondition
!other.distributed()
numColumns() == other.numRows()
Parameters
[in]otherThe Matrix to multiply with this.
Returns
The product Matrix.

◆ mult() [2/8]

void CAROM::Matrix::mult ( const Matrix other,
Matrix result 
) const

Multiplies this Matrix with other and fills result with the answer.

Supports multiplication of two undistributed matrices resulting in an undistributed Matrix, and multiplication of a distributed Matrix with an undistributed Matrix resulting in a distributed Matrix. Result will be sized accordingly.

Precondition
result.distributed() == distributed()
!other.distributed()
numColumns() == other.numRows()
Parameters
[in]otherThe Matrix to multiply with this.
[out]resultThe product Matrix.

◆ mult() [3/8]

void CAROM::Matrix::mult ( const Matrix other,
Matrix *&  result 
) const

Multiplies this Matrix with other and fills result with the answer.

Supports multiplication of two undistributed matrices resulting in an undistributed Matrix, and multiplication of a distributed Matrix with an undistributed Matrix resulting in a distributed Matrix. If result has not been allocated it will be, otherwise it will be sized accordingly.

Precondition
result == 0 || result->distributed() == distributed()
!other.distributed()
numColumns() == other.numRows()
Parameters
[in]otherThe Matrix to multiply with this.
[out]resultThe product Matrix.

◆ mult() [4/8]

Matrix* CAROM::Matrix::mult ( const Matrix other) const
inline

Multiplies this Matrix with other and returns the product, pointer version.

Supports multiplication of two undistributed matrices returning an undistributed Matrix, and multiplication of a distributed Matrix with an undistributed Matrix returning a distributed Matrix.

Precondition
other != 0
!other->distributed()
numColumns() == other->numRows()
Parameters
[in]otherThe Matrix to multiply with this.
Returns
The product Matrix.

◆ mult() [5/8]

Vector* CAROM::Matrix::mult ( const Vector other) const
inline

Multiplies this Matrix with other and returns the product, reference version.

Supports multiplication of an undistributed Matrix and Vector returning an undistributed Vector, and multiplication of a distributed Matrix and an undistributed Vector returning a distributed Vector.

Precondition
!other.distributed()
numColumns() == other.dim()
Parameters
[in]otherThe Vector to multiply with this.
Returns
The product Vector.

◆ mult() [6/8]

void CAROM::Matrix::mult ( const Vector other,
Vector result 
) const

Multiplies this Matrix with other and fills result with the answer.

Supports multiplication of an undistributed Matrix and Vector resulting in an undistributed Vector, and multiplication of a distributed Matrix and an undistributed Vector resulting in a distributed Vector. Result will be sized accordingly.

Precondition
result.distributed() == distributed()
!other.distributed()
numColumns() == other.dim()
Parameters
[in]otherThe Vector to multiply with this.
[out]resultThe product Vector.

◆ mult() [7/8]

void CAROM::Matrix::mult ( const Vector other,
Vector *&  result 
) const

Multiplies this Matrix with other and fills result with the answer.

Supports multiplication of an undistributed Matrix and Vector resulting in an undistributed Vector, and multiplication of a distributed Matrix and an undistributed Vector resulting in a distributed Vector. If result has not been allocated it will be, otherwise it will be sized accordingly.

Precondition
result == 0 || result->distributed() == distributed()
!other.distributed()
numColumns() == other.dim()
Parameters
[in]otherThe Vector to multiply with this.
[out]resultThe product Vector.

◆ mult() [8/8]

Vector* CAROM::Matrix::mult ( const Vector other) const
inline

Multiplies this Matrix with other and returns the product, pointer version.

Supports multiplication of an undistributed Matrix and Vector returning an undistributed Vector, and multiplication of a distributed Matrix and an undistributed Vector returning a distributed Vector.

Precondition
other != 0
!other->distributed()
numColumns() == other->dim()
Parameters
[in]otherThe Vector to multiply with this.
Returns
The product Vector.

◆ multPlus()

void CAROM::Matrix::multPlus ( Vector a,
const Vector b,
double  c 
) const

Computes a += this*b*c.

Supports accumulation of the multiplication of an undistributed Matrix and Vector into an undistributed Vector, and accumulation of the multiplication of a distributed Matrix and an undistributed Vector into a distributed Vector.

Precondition
a.distributed() == distributed()
!b->distributed()
numColumns() == b.dim()
numRows() = a.dim()
Parameters
[in,out]aThe Vector to accumulate this*b into.
[in]bThe Vector multiplied by this.
[in]cScalar multiplication factor.

◆ numColumns()

int CAROM::Matrix::numColumns ( ) const
inline

Returns the number of columns in the Matrix. This method will return the same value from each processor.

Returns
The number of columns of the Matrix.

◆ numDistributedRows()

int CAROM::Matrix::numDistributedRows ( ) const
inline

Returns the number of rows of the Matrix across all processors.

Returns
The number of rows of the Matrix across all processors.

◆ numRows()

int CAROM::Matrix::numRows ( ) const
inline

Returns the number of rows of the Matrix on this processor.

Returns
The number of rows of the Matrix on this processor.

◆ operator()() [1/2]

double& CAROM::Matrix::operator() ( int  row,
int  col 
)
inline

Non-const Matrix member access.

Allows constructs of the form mat[i, j] = val;

Precondition
(0 <= row) && (row < numRows())
(0 <= col) && (col < numColumns())
Parameters
[in]rowThe row of the Matrix value on this processor requested.
[in]colThe column of the Matrix value requested.

◆ operator()() [2/2]

const double& CAROM::Matrix::operator() ( int  row,
int  col 
) const
inline

Const Matrix member access.

Precondition
(0 <= row) && (row < numRows())
(0 <= col) && (col < numColumns())
Parameters
[in]rowThe row of the Matrix value on this processor requested.
[in]colThe column of the Matrix value requested.

◆ operator+=()

Matrix & CAROM::Matrix::operator+= ( const Matrix rhs)

Addition operator.

Parameters
[in]rhsThe Matrix to add to this.
Returns
This after rhs has been added to it.

◆ operator-=()

Matrix & CAROM::Matrix::operator-= ( const Matrix rhs)

Subtraction operator.

Parameters
[in]rhsThe Matrix to subtract to this.
Returns
This after rhs has been subtracted to it.

◆ operator=() [1/2]

Matrix & CAROM::Matrix::operator= ( const double  a)

Assignment operator.

Parameters
[in]aconstant value
Returns
This after filling all the data with a constant value

◆ operator=() [2/2]

Matrix & CAROM::Matrix::operator= ( const Matrix rhs)

Assignment operator.

Parameters
[in]rhsThe Matrix to assign to this.
Returns
This after rhs has been assigned to it.

◆ pointwise_mult() [1/2]

void CAROM::Matrix::pointwise_mult ( int  this_row,
const Vector other,
Vector result 
) const

Multiplies a specified row of this Matrix with other pointwise.

Only supports multiplication of an undistributed Matrix and Vector resulting in an undistributed Vector. Result will be sized accordingly.

Precondition
!result.distributed()
!distributed()
!other.distributed()
numColumns() == other.dim()
Parameters
[in]this_rowThe row of the matrix to multiple with other.
[in]otherThe Vector to multiply with this_row of the matrix.
[out]resultThe product Vector.

◆ pointwise_mult() [2/2]

void CAROM::Matrix::pointwise_mult ( int  this_row,
Vector other 
) const

Multiplies a specified row of this Matrix with other pointwise. This modifies other.

Only supports multiplication of an undistributed Matrix and Vector resulting in an undistributed Vector. Result will be sized accordingly.

Precondition
!result.distributed()
!distributed()
!other.distributed()
numColumns() == other.dim()
Parameters
[in]this_rowThe row of the matrix to multiple with other.
[in]otherThe Vector to multiply with this_row of the matrix.
[out]otherThe product Vector.

◆ print()

void CAROM::Matrix::print ( const char *  prefix) const

print Matrix into (a) ascii file(s).

Parameters
[in]prefixThe name of the prefix of the file name.

◆ qr_factorize()

Matrix * CAROM::Matrix::qr_factorize ( ) const

Computes and returns the Q of the QR factorization of this.

Returns
The Q of the QR factorization of this.

◆ qrcp_pivots_transpose()

void CAROM::Matrix::qrcp_pivots_transpose ( int *  row_pivot,
int *  row_pivot_owner,
int  pivots_requested 
) const

Compute the leading numColumns() column pivots from a QR decomposition with column pivots (QRCP) of the transpose of this.

Precondition
!distributed()
Parameters
[out]row_pivotArray of leading column pivots from QRCP of transpose of this Matrix, has length pivots_requested
[out]row_pivot_ownerArray of process rank that owns each pivot on the communicator owned by this Matrix.
[in]pivots_requestedThe number of pivots requested, must be less than or equal to the number of rows of this Matrix.

◆ read()

void CAROM::Matrix::read ( const std::string &  base_file_name)

read Matrix into (a) HDF file(s).

Parameters
[in]base_file_nameThe base part of the file name.

◆ setSize()

void CAROM::Matrix::setSize ( int  num_rows,
int  num_cols 
)
inline

Sets the number of rows and columns of the matrix and reallocates storage if needed. All values are initialized to zero.

Parameters
[in]num_rowsNew number of rows
[in]num_colsNew number of cols

◆ transpose()

void CAROM::Matrix::transpose ( )

Replaces this Matrix with its transpose (in place), in the serial square case only.

Precondition
!distributed()
numRows() == numColumns()

◆ transposeMult() [1/8]

Matrix* CAROM::Matrix::transposeMult ( const Matrix other) const
inline

Multiplies the transpose of this Matrix with other and returns the product, reference version.

Supports multiplication of two undistributed matrices returning an undistributed Matrix or two distributed matrices returning an undistributed Matrix.

Precondition
distributed() == other.distributed()
numRows() == other.numRows()
Parameters
[in]otherThe Matrix to multiply with this.
Returns
The product Matrix.

◆ transposeMult() [2/8]

void CAROM::Matrix::transposeMult ( const Matrix other,
Matrix result 
) const

Multiplies the transpose of this Matrix with other and fills result with the answer.

Supports multiplication of two undistributed matrices or two distributed matrices resulting in an undistributed Matrix. Result will be sized accordingly.

Precondition
!result.distributed()
distributed() == other.distributed()
numRows() == other.numRows()
Parameters
[in]otherThe Matrix to multiply with this.
[out]resultThe product Matrix.

◆ transposeMult() [3/8]

void CAROM::Matrix::transposeMult ( const Matrix other,
Matrix *&  result 
) const

Multiplies the transpose of this Matrix with other and fills result with the answer.

Supports multiplication of two undistributed matrices or two distributed matrices resulting in an undistributed Matrix. If result has not been allocated it will be, otherwise it will be sized accordingly.

Precondition
result == 0 || !result->distributed()
distributed() == other.distributed()
numRows() == other.numRows()
Parameters
[in]otherThe Matrix to multiply with this.
[out]resultThe product Matrix.

◆ transposeMult() [4/8]

Matrix* CAROM::Matrix::transposeMult ( const Matrix other) const
inline

Multiplies the transpose of this Matrix with other and returns the product, pointer version.

Supports multiplication of two undistributed matrices returning an undistributed Matrix or two distributed matrices returning an undistributed Matrix.

Precondition
other != 0
distributed() == other->distributed()
numRows() == other->numRows()
Parameters
[in]otherThe Matrix to multiply with this.
Returns
The product Matrix.

◆ transposeMult() [5/8]

Vector* CAROM::Matrix::transposeMult ( const Vector other) const
inline

Multiplies the transpose of this Matrix with other and returns the product, reference version.

Supports multiplication of an undistributed Matrix and an undistributed Vector or a distributed Matrix and a distributed Vector returning an undistributed Vector.

Precondition
distributed() == other.distributed()
numRows() == other.dim();
Parameters
[in]otherThe Vector to multiply with this.
Returns
The product Vector.

◆ transposeMult() [6/8]

void CAROM::Matrix::transposeMult ( const Vector other,
Vector result 
) const

Multiplies the transpose of this Matrix with other and fills result with the answer.

Supports multiplication of an undistributed Matrix and an undistributed Vector or a distributed Matrix and a distributed Vector resulting in an undistributed Vector. Result will be sized accordingly.

Precondition
!result.distributed()
distributed() == other.distributed()
numRows() == other.dim();
Parameters
[in]otherThe Vector to multiply with this.
[out]resultThe product Vector.

◆ transposeMult() [7/8]

void CAROM::Matrix::transposeMult ( const Vector other,
Vector *&  result 
) const

Multiplies the transpose of this Matrix with other and fills result with the answer.

Supports multiplication of an undistributed Matrix and an undistributed Vector or a distributed Matrix and a distributed Vector resulting in an undistributed Vector. If result has not been allocated it will be, otherwise it will be sized accordingly.

Precondition
result == 0 || !result->distributed()
distributed() == other.distributed()
numRows() == other.dim();
Parameters
[in]otherThe Vector to multiply with this.
[out]resultThe product Vector.

◆ transposeMult() [8/8]

Vector* CAROM::Matrix::transposeMult ( const Vector other) const
inline

Multiplies the transpose of this Matrix with other and returns the product, pointer version.

Supports multiplication of an undistributed Matrix and an undistributed Vector or a distributed Matrix and a distributed Vector returning an undistributed Vector.

Precondition
other != 0
distributed() == other->distributed()
numRows() == other->dim();
Parameters
[in]otherThe Vector to multiply with this.
Returns
The product Vector.

◆ transposePseudoinverse()

void CAROM::Matrix::transposePseudoinverse ( )

Computes the transposePseudoinverse of this.

Precondition
!distributed()
numRows() >= numColumns()

Assumes this is full column rank; may fail if this is not full column rank.

◆ write()

void CAROM::Matrix::write ( const std::string &  base_file_name) const

write Matrix into (a) HDF file(s).

Parameters
[in]base_file_nameThe base part of the file name.

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