Cantera 2.6.0

Public Types | Public Member Functions | Protected Attributes | List of all members
Array2D Class Reference

A class for 2D arrays stored in column-major (Fortran-compatible) form. More...

`#include <Array.h>`

Inheritance diagram for Array2D:
[legend]

## 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 double v=0.0)
| Constructor. More...
| Array2D (const size_t m, const size_t n, const double *values)
| Constructor. More...
| Array2D (const Array2D &y)
Array2D & | operator= (const Array2D &y)
void | resize (size_t n, size_t m, double 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 double *const c)
| Append a column to the existing matrix. More...
void | setRow (size_t n, const double *const rw)
| Set the nth row to array rw. More...
void | getRow (size_t n, double *const rw)
| Get the nth row and return it in a vector. More...
void | setColumn (size_t m, double *const col)
| Set the values in column m to those in array col. More...
void | getColumn (size_t m, double *const col)
| Get the values in column m. 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...

## Detailed Description

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 29 of file Array.h.

## Member Typedef Documentation

## ◆ iterator

typedef vector_fp::iterator iterator

Type definition for the iterator class that is can be used by Array2D types.

This is just equal to vector_fp::iterator.

Definition at line 37 of file Array.h.

## ◆ const_iterator

typedef vector_fp::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_fp::const_iterator.

Definition at line 44 of file Array.h.

## Constructor & Destructor Documentation

## ◆ Array2D() [1/4]

Array2D | ( |  | ) |

Default constructor.

Create an empty array.

Definition at line 14 of file Array.cpp.

## ◆ Array2D() [2/4]

Array2D | ( | const size_t | m,
|  | const size_t | n,
|  | const double | v = `0.0`
| ) |  |

Constructor.

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

Parameters

  m | Number of rows
  n | Number of columns
  v | Default fill value. The default is 0.0

Definition at line 20 of file Array.cpp.

References Array2D::m_data.

## ◆ Array2D() [3/4]

Array2D | ( | const size_t | m,
|  | const size_t | n,
|  | const double * | values
| ) |  |

Constructor.

Create an `m` by `n` array, initialized with the contents of the array `values`.

Parameters

  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 27 of file Array.cpp.

References Array2D::m_data.

## ◆ Array2D() [4/4]

Array2D | ( | const Array2D & | y | ) |

Definition at line 34 of file Array.cpp.

## ◆ ~Array2D()

virtual ~Array2D | ( |  | ) |
| inline virtual

Definition at line 75 of file Array.h.

## Member Function Documentation

## ◆ operator=()

Array2D & operator= | ( | const Array2D & | y | ) |

Definition at line 41 of file Array.cpp.

## ◆ resize()

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

Resize the array, and fill the new entries with 'v'.

Parameters

  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 52 of file Array.cpp.

References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.

Referenced by RedlichKisterVPSSTP::addBinaryInteraction(), VCS_SOLVE::addElement(), GibbsExcessVPSSTP::addSpecies(), PengRobinson::addSpecies(), RedlichKwongMFTP::addSpecies(), MargulesVPSSTP::initLengths(), RedlichKisterVPSSTP::initLengths(), StFlow::resize(), DenseMatrix::resize(), StFlow::setTransport(), StFlow::StFlow(), and VCS_SOLVE::VCS_SOLVE().

## ◆ appendColumn() [1/2]

void appendColumn | ( | const vector_fp & | c | ) |

Append a column to the existing matrix using a std vector.

This operation will add a column onto the existing matrix.

Parameters

  c | This vector is the entries in the column to be added. It must have a length equal to m_nrows or greater.

Definition at line 59 of file Array.cpp.

References Array2D::m_data, Array2D::m_ncols, Array2D::m_nrows, and Array2D::value().

## ◆ appendColumn() [2/2]

void appendColumn | ( | const double *const | c | ) |

Append a column to the existing matrix.

This operation will add a column onto the existing matrix.

Parameters

  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 68 of file Array.cpp.

References Array2D::m_data, Array2D::m_ncols, Array2D::m_nrows, and Array2D::value().

## ◆ setRow()

void setRow | ( | size_t | n,
|  | const double *const | rw
| ) |  |

Set the nth row to array rw.

Parameters

  n | Index of the row to be changed
  rw | Vector for the row. Must have a length of m_ncols.

Definition at line 77 of file Array.cpp.

References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.

## ◆ getRow()

void getRow | ( | size_t | n,
|  | double *const | rw
| ) |  |

Get the nth row and return it in a vector.

Parameters

  n | Index of the row to be returned.
  rw | Return Vector for the operation. Must have a length of m_ncols.

Definition at line 84 of file Array.cpp.

References Array2D::m_data, Array2D::m_ncols, and Array2D::m_nrows.

Referenced by StFlow::save(), and RedlichKwongMFTP::setSpeciesCoeffs().

## ◆ setColumn()

void setColumn | ( | size_t | m,
|  | double *const | col
| ) |  |

Set the values in column m to those in array col.

A(i,m) = col(i)

Parameters

  m | Column to set
  col | pointer to a col vector. Vector must have a length of m_nrows.

Definition at line 91 of file Array.cpp.

References Array2D::m_data, and Array2D::m_nrows.

## ◆ getColumn()

void getColumn | ( | size_t | m,
|  | double *const | col
| ) |  |

Get the values in column m.

col(i) = A(i,m)

Parameters

  m | Column to set
  col | pointer to a col vector that will be returned

Definition at line 98 of file Array.cpp.

References Array2D::m_data, and Array2D::m_nrows.

## ◆ zero()

void zero | ( |  | ) |
| inline

Set all of the entries to zero.

Definition at line 139 of file Array.h.

References Array2D::m_data.

Referenced by IonsFromNeutralVPSSTP::s_update_dlnActCoeff_dlnN(), and VCS_SOLVE::vcs_basopt().

## ◆ operator()() [1/2]

doublereal & operator() | ( | size_t | i,
|  | size_t | j
| ) |  |
| inline

Allows setting elements using the syntax A(i,j) = x.

Parameters

  i | row index
  j | column index.

Returns
  a reference to A(i,j) which may be assigned.

Definition at line 149 of file Array.h.

References Array2D::value().

## ◆ operator()() [2/2]

doublereal operator() | ( | size_t | i,
|  | size_t | j
| ) |  | const
| inline

Allows retrieving elements using the syntax x = A(i,j).

Parameters

  i | Index for the row to be retrieved
  j | Index for the column to be retrieved.

Returns
  the value of the matrix entry

Definition at line 159 of file Array.h.

References Array2D::value().

## ◆ value() [1/2]

doublereal & value | ( | size_t | i,
|  | size_t | j
| ) |  |
| 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.

Parameters

  i | The row index
  j | The column index

Returns
  a changeable reference to the matrix entry

Definition at line 172 of file Array.h.

References Array2D::m_data, and Array2D::m_nrows.

Referenced by Array2D::appendColumn(), DenseMatrix::leftMult(), and Array2D::operator()().

## ◆ value() [2/2]

doublereal value | ( | size_t | i,
|  | size_t | j
| ) |  | const
| inline

Returns the value of a single matrix entry.

Returns the value of the matrix position (i,j) element.

Parameters

  i | The row index
  j | The column index

Definition at line 183 of file Array.h.

References Array2D::m_data, and Array2D::m_nrows.

## ◆ nRows()

size_t nRows | ( |  | ) | const
| inline

Number of rows.

Definition at line 188 of file Array.h.

References Array2D::m_nrows.

Referenced by Cantera::getMatrixValues(), ChebyshevRate::getParameters(), DenseMatrix::leftMult(), DenseMatrix::mult(), ChebyshevRate::nTemperature(), Cantera::operator<<(), Cantera::outputExcel(), Cantera::outputTEC(), ChebyshevRate::setData(), ChebyshevRate::update_C(), and ChebyshevRate::updateRC().

## ◆ nColumns()

size_t nColumns | ( |  | ) | const
| inline

Number of columns.

Definition at line 193 of file Array.h.

References Array2D::m_ncols.

Referenced by Cantera::getMatrixValues(), ChebyshevRate::getParameters(), DenseMatrix::leftMult(), DenseMatrix::mult(), ChebyshevRate::nPressure(), Cantera::operator<<(), Cantera::outputExcel(), Cantera::outputTEC(), StFlow::save(), ChebyshevRate::setData(), ChebyshevRate::update_C(), and VCS_SOLVE::vcs_popPhaseRxnStepSizes().

## ◆ begin() [1/2]

iterator begin | ( |  | ) |
| inline

Return an iterator pointing to the first element.

Definition at line 198 of file Array.h.

References Array2D::m_data.

Referenced by Cantera::operator*=().

## ◆ end() [1/2]

iterator end | ( |  | ) |
| inline

Return an iterator pointing past the last element.

Definition at line 203 of file Array.h.

References Array2D::m_data.

Referenced by Cantera::operator*=().

## ◆ begin() [2/2]

const_iterator begin | ( |  | ) | const
| inline

Return a const iterator pointing to the first element.

Definition at line 208 of file Array.h.

References Array2D::m_data.

## ◆ end() [2/2]

const_iterator end | ( |  | ) | const
| inline

Return a const iterator pointing to past the last element.

Definition at line 213 of file Array.h.

References Array2D::m_data.

## ◆ data() [1/2]

vector_fp & data | ( |  | ) |
| inline

Return a reference to the data vector.

Definition at line 218 of file Array.h.

References Array2D::m_data.

Referenced by Cantera::BasisOptimize(), ChemEquil::equilibrate(), ChemEquil::estimateElementPotentials(), ChebyshevRate::getParameters(), RedlichKwongMFTP::initThermoXML(), MultiPhaseEquil::MultiPhaseEquil(), and ChebyshevRate::validate().

## ◆ data() [2/2]

const vector_fp & data | ( |  | ) | const
| inline

Return a const reference to the data vector.

Definition at line 223 of file Array.h.

References Array2D::m_data.

## ◆ ptrColumn() [1/2]

doublereal * ptrColumn | ( | size_t | j | ) |
| inline

Return a pointer to the top of column j, columns are contiguous in memory.

Parameters

  j | Value of the column

Returns
  a pointer to the top of the column

Definition at line 233 of file Array.h.

References Array2D::m_data, and Array2D::m_nrows.

Referenced by VCS_SOLVE::delta_species(), DustyGasTransport::updateBinaryDiffCoeffs(), StFlow::updateTransport(), VCS_SOLVE::vcs_basopt(), VCS_SOLVE::vcs_deltag(), VCS_SOLVE::vcs_Hessian_actCoeff_diag(), and VCS_SOLVE::vcs_setMolesLinProg().

## ◆ ptrColumn() [2/2]

const doublereal * ptrColumn | ( | size_t | j | ) | const
| inline

Return a const pointer to the top of column j, columns are contiguous in memory.

Parameters

  j | Value of the column

Returns
  a const pointer to the top of the column

Definition at line 243 of file Array.h.

References Array2D::m_data, and Array2D::m_nrows.

## Member Data Documentation

## ◆ m_data

vector_fp m_data
| protected

Data stored in a single array.

Definition at line 249 of file Array.h.

Referenced by Array2D::appendColumn(), Array2D::Array2D(), Array2D::begin(), Array2D::data(), DenseMatrix::DenseMatrix(), Array2D::end(), Array2D::getColumn(), Array2D::getRow(), Array2D::ptrColumn(), Array2D::resize(), DenseMatrix::resize(), Array2D::setColumn(), Array2D::setRow(), Array2D::value(), and Array2D::zero().

## ◆ m_nrows

size_t m_nrows
| protected

Number of rows.

Definition at line 252 of file Array.h.

Referenced by Array2D::appendColumn(), DenseMatrix::DenseMatrix(), Array2D::getColumn(), Array2D::getRow(), Array2D::nRows(), Array2D::ptrColumn(), Array2D::resize(), DenseMatrix::resize(), Array2D::setColumn(), Array2D::setRow(), and Array2D::value().

## ◆ m_ncols

size_t m_ncols
| protected

Number of columns.

Definition at line 255 of file Array.h.

Referenced by Array2D::appendColumn(), Array2D::getRow(), Array2D::nColumns(), Array2D::resize(), DenseMatrix::resize(), and Array2D::setRow().

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

- Array.h
- Array.cpp