Cantera  4.0.0a1
Loading...
Searching...
No Matches
DenseMatrix Class Reference

A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operations to class Array2D. More...

#include <DenseMatrix.h>

Inheritance diagram for DenseMatrix:
[legend]

Detailed Description

A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operations to class Array2D.

The dense matrix class adds matrix operations onto the Array2D class. These matrix operations are carried out by the appropriate BLAS and LAPACK routines

Definition at line 41 of file DenseMatrix.h.

Public Member Functions

 DenseMatrix ()=default
 Default Constructor.
 
 DenseMatrix (size_t n, size_t m, double v=0.0)
 Constructor.
 
 DenseMatrix (const DenseMatrix &y)
 
DenseMatrixoperator= (const DenseMatrix &y)
 
void resize (size_t n, size_t m, double v=0.0) override
 Resize the matrix.
 
virtual void mult (span< const double > b, span< double > prod) const
 
virtual void mult (const DenseMatrix &b, DenseMatrix &prod) const
 Multiply A*B and write result to prod.
 
virtual void leftMult (span< const double > b, span< double > prod) const
 Left-multiply the matrix by transpose(b), and write the result to prod.
 
vector< int > & ipiv ()
 Return a changeable value of the pivot vector.
 
const vector< int > & ipiv () const
 Return a changeable value of the pivot vector.
 
- Public Member Functions inherited from Array2D
 Array2D ()=default
 Default constructor.
 
 Array2D (const size_t m, const size_t n, const double v=0.0)
 Constructor.
 
 Array2D (const size_t m, const size_t n, span< const double > values)
 Constructor.
 
 Array2D (const Array2D &y)
 
Array2Doperator= (const Array2D &y)
 
virtual void resize (size_t n, size_t m, double v=0.0)
 Resize the array, and fill the new entries with 'v'.
 
void appendColumn (span< const double > c)
 Append a column to the existing matrix using a std vector.
 
void setRow (size_t n, span< const double > rw)
 Set the nth row to array rw.
 
void getRow (size_t n, span< double > rw) const
 Get the nth row and return it in a vector.
 
void setColumn (size_t m, span< const double > col)
 Set the values in column m to those in array col.
 
void getColumn (size_t m, span< double > col) const
 Get the values in column m.
 
void zero ()
 Set all of the entries to zero.
 
double & operator() (size_t i, size_t j)
 Allows setting elements using the syntax A(i,j) = x.
 
double operator() (size_t i, size_t j) const
 Allows retrieving elements using the syntax x = A(i,j).
 
double & value (size_t i, size_t j)
 Returns a changeable reference to position in the matrix.
 
double value (size_t i, size_t j) const
 Returns the value of a single matrix entry.
 
size_t nRows () const
 Number of rows.
 
size_t nColumns () const
 Number of columns.
 
vector< double > & data ()
 Return a reference to the data vector.
 
const vector< double > & data () const
 Return a const reference to the data vector.
 
void operator*= (double a)
 
span< double > col (size_t j)
 Return a writable span over column j.
 
span< const double > col (size_t j) const
 Return a read-only span over column j.
 

Protected Attributes

vector< int > m_ipiv
 Vector of pivots. Length is equal to the max of m and n.
 
- Protected Attributes inherited from Array2D
vector< double > m_data
 Data stored in a single array.
 
size_t m_nrows = 0
 Number of rows.
 
size_t m_ncols = 0
 Number of columns.
 

Constructor & Destructor Documentation

◆ DenseMatrix() [1/3]

DenseMatrix ( )
default

Default Constructor.

◆ DenseMatrix() [2/3]

DenseMatrix ( size_t  n,
size_t  m,
double  v = 0.0 
)

Constructor.

Create an n by m matrix, and initialize all elements to v.

Parameters
nNew number of rows
mNew number of columns
vDefault fill value. defaults to zero.

Definition at line 20 of file DenseMatrix.cpp.

◆ DenseMatrix() [3/3]

DenseMatrix ( const DenseMatrix y)

Definition at line 26 of file DenseMatrix.cpp.

Member Function Documentation

◆ operator=()

DenseMatrix & operator= ( const DenseMatrix y)

Definition at line 32 of file DenseMatrix.cpp.

◆ resize()

void resize ( size_t  n,
size_t  m,
double  v = 0.0 
)
overridevirtual

Resize the matrix.

Resize the matrix to n rows by m cols.

Parameters
nNew number of rows
mNew number of columns
vDefault fill value. defaults to zero.

Reimplemented from Array2D.

Definition at line 42 of file DenseMatrix.cpp.

◆ mult() [1/2]

void mult ( span< const double >  b,
span< double >  prod 
) const
virtual

Definition at line 48 of file DenseMatrix.cpp.

◆ mult() [2/2]

void mult ( const DenseMatrix b,
DenseMatrix prod 
) const
virtual

Multiply A*B and write result to prod.

Take this matrix to be of size NxM.

Parameters
[in]bDenseMatrix B of size MxP
[out]prodDenseMatrix prod size NxP

Definition at line 65 of file DenseMatrix.cpp.

◆ leftMult()

void leftMult ( span< const double >  b,
span< double >  prod 
) const
virtual

Left-multiply the matrix by transpose(b), and write the result to prod.

Parameters
bleft multiply by this vector. The length must be equal to n the number of rows in the matrix.
prodResulting vector. This is of length m, the number of columns in the matrix

Definition at line 83 of file DenseMatrix.cpp.

◆ ipiv() [1/2]

vector< int > & ipiv ( )

Return a changeable value of the pivot vector.

Returns
a reference to the pivot vector as a vector<int>

Definition at line 96 of file DenseMatrix.cpp.

◆ ipiv() [2/2]

const vector< int > & ipiv ( ) const
inline

Return a changeable value of the pivot vector.

Returns
a reference to the pivot vector as a vector<int>

Definition at line 99 of file DenseMatrix.h.

Member Data Documentation

◆ m_ipiv

vector<int> m_ipiv
protected

Vector of pivots. Length is equal to the max of m and n.

Definition at line 105 of file DenseMatrix.h.


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