Cantera
2.3.0
|
A class for 2D arrays stored in column-major (Fortran-compatible) form. More...
#include <Array.h>
Public Types | |
typedef vector_fp::iterator | iterator |
Type definition for the iterator class that is can be used by Array2D types. More... | |
typedef vector_fp::const_iterator | const_iterator |
Type definition for the const_iterator class that is can be used by Array2D types. More... | |
Public Member Functions | |
Array2D () | |
Default constructor. More... | |
Array2D (const size_t m, const size_t n, const doublereal v=0.0) | |
Constructor. More... | |
Array2D (const size_t m, const size_t n, const doublereal *values) | |
Constructor. More... | |
Array2D (const Array2D &y) | |
Array2D & | operator= (const Array2D &y) |
void | resize (size_t n, size_t m, doublereal v=0.0) |
Resize the array, and fill the new entries with 'v'. More... | |
void | appendColumn (const vector_fp &c) |
Append a column to the existing matrix using a std vector. More... | |
void | appendColumn (const doublereal *const c) |
Append a column to the existing matrix. More... | |
void | setRow (size_t n, const doublereal *const rw) |
Set the nth row to array rw. More... | |
void | getRow (size_t n, doublereal *const rw) |
Get the nth row and return it in a vector. More... | |
void | setColumn (size_t m, doublereal *const col) |
Set the values in column m to those in array col. More... | |
void | getColumn (size_t m, doublereal *const col) |
Get the values in column m. More... | |
void | axpy (doublereal a, const Array2D &x, const Array2D &y) |
Evaluate z = a*x + y. More... | |
void | zero () |
Set all of the entries to zero. More... | |
doublereal & | operator() (size_t i, size_t j) |
Allows setting elements using the syntax A(i,j) = x. More... | |
doublereal | operator() (size_t i, size_t j) const |
Allows retrieving elements using the syntax x = A(i,j). More... | |
doublereal & | value (size_t i, size_t j) |
Returns a changeable reference to position in the matrix. More... | |
doublereal | value (size_t i, size_t j) const |
Returns the value of a single matrix entry. More... | |
size_t | nRows () const |
Number of rows. More... | |
size_t | nColumns () const |
Number of columns. More... | |
iterator | begin () |
Return an iterator pointing to the first element. More... | |
iterator | end () |
Return an iterator pointing past the last element. More... | |
const_iterator | begin () const |
Return a const iterator pointing to the first element. More... | |
const_iterator | end () const |
Return a const iterator pointing to past the last element. More... | |
vector_fp & | data () |
Return a reference to the data vector. More... | |
const vector_fp & | data () const |
Return a const reference to the data vector. More... | |
doublereal * | ptrColumn (size_t j) |
Return a pointer to the top of column j, columns are contiguous in memory. More... | |
const doublereal * | ptrColumn (size_t j) const |
Return a const pointer to the top of column j, columns are contiguous in memory. More... | |
Protected Attributes | |
vector_fp | m_data |
Data stored in a single array. More... | |
size_t | m_nrows |
Number of rows. More... | |
size_t | m_ncols |
Number of columns. More... | |
A class for 2D arrays stored in column-major (Fortran-compatible) form.
In this form, the data entry for an n row, m col matrix is
index = i + (n-1) * j
where
J(i,j) = data_start + index i = row j = column
typedef vector_fp::iterator iterator |
typedef vector_fp::const_iterator const_iterator |
|
inline |
|
inline |
Constructor.
Create an m
by n
array, and initialize all elements to v
.
m | Number of rows |
n | Number of columns |
v | Default fill value. The default is 0.0 |
Definition at line 65 of file Array.h.
References Array2D::m_data.
|
inline |
Constructor.
Create an m
by n
array, initialized with the contents of the array values
.
m | Number of rows |
n | Number of columns |
values | Initial values of the array. Must be of length m*n, and stored in column-major order. |
Definition at line 80 of file Array.h.
References Array2D::m_data.
|
inline |
Resize the array, and fill the new entries with 'v'.
n | This is the number of rows |
m | This is the number of columns in the new matrix |
v | Default fill value -> defaults to zero. |
Definition at line 112 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.
Referenced by RedlichKwongMFTP::addSpecies(), IonsFromNeutralVPSSTP::initLengths(), MixedSolventElectrolyte::initLengths(), MargulesVPSSTP::initLengths(), RedlichKisterVPSSTP::initLengths(), PhaseCombo_Interaction::initLengths(), LiquidTransport::initLiquid(), DenseMatrix::resize(), StFlow::resize(), VCS_PROB::resizeElements(), RedlichKisterVPSSTP::resizeNumInteractions(), VCS_PROB::resizeSpecies(), and StFlow::setTransport().
|
inline |
|
inline |
|
inline |
Set the nth row to array rw.
n | Index of the row to be changed |
rw | Vector for the row. Must have a length of m_ncols. |
Definition at line 153 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.
|
inline |
Get the nth row and return it in a vector.
n | Index of the row to be returned. |
rw | Return Vector for the operation. Must have a length of m_ncols. |
Definition at line 165 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.
Referenced by StFlow::save().
|
inline |
Set the values in column m to those in array col.
A(i,m) = col(i)
m | Column to set |
col | pointer to a col vector. Vector must have a length of m_nrows. |
Definition at line 178 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
|
inline |
Get the values in column m.
col(i) = A(i,m)
m | Column to set |
col | pointer to a col vector that will be returned |
Definition at line 191 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
Evaluate z = a*x + y.
This function evaluates the AXPY operation, and stores the result in the object's Array2D object. It's assumed that all 3 objects have the same dimensions, but no error checking is done.
a | scalar to multiply x with |
x | First Array2D object to be used |
y | Second Array2D object to be used |
Definition at line 208 of file Array.h.
References Cantera::warn_deprecated().
|
inline |
Set all of the entries to zero.
Definition at line 220 of file Array.h.
References Array2D::m_data.
Referenced by IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN(), and VCS_SOLVE::vcs_prep().
|
inline |
Allows setting elements using the syntax A(i,j) = x.
i | row index |
j | column index. |
Definition at line 230 of file Array.h.
References Array2D::value().
Referenced by SquareMatrix::operator()().
|
inline |
Allows retrieving elements using the syntax x = A(i,j).
i | Index for the row to be retrieved |
j | Index for the column to be retrieved. |
Definition at line 240 of file Array.h.
References Array2D::value().
|
inline |
Returns a changeable reference to position in the matrix.
Returns a reference to the matrix's (i,j) element. This may be used as an L value.
i | The row index |
j | The column index |
Definition at line 253 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
Referenced by SquareMatrix::checkColumns(), SquareMatrix::checkRows(), and Array2D::operator()().
|
inline |
Returns the value of a single matrix entry.
Returns the value of the matrix position (i,j) element.
i | The row index |
j | The column index |
Definition at line 264 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
|
inline |
Number of rows.
Definition at line 269 of file Array.h.
References Array2D::m_nrows.
Referenced by Cantera::getMatrixValues(), DenseMatrix::mult(), Cantera::operator<<(), Cantera::outputExcel(), and Cantera::outputTEC().
|
inline |
Number of columns.
Definition at line 274 of file Array.h.
References Array2D::m_ncols.
Referenced by Cantera::getMatrixValues(), DenseMatrix::mult(), Cantera::operator<<(), Cantera::outputExcel(), Cantera::outputTEC(), and StFlow::save().
|
inline |
Return an iterator pointing to the first element.
Definition at line 279 of file Array.h.
References Array2D::m_data.
Referenced by Cantera::operator*=(), and Cantera::operator+=().
|
inline |
Return an iterator pointing past the last element.
Definition at line 284 of file Array.h.
References Array2D::m_data.
Referenced by Cantera::operator*=(), and Cantera::operator+=().
|
inline |
Return a const iterator pointing to the first element.
Definition at line 289 of file Array.h.
References Array2D::m_data.
|
inline |
Return a const iterator pointing to past the last element.
Definition at line 294 of file Array.h.
References Array2D::m_data.
|
inline |
Return a reference to the data vector.
Definition at line 299 of file Array.h.
References Array2D::m_data.
Referenced by ChemEquil::equilibrate(), SquareMatrix::factor(), and MultiPhaseEquil::MultiPhaseEquil().
|
inline |
Return a const reference to the data vector.
Definition at line 304 of file Array.h.
References Array2D::m_data.
|
inline |
Return a pointer to the top of column j, columns are contiguous in memory.
j | Value of the column |
Definition at line 314 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
Referenced by SquareMatrix::ptrColumn(), DustyGasTransport::updateBinaryDiffCoeffs(), StFlow::updateTransport(), VCS_SOLVE::vcs_Hessian_actCoeff_diag(), and VCS_SOLVE::vcs_line_search().
|
inline |
Return a const pointer to the top of column j, columns are contiguous in memory.
j | Value of the column |
Definition at line 324 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
|
protected |
Data stored in a single array.
Definition at line 330 of file Array.h.
Referenced by Array2D::Array2D(), SquareMatrix::begin(), Array2D::begin(), Array2D::data(), DenseMatrix::DenseMatrix(), Array2D::end(), Array2D::getColumn(), Array2D::getRow(), Array2D::ptrColumn(), DenseMatrix::resize(), Array2D::resize(), Array2D::setColumn(), Array2D::setRow(), Array2D::value(), SquareMatrix::zero(), and Array2D::zero().
|
protected |
Number of rows.
Definition at line 333 of file Array.h.
Referenced by SquareMatrix::checkColumns(), SquareMatrix::checkRows(), DenseMatrix::DenseMatrix(), SquareMatrix::factor(), SquareMatrix::factorQR(), Array2D::getColumn(), Array2D::getRow(), SquareMatrix::nRows(), Array2D::nRows(), SquareMatrix::nRowsAndStruct(), Array2D::ptrColumn(), SquareMatrix::rcond(), SquareMatrix::rcondQR(), DenseMatrix::resize(), Array2D::resize(), Array2D::setColumn(), Array2D::setRow(), and Array2D::value().
|
protected |
Number of columns.
Definition at line 336 of file Array.h.
Referenced by Array2D::getRow(), Array2D::nColumns(), DenseMatrix::resize(), Array2D::resize(), and Array2D::setRow().