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