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