![]() |
Cantera
3.0.0
|
A class for 2D arrays stored in column-major (Fortran-compatible) form. More...
#include <Array.h>
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
Public Types | |
typedef vector< double >::iterator | iterator |
Type definition for the iterator class that is can be used by Array2D types. | |
typedef vector< double >::const_iterator | const_iterator |
Type definition for the const_iterator class that is can be used by Array2D types. | |
Public Member Functions | |
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, const double *values) | |
Constructor. | |
Array2D (const Array2D &y) | |
Array2D & | operator= (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 (const vector< double > &c) |
Append a column to the existing matrix using a std vector. | |
void | appendColumn (const double *const c) |
Append a column to the existing matrix. | |
void | setRow (size_t n, const double *const rw) |
Set the nth row to array rw. | |
void | getRow (size_t n, double *const rw) |
Get the nth row and return it in a vector. | |
void | setColumn (size_t m, double *const col) |
Set the values in column m to those in array col. | |
void | getColumn (size_t m, double *const col) |
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. | |
iterator | begin () |
Return an iterator pointing to the first element. | |
iterator | end () |
Return an iterator pointing past the last element. | |
const_iterator | begin () const |
Return a const iterator pointing to the first element. | |
const_iterator | end () const |
Return a const iterator pointing to past the last element. | |
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) |
double * | ptrColumn (size_t j) |
Return a pointer to the top of column j, columns are contiguous in memory. | |
const double * | ptrColumn (size_t j) const |
Return a const pointer to the top of column j, columns are contiguous in memory. | |
Protected Attributes | |
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. | |
typedef vector<double>::iterator iterator |
Type definition for the iterator class that is can be used by Array2D types.
This is just equal to vector<double>::iterator.
typedef vector<double>::const_iterator const_iterator |
Type definition for the const_iterator class that is can be used by Array2D types.
This is just equal to vector<double>::const_iterator.
|
default |
Default constructor.
Create an empty array.
Array2D | ( | const size_t | m, |
const size_t | n, | ||
const double | v = 0.0 |
||
) |
Array2D | ( | const size_t | m, |
const size_t | n, | ||
const double * | values | ||
) |
|
virtual |
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. |
Reimplemented in DenseMatrix.
void appendColumn | ( | const vector< double > & | c | ) |
void appendColumn | ( | const double *const | c | ) |
void setRow | ( | size_t | n, |
const double *const | rw | ||
) |
void getRow | ( | size_t | n, |
double *const | rw | ||
) |
void setColumn | ( | size_t | m, |
double *const | col | ||
) |
void getColumn | ( | size_t | m, |
double *const | col | ||
) |
|
inline |
|
inline |
|
inline |
|
inline |
Array2D::iterator begin | ( | ) |
Return an iterator pointing to the first element.
Array2D::iterator end | ( | ) |
Return an iterator pointing past the last element.
Array2D::const_iterator begin | ( | ) | const |
Return a const iterator pointing to the first element.
Array2D::const_iterator end | ( | ) | const |
Return a const iterator pointing to past the last element.
|
inline |
|
inline |
|
inline |
|
inline |
|
protected |