From 82e194a2b00298daf231798db0abb572eeba327c Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sun, 31 Jul 2011 18:58:19 +0000 Subject: [PATCH] Added column pointers as a member to this object. This is needed for linking in sundance more closely. --- Cantera/src/numerics/DenseMatrix.cpp | 24 ++++++++++++++++++++++++ Cantera/src/numerics/DenseMatrix.h | 25 ++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/Cantera/src/numerics/DenseMatrix.cpp b/Cantera/src/numerics/DenseMatrix.cpp index 89f6d7519..c56f242fb 100644 --- a/Cantera/src/numerics/DenseMatrix.cpp +++ b/Cantera/src/numerics/DenseMatrix.cpp @@ -38,6 +38,10 @@ namespace Cantera { m_printLevel(0) { m_ipiv.resize(max(n, m)); + m_colPts.resize(m); + for (int j = 0; j < m; j++) { + m_colPts[j] = &(m_data[m_nrows*j]); + } } //==================================================================================================================== // Copy constructor @@ -51,6 +55,10 @@ namespace Cantera { m_printLevel(0) { m_ipiv = y.ipiv(); + m_colPts.resize(m_ncols); + for (int j = 0; j < m_ncols; j++) { + m_colPts[j] = &(m_data[m_nrows*j]); + } } //==================================================================================================================== // assignment @@ -58,6 +66,10 @@ namespace Cantera { if (&y == this) return *this; Array2D::operator=(y); m_ipiv = y.ipiv(); + m_colPts.resize(m_ncols); + for (int j = 0; j < m_ncols; j++) { + m_colPts[j] = &(m_data[m_nrows*j]); + } m_useReturnErrorCode = y.m_useReturnErrorCode; m_printLevel = y.m_printLevel; return *this; @@ -71,6 +83,18 @@ namespace Cantera { void DenseMatrix::resize(int n, int m, doublereal v) { Array2D::resize(n,m,v); m_ipiv.resize( max(n,m) ); + m_colPts.resize(m_ncols); + for (int j = 0; j < m_ncols; j++) { + m_colPts[j] = &(m_data[m_nrows*j]); + } + } + //==================================================================================================================== + doublereal * const * DenseMatrix::colPts() { + return &(m_colPts[0]); + } + //==================================================================================================================== + const doublereal * const * DenseMatrix::const_colPts() const { + return &(m_colPts[0]); } //==================================================================================================================== void DenseMatrix::mult(const double* b, double* prod) const { diff --git a/Cantera/src/numerics/DenseMatrix.h b/Cantera/src/numerics/DenseMatrix.h index 04aac8f48..f635e17bb 100644 --- a/Cantera/src/numerics/DenseMatrix.h +++ b/Cantera/src/numerics/DenseMatrix.h @@ -113,7 +113,27 @@ namespace Cantera { * @param m New number of columns * @param v Default fill value. defaults to zero. */ - void resize(int n, int m, doublereal v = 0.0); + void resize(int n, int m, doublereal v); + + //! Return a vector of const pointers to the columns + /*! + * Note the value of the pointers are protected by their being const. + * However, the value of the matrix is open to being changed. + * + * @return returns a vector of pointers to the top of the columns + * of the matrices. + */ + doublereal * const * colPts(); + + //! Return a const vector of const pointers to the columns + /*! + * Note, the jacobian can not be altered by this routine, and + * therefore the member function is const. + * + * @return returns a vector of pointers to the top of the columns + * of the matrices. + */ + const doublereal * const * const_colPts() const; //! Multiply A*b and write result to \c prod. /*! @@ -150,6 +170,9 @@ namespace Cantera { //! Vector of pivots. Length is equal to the max of m and n. vector_int m_ipiv; + //! Vector of column pointers + std::vector m_colPts; + public: //! Error Handling Flag