Cantera  2.0
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 col
20  * matrix is
21  * index = i + (n-1) * j
22  * where
23  * Matrix[j][i]
24  * i = row
25  * j = column
26  * The way this is instantiated is via the constructor:
27  * DoubleStarStar Dmatrix(mcol, mrow);
28  *
29  * The way this is referenced is via the notation:
30  * Dmatrix[icol][irow]
31  */
33 {
34 
35 public:
36 
37  //! Default constructor. Create an empty array.
39 
40  //! Constructor.
41  /*!
42  * Create an \c nrow by \c mcol double array, and initialize
43  * all elements to \c v.
44  *
45  * @param mcol Number of columns
46  * @param nrow Number of rows
47  */
48  DoubleStarStar(size_t mcol, size_t nrow, double v = 0.0);
49 
50  //! copy constructor
51  /*!
52  * @param y object to be copied
53  */
55 
56  /// assignment operator
57  /*!
58  * @param y object to be copied
59  */
61 
62  //! Resize the array, and fill the new entries with 'v'
63  /*!
64  * @param mrow This is the number of columns in the new matrix
65  * @param ncol This is the number of rows
66  * @param v Default fill value -> defaults to zero.
67  */
68  void resize(size_t mcol, size_t nrow, double v = 0.0);
69 
70  //! Pointer to the top of the column
71  /*!
72  * @param jcol This is the jth column
73  *
74  * @return returns the pointer to the top of the jth column
75  */
76  double* operator[](size_t jcol);
77 
78  //! Returns a const Pointer to the top of the jth column
79  /*!
80  * @param jcol This is the jth column
81  *
82  * @return returns the pointer to the top of the jth column
83  */
84  const double* operator[](size_t jcol) const;
85 
86  //! Returns a double ** pointer to the base address
87  /*!
88  * This is the second way to get to the data
89  * This returns a double ** which can later be used in
90  * Dmatrix[icol][irow] notation to get to the data
91  */
92  double* const* baseDataAddr();
93 
94  //! Returns a const double ** pointer to the base address
95  /*!
96  * This is the second way to get to the data
97  * This returns a double ** which can later be used in
98  * Dmatrix[icol][irow] notation to get to the data
99  */
100  double const* const* constBaseDataAddr() const;
101 
102  //! Number of rows
103  size_t nRows() const;
104 
105  //! Number of columns
106  size_t nColumns() const;
107 
108 private:
109  //! Storage area
110  std::vector<double> m_data;
111 
112  //! Vector of addresses for the top of the columns
113  /*!
114  * Length = mcol
115  */
116  std::vector<double*> m_colAddr;
117 
118  //! number of rows
119  size_t m_nrows;
120 
121  //! number of columns
122  size_t m_ncols;
123 };
124 
125 }
126 
127 #endif
128 
129