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. | |
typedef vector_fp::const_iterator | const_iterator |
Type definition for the const_iterator class that is can be used by Array2D types. | |
Public Member Functions | |
Array2D () | |
Default constructor. | |
Array2D (const int m, const int n, const doublereal v=0.0) | |
Constructor. | |
Array2D (const Array2D &y) | |
Copy constructor. | |
Array2D & | operator= (const Array2D &y) |
assignment operator | |
void | resize (int n, int m, doublereal v=0.0) |
Resize the array, and fill the new entries with 'v'. | |
void | appendColumn (const vector_fp &c) |
Append a column to the existing matrix using a std vector. | |
void | appendColumn (const doublereal *const c) |
Append a column to the existing matrix. | |
void | setRow (int n, const doublereal *const rw) |
Set the nth row to array rw. | |
void | getRow (int n, doublereal *const rw) |
Get the nth row and return it in a vector. | |
void | setColumn (int m, doublereal *const col) |
Set the values in column m to those in array col. | |
void | getColumn (int m, doublereal *const col) |
Get the values in column m. | |
virtual | ~Array2D () |
Destructor. | |
void | axpy (doublereal a, const Array2D &x, const Array2D &y) |
Evaluate z = a*x + y. | |
doublereal & | operator() (int i, int j) |
Allows setting elements using the syntax A(i,j) = x. | |
doublereal | operator() (int i, int j) const |
Allows retrieving elements using the syntax x = A(i,j). | |
doublereal & | value (int i, int j) |
Returns a changeable reference to position in the matrix. | |
doublereal | value (int i, int 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_fp & | data () |
Return a reference to the data vector. | |
const vector_fp & | data () const |
Return a const reference to the data vector. | |
doublereal * | ptrColumn (int j) |
Return a pointer to the top of column j, columns are contiguous in memory. | |
const doublereal * | ptrColumn (int j) const |
Return a const pointer to the top of column j, columns are contiguous in memory. | |
Protected Attributes | |
vector_fp | m_data |
Data storred in a single array. | |
int | m_nrows |
Number of rows. | |
int | m_ncols |
Number of columns. |
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
Definition at line 36 of file Array.h.
typedef vector_fp::const_iterator const_iterator |
typedef vector_fp::iterator iterator |
Array2D | ( | ) | [inline] |
Array2D | ( | const int | m, | |
const int | n, | |||
const doublereal | v = 0.0 | |||
) | [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 56 of file Array.h.
References Array2D::m_data.
Copy constructor.
y | Array2D to make the copy from |
Definition at line 66 of file Array.h.
References Array2D::m_data.
virtual ~Array2D | ( | ) | [inline, virtual] |
Destructor.
Does nothing, since no memory allocated on the heap.
Definition at line 182 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
void appendColumn | ( | const doublereal *const | c | ) | [inline] |
Append a column to the existing matrix.
This operation will add a column onto the existing matrix.
c | This vector of doubles is the entries in the column to be added. It must have a length equal to m_nrows or greater. |
Definition at line 121 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, Array2D::m_nrows, and Array2D::value().
void appendColumn | ( | const vector_fp & | c | ) | [inline] |
Append a column to the existing matrix using a std vector.
This operation will add a column onto the existing matrix.
c | This vector<doublereal> is the entries in the column to be added. It must have a length equal to m_nrows or greater. |
Definition at line 106 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, 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.
const_iterator begin | ( | ) | const [inline] |
iterator begin | ( | ) | [inline] |
Return an iterator pointing to the first element.
Definition at line 258 of file Array.h.
Referenced by Array2D::operator()(), Cantera::operator*=(), and Cantera::operator+=().
const vector_fp& data | ( | ) | const [inline] |
Return a const reference to the data vector.
Definition at line 273 of file Array.h.
References Array2D::m_data.
vector_fp& data | ( | ) | [inline] |
Return a reference to the data vector.
Definition at line 270 of file Array.h.
References Array2D::m_ncols.
const_iterator end | ( | ) | const [inline] |
Return a const iterator pointing to past the last element.
Definition at line 267 of file Array.h.
References Array2D::m_nrows.
iterator end | ( | ) | [inline] |
Return an iterator pointing past the last element.
Definition at line 261 of file Array.h.
Referenced by Array2D::operator()(), Cantera::operator*=(), and Cantera::operator+=().
void getColumn | ( | int | m, | |
doublereal *const | col | |||
) | [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 172 of file Array.h.
References Array2D::m_data, and Array2D::m_nrows.
void getRow | ( | int | n, | |
doublereal *const | rw | |||
) | [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 145 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.
size_t nColumns | ( | ) | const [inline] |
size_t nRows | ( | ) | const [inline] |
doublereal operator() | ( | int | i, | |
int | j | |||
) | const [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 221 of file Array.h.
References Array2D::value().
doublereal& operator() | ( | int | i, | |
int | j | |||
) | [inline] |
Allows setting elements using the syntax A(i,j) = x.
i | row index | |
j | column index. |
Definition at line 211 of file Array.h.
References Array2D::begin(), and Array2D::end().
assignment operator
y | Array2D to get the values from |
Definition at line 77 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.
const doublereal* ptrColumn | ( | int | j | ) | const [inline] |
doublereal* ptrColumn | ( | int | j | ) | [inline] |
Return a pointer to the top of column j, columns are contiguous in memory.
j | Value of the column |
Definition at line 282 of file Array.h.
References Array2D::m_data.
Referenced by HMWSoln::s_updatePitzer_CoeffWRTemp().
void resize | ( | int | n, | |
int | m, | |||
doublereal | v = 0.0 | |||
) | [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 92 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.
Referenced by HMWSoln::initLengths(), DebyeHuckel::initLengths(), and HMWSoln::readXMLLambdaNeutral().
void setColumn | ( | int | m, | |
doublereal *const | col | |||
) | [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 159 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.
void setRow | ( | int | n, | |
const doublereal *const | rw | |||
) | [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 133 of file Array.h.
References Array2D::m_data, Array2D::m_ncols, Array2D::m_nrows, and Array2D::value().
doublereal value | ( | int | i, | |
int | j | |||
) | const [inline] |
doublereal& value | ( | int | i, | |
int | j | |||
) | [inline] |
Returns a changeable reference to position in the matrix.
This is a key entry. Returns a reference to the matrixes (i,j) element. This may be used as an L value.
i | The row index | |
j | The column index |
Definition at line 235 of file Array.h.
Referenced by Array2D::appendColumn(), Array2D::operator()(), DebyeHuckel::s_update_lnMolalityActCoeff(), and Array2D::setRow().
vector_fp m_data [protected] |
Data storred in a single array.
Definition at line 298 of file Array.h.
Referenced by Array2D::appendColumn(), Array2D::Array2D(), Array2D::data(), Array2D::getColumn(), Array2D::getRow(), Array2D::operator=(), Array2D::ptrColumn(), Array2D::resize(), Array2D::setColumn(), Array2D::setRow(), and Array2D::~Array2D().
int m_ncols [protected] |
Number of columns.
Definition at line 304 of file Array.h.
Referenced by Array2D::appendColumn(), Array2D::data(), Array2D::getRow(), Array2D::operator=(), Array2D::resize(), Array2D::setColumn(), and Array2D::setRow().
int m_nrows [protected] |
Number of rows.
Definition at line 301 of file Array.h.
Referenced by Array2D::appendColumn(), Array2D::end(), Array2D::getColumn(), Array2D::getRow(), Array2D::operator=(), Array2D::resize(), Array2D::setColumn(), Array2D::setRow(), and Array2D::~Array2D().