Cantera  2.1.2
vcs_DoubleStarStar.h
Go to the documentation of this file.
1 /**
2  * @file vcs_DoubleStarStar.h
3  *
4  * Header file for class DoubleStarStar
5  */
6 #ifndef VCS_DOUBLESTARSTAR_H
7 #define VCS_DOUBLESTARSTAR_H
8 
9 #include <vector>
10 
11 namespace VCSnonideal
12 {
13 
14 using std::size_t;
15 
16 //! A class for 2D double arrays stored in column-major
17 //! (Fortran-compatible) form.
18 /*!
19  * In this form, the data entry for an `n` row, `m` colum matrix is index =
20  * `i + (n-1) * j` where `Matrix[j][i]` references the element in row `i`,
21  * column `j`.
22  *
23  * The way this is instantiated is via the constructor,
24  * DoubleStarStar Dmatrix(mcol, mrow)`.
25  *
26  * The way this is referenced is via the notation: `Dmatrix[icol][irow]`.
27  */
29 {
30 public:
31 
32  //! Default constructor. Create an empty array.
34 
35  //! Constructor.
36  /*!
37  * Create an `nrow` by `mcol` double array, and initialize all elements
38  * to `v`.
39  *
40  * @param mcol Number of columns
41  * @param nrow Number of rows
42  * @param v value used to initialize elements
43  */
44  DoubleStarStar(size_t mcol, size_t nrow, double v = 0.0);
45 
47  DoubleStarStar& operator=(const DoubleStarStar& y);
48 
49  //! Resize the array, and fill the new entries with `v`
50  /*!
51  * @param mcol This is the number of columns in the new matrix
52  * @param nrow This is the number of rows
53  * @param v Default fill value -> defaults to zero.
54  */
55  void resize(size_t mcol, size_t nrow, double v = 0.0);
56 
57  //! Pointer to the top of the column
58  /*!
59  * @param jcol This is the jth column
60  *
61  * @return returns the pointer to the top of the jth column
62  */
63  double* operator[](size_t jcol);
64 
65  //! Returns a const Pointer to the top of the jth column
66  /*!
67  * @param jcol This is the jth column
68  *
69  * @return returns the pointer to the top of the jth column
70  */
71  const double* operator[](size_t jcol) const;
72 
73  //! Returns a `double**` pointer to the base address
74  /*!
75  * This is the second way to get to the data. This returns a `double**`
76  * which can later be used in `Dmatrix[icol][irow]` notation to get to
77  * the data.
78  */
79  double* const* baseDataAddr();
80 
81  //! Returns a `const double**` pointer to the base address
82  /*!
83  * This is the second way to get to the data This returns a double **
84  * which can later be used in `Dmatrix[icol][irow]` notation to get to
85  * the data.
86  */
87  double const* const* constBaseDataAddr() const;
88 
89  //! Number of rows
90  size_t nRows() const;
91 
92  //! Number of columns
93  size_t nColumns() const;
94 
95 private:
96  //! Storage area
97  std::vector<double> m_data;
98 
99  //! Vector of addresses for the top of the columns
100  /*!
101  * Length = mcol
102  */
103  std::vector<double*> m_colAddr;
104 
105  //! number of rows
106  size_t m_nrows;
107 
108  //! number of columns
109  size_t m_ncols;
110 };
111 
112 }
113 
114 #endif
DoubleStarStar()
Default constructor. Create an empty array.
size_t nColumns() const
Number of columns.
double *const * baseDataAddr()
Returns a double** pointer to the base address.
void resize(size_t mcol, size_t nrow, double v=0.0)
Resize the array, and fill the new entries with v
std::vector< double * > m_colAddr
Vector of addresses for the top of the columns.
double * operator[](size_t jcol)
Pointer to the top of the column.
size_t m_ncols
number of columns
double const *const * constBaseDataAddr() const
Returns a const double** pointer to the base address.
size_t m_nrows
number of rows
size_t nRows() const
Number of rows.
A class for 2D double arrays stored in column-major (Fortran-compatible) form.
std::vector< double > m_data
Storage area.