Cleaned up Doxygen Documentation for matrix classes

BandMatrix, DenseMatrix, SquareMatrix, and GeneralMatrix
This commit is contained in:
Ray Speth 2013-05-29 00:11:22 +00:00
parent 7e8276809f
commit e9daef3313
8 changed files with 94 additions and 476 deletions

View file

@ -7,7 +7,6 @@
// Copyright 2001 California Institute of Technology // Copyright 2001 California Institute of Technology
#ifndef CT_BANDMATRIX_H #ifndef CT_BANDMATRIX_H
#define CT_BANDMATRIX_H #define CT_BANDMATRIX_H
@ -86,23 +85,7 @@ public:
*/ */
void bfill(doublereal v = 0.0); void bfill(doublereal v = 0.0);
//! Index into the (i,j) element
/*!
* @param i row
* @param j column
*
* Returns a changeable reference to the matrix entry
*/
doublereal& operator()(size_t i, size_t j); doublereal& operator()(size_t i, size_t j);
//! Constant index into the (i,j) element
/*!
* @param i row
* @param j column
*
* Returns an unchangeable reference to the matrix entry
*/
doublereal operator()(size_t i, size_t j) const; doublereal operator()(size_t i, size_t j) const;
//! Return a changeable reference to element (i,j). //! Return a changeable reference to element (i,j).
@ -117,7 +100,6 @@ public:
*/ */
doublereal& value(size_t i, size_t j); doublereal& value(size_t i, size_t j);
//! Return the value of element (i,j). //! Return the value of element (i,j).
/*! /*!
* This method does not alter the array. * This method does not alter the array.
@ -149,13 +131,10 @@ public:
*/ */
doublereal _value(size_t i, size_t j) const; doublereal _value(size_t i, size_t j) const;
//! Returns the number of rows
virtual size_t nRows() const; virtual size_t nRows() const;
//! Return the size and structure of the matrix //! Return the size and structure of the matrix
/*! /*!
* This is inherited from GeneralMatrix
*
* @param iStruct OUTPUT Pointer to a vector of ints that describe the structure of the matrix. * @param iStruct OUTPUT Pointer to a vector of ints that describe the structure of the matrix.
* istruct[0] = kl * istruct[0] = kl
* istruct[1] = ku * istruct[1] = ku
@ -177,28 +156,13 @@ public:
size_t ldim() const; size_t ldim() const;
//! Return a reference to the pivot vector //! Return a reference to the pivot vector
/*!
* @return return a reference to the pivot vector
*/
vector_int& ipiv(); vector_int& ipiv();
//! Multiply A*b and write result to prod.
/*!
* @param b Vector to do the rh multiplication
* @param prod OUTPUT vector to receive the result
*/
virtual void mult(const doublereal* b, doublereal* prod) const; virtual void mult(const doublereal* b, doublereal* prod) const;
//! Multiply b*A and write result to prod.
/*!
* @param b Vector to do the lh multiplication
* @param prod OUTPUT vector to receive the result
*/
virtual void leftMult(const doublereal* const b, doublereal* const prod) const; virtual void leftMult(const doublereal* const b, doublereal* const prod) const;
//! Perform an LU decomposition, the LAPACK routine DGBTRF is used. //! Perform an LU decomposition, the LAPACK routine DGBTRF is used.
/*! /*!
*
* The factorization is saved in ludata. * The factorization is saved in ludata.
* *
* @return Return a success flag. * @return Return a success flag.
@ -207,7 +171,6 @@ public:
*/ */
int factor(); int factor();
//! Solve the matrix problem Ax = b //! Solve the matrix problem Ax = b
/*! /*!
* @param b INPUT rhs of the problem * @param b INPUT rhs of the problem
@ -230,7 +193,6 @@ public:
*/ */
int solve(doublereal* b); int solve(doublereal* b);
//! Returns an iterator for the start of the band storage data //! Returns an iterator for the start of the band storage data
/*! /*!
* Iterator points to the beginning of the data, and it is changeable. * Iterator points to the beginning of the data, and it is changeable.
@ -255,9 +217,6 @@ public:
*/ */
vector_fp::const_iterator end() const; vector_fp::const_iterator end() const;
/**
* Zero the matrix
*/
virtual void zero(); virtual void zero();
//! Factors the A matrix using the QR algorithm, overwriting A //! Factors the A matrix using the QR algorithm, overwriting A
@ -306,7 +265,6 @@ public:
//! Returns the one norm of the matrix //! Returns the one norm of the matrix
virtual doublereal oneNorm() const; virtual doublereal oneNorm() const;
//! Duplicate this object as a GeneralMatrix pointer
virtual GeneralMatrix* duplMyselfAsGeneralMatrix() const; virtual GeneralMatrix* duplMyselfAsGeneralMatrix() const;
//! Report whether the current matrix has been factored. //! Report whether the current matrix has been factored.
@ -316,11 +274,11 @@ public:
/*! /*!
* The LAPACK bandstructure has column values which are contiguous in memory: * The LAPACK bandstructure has column values which are contiguous in memory:
* *
* On entry, the matrix A in band storage, in rows KL+1 to * On entry, the matrix A in band storage, in rows KL+1 to
* 2*KL+KU+1; rows 1 to KL of the array need not be set. * 2*KL+KU+1; rows 1 to KL of the array need not be set.
* The j-th column of A is stored in the j-th column of the * The j-th column of A is stored in the j-th column of the
* array AB as follows: * array AB as follows:
* AB(KL + KU + 1 + i - j,j) = A(i,j) for max(1, j - KU) <= i <= min(m, j + KL) * AB(KL + KU + 1 + i - j,j) = A(i,j) for max(1, j - KU) <= i <= min(m, j + KL)
* *
* This routine returns the position of AB(1,j) (fortran-1 indexing) in the above format * This routine returns the position of AB(1,j) (fortran-1 indexing) in the above format
* *
@ -329,7 +287,6 @@ public:
* double *colP_j = matrix.ptrColumn(j); * double *colP_j = matrix.ptrColumn(j);
* double a_i_j = colP_j[kl + ku + i - j]; * double a_i_j = colP_j[kl + ku + i - j];
* *
*
* @param j Value of the column * @param j Value of the column
* *
* @return Returns a pointer to the top of the column * @return Returns a pointer to the top of the column
@ -353,7 +310,6 @@ public:
*/ */
virtual void copyData(const GeneralMatrix& y); virtual void copyData(const GeneralMatrix& y);
//! Clear the factored flag //! Clear the factored flag
virtual void clearFactorFlag(); virtual void clearFactorFlag();
@ -421,8 +377,6 @@ private:
* @param msg String containing the message. * @param msg String containing the message.
*/ */
void err(const std::string& msg) const; void err(const std::string& msg) const;
}; };
//! Utility routine to print out the matrix //! Utility routine to print out the matrix

View file

@ -69,9 +69,7 @@ public:
*/ */
class DenseMatrix : public Array2D class DenseMatrix : public Array2D
{ {
public: public:
//! Default Constructor //! Default Constructor
DenseMatrix(); DenseMatrix();
@ -107,14 +105,6 @@ public:
*/ */
void resize(size_t n, size_t m, doublereal v = 0.0); void resize(size_t n, size_t m, doublereal v = 0.0);
//! 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.
*/
virtual doublereal* const* colPts(); virtual doublereal* const* colPts();
//! Return a const vector of const pointers to the columns //! Return a const vector of const pointers to the columns
@ -127,17 +117,10 @@ public:
*/ */
const doublereal* const* const_colPts() const; const doublereal* const* const_colPts() const;
//! Multiply A*b and write result to \c prod.
/*!
*
* @param b input vector b with length N
* @param prod output output vector prod length = M
*/
virtual void mult(const double* b, double* prod) const; virtual void mult(const double* b, double* prod) const;
//! Multiply A*B and write result to \c prod. //! Multiply A*B and write result to \c prod.
/*! /*!
*
* @param b input DenseMatrix B of size NxN * @param b input DenseMatrix B of size NxN
* @param prod output output DenseMatrix prod size NxN * @param prod output output DenseMatrix prod size NxN
*/ */
@ -147,7 +130,6 @@ public:
/*! /*!
* @param b left multiply by this vector. The length must be equal to n * @param b left multiply by this vector. The length must be equal to n
* the number of rows in the matrix. * the number of rows in the matrix.
*
* @param prod Resulting vector. This is of length m, the number of columns * @param prod Resulting vector. This is of length m, the number of columns
* in the matrix * in the matrix
*/ */
@ -168,7 +150,6 @@ public:
} }
protected: protected:
//! Vector of pivots. Length is equal to the max of m and n. //! Vector of pivots. Length is equal to the max of m and n.
vector_int m_ipiv; vector_int m_ipiv;
@ -176,7 +157,6 @@ protected:
std::vector<doublereal*> m_colPts; std::vector<doublereal*> m_colPts;
public: public:
//! Error Handling Flag //! Error Handling Flag
/*! /*!
* The default is to set this to 0. In this case, if a factorization is requested and can't be achieved, * The default is to set this to 0. In this case, if a factorization is requested and can't be achieved,
@ -194,7 +174,6 @@ public:
*/ */
int m_printLevel; int m_printLevel;
// Listing of friend functions which are defined below // Listing of friend functions which are defined below
friend int solve(DenseMatrix& A, double* b); friend int solve(DenseMatrix& A, double* b);
@ -202,8 +181,6 @@ public:
friend int invert(DenseMatrix& A, int nn); friend int invert(DenseMatrix& A, int nn);
}; };
//==================================================================================================================
//! Solve Ax = b. Array b is overwritten on exit with x. //! Solve Ax = b. Array b is overwritten on exit with x.
/*! /*!
@ -265,6 +242,3 @@ int invert(DenseMatrix& A, size_t nn=npos);
} }
#endif #endif

View file

@ -32,15 +32,9 @@ public:
GeneralMatrix(int matType); GeneralMatrix(int matType);
//! Copy Constructor //! Copy Constructor
/*!
* @param right Object to be copied
*/
GeneralMatrix(const GeneralMatrix& right); GeneralMatrix(const GeneralMatrix& right);
//! Assignment operator //! Assignment operator
/*!
* @param right Object to be copied
*/
GeneralMatrix& operator=(const GeneralMatrix& right); GeneralMatrix& operator=(const GeneralMatrix& right);
//! Destructor. Does nothing. //! Destructor. Does nothing.
@ -48,7 +42,7 @@ public:
//! Duplicator member function //! Duplicator member function
/*! /*!
* This function will duplicate the matrix given a generic GeneralMatrix pointer * This function will duplicate the matrix given a generic GeneralMatrix
* *
* @return Returns a pointer to the malloced object * @return Returns a pointer to the malloced object
*/ */
@ -112,26 +106,16 @@ public:
virtual void useFactorAlgorithm(int fAlgorithm) = 0; virtual void useFactorAlgorithm(int fAlgorithm) = 0;
//! Return the factor algorithm used //! Return the factor algorithm used
/*!
*
*/
virtual int factorAlgorithm() const = 0; virtual int factorAlgorithm() const = 0;
//! Calculate the one norm of the matrix //! Calculate the one norm of the matrix
/*!
* Returns the one norm of the matrix
*/
virtual doublereal oneNorm() const = 0; virtual doublereal oneNorm() const = 0;
//! Return the number of rows in the matrix //! Return the number of rows in the matrix
virtual size_t nRows() const = 0; virtual size_t nRows() const = 0;
//! Return the size and structure of the matrix //! Return the size and structure of the matrix
/*! /*!
* This is inherited from GeneralMatrix
*
* @param iStruct OUTPUT Pointer to a vector of ints that describe the structure of the matrix. * @param iStruct OUTPUT Pointer to a vector of ints that describe the structure of the matrix.
* *
* @return returns the number of rows and columns in the matrix. * @return returns the number of rows and columns in the matrix.
@ -167,7 +151,6 @@ public:
*/ */
virtual doublereal& operator()(size_t i, size_t j) = 0; virtual doublereal& operator()(size_t i, size_t j) = 0;
//! Constant Index into the (i,j) element //! Constant Index into the (i,j) element
/*! /*!
* @param i row * @param i row

View file

@ -27,9 +27,6 @@ class SquareMatrix: public DenseMatrix, public GeneralMatrix
{ {
public: public:
//! Base Constructor. //! Base Constructor.
/*!
* Create an \c 0 by \c 0 matrix, and initialize all elements to \c 0.
*/
SquareMatrix(); SquareMatrix();
//! Constructor. //! Constructor.
@ -42,91 +39,28 @@ public:
SquareMatrix(size_t n, doublereal v = 0.0); SquareMatrix(size_t n, doublereal v = 0.0);
//! Copy Constructor //! Copy Constructor
/*!
* @param right Object to be copied
*/
SquareMatrix(const SquareMatrix& right); SquareMatrix(const SquareMatrix& right);
//! Assignment operator //! Assignment operator
/*!
* @param right Object to be copied
*/
SquareMatrix& operator=(const SquareMatrix& right); SquareMatrix& operator=(const SquareMatrix& right);
//! Solves the Ax = b system returning x in the b spot.
/*!
* @param b Vector for the rhs of the equation system
*/
int solve(doublereal* b); int solve(doublereal* b);
//! Resize the matrix
/*!
* @param n Number of rows
* @param m Number of columns
* @param v double to fill the new space (defaults to zero)
*/
void resize(size_t n, size_t m, doublereal v = 0.0); void resize(size_t n, size_t m, doublereal v = 0.0);
/** //! Zero the matrix
* Zero the matrix
*/
void zero(); void zero();
//! Multiply A*b and write result to prod.
/*!
* @param b Vector to do the rh multiplication
* @param prod OUTPUT vector to receive the result
*/
virtual void mult(const doublereal* b, doublereal* prod) const; virtual void mult(const doublereal* b, doublereal* prod) const;
//! Multiply A*B and write result to \c prod.
/*!
*
* @param b input DenseMatrix B of size NxN
* @param prod output output DenseMatrix prod size NxN
*/
virtual void mult(const DenseMatrix& b, DenseMatrix& prod) const; virtual void mult(const DenseMatrix& b, DenseMatrix& prod) const;
//! Multiply b*A and write result to prod.
/*!
* @param b Vector to do the lh multiplication
* @param prod OUTPUT vector to receive the result
*/
virtual void leftMult(const doublereal* const b, doublereal* const prod) const; virtual void leftMult(const doublereal* const b, doublereal* const prod) const;
/**
* Factors the A matrix, overwriting A. We flip m_factored
* boolean to indicate that the matrix is now A-1.
*/
int factor(); int factor();
//! Factors the A matrix using the QR algorithm, overwriting A
/*!
* we set m_factored to 2 to indicate the matrix is now QR factored
*
* @return Returns the info variable from lapack
*/
virtual int factorQR(); virtual int factorQR();
//! Returns an estimate of the inverse of the condition number for the matrix
/*!
* The matrix must have been previously factored using the QR algorithm
*
* @return returns the inverse of the condition number
*/
virtual doublereal rcondQR(); virtual doublereal rcondQR();
//! Returns an estimate of the inverse of the condition number for the matrix
/*!
* The matrix must have been previously factored using the LU algorithm
*
* @param a1norm Norm of the matrix
*
* @return returns the inverse of the condition number
*/
virtual doublereal rcond(doublereal a1norm); virtual doublereal rcond(doublereal a1norm);
//! Returns the one norm of the matrix
virtual doublereal oneNorm() const; virtual doublereal oneNorm() const;
//! Solves the linear problem Ax=b using the QR algorithm returning x in the b spot //! Solves the linear problem Ax=b using the QR algorithm returning x in the b spot
@ -135,22 +69,12 @@ public:
*/ */
int solveQR(doublereal* b); int solveQR(doublereal* b);
//! clear the factored flag
virtual void clearFactorFlag(); virtual void clearFactorFlag();
//! set the factored flag //! set the factored flag
void setFactorFlag(); void setFactorFlag();
//! Report whether the current matrix has been factored.
virtual bool factored() const; virtual bool factored() const;
//! Change the way the matrix is factored
/*!
* @param fAlgorithm integer
* 0 LU factorization
* 1 QR factorization
*/
virtual void useFactorAlgorithm(int fAlgorithm); virtual void useFactorAlgorithm(int fAlgorithm);
//! Returns the factor algorithm used //! Returns the factor algorithm used
@ -162,46 +86,18 @@ public:
*/ */
virtual int factorAlgorithm() const; virtual int factorAlgorithm() const;
//! Return a pointer to the top of column j, columns are assumed to be contiguous in memory
/*!
* @param j Value of the column
*
* @return Returns a pointer to the top of the column
*/
virtual doublereal* ptrColumn(size_t j); virtual doublereal* ptrColumn(size_t j);
//! Index into the (i,j) element
/*!
* @param i row
* @param j column
*
* (note, tried a using directive here, and it didn't seem to work)
*
* Returns a changeable reference to the matrix entry
*/
virtual doublereal& operator()(size_t i, size_t j) { virtual doublereal& operator()(size_t i, size_t j) {
return Array2D::operator()(i, j); return Array2D::operator()(i, j);
} }
//! Copy the data from one array into another without doing any checking
/*!
* This differs from the assignment operator as no resizing is done and memcpy() is used.
* @param y Array to be copied
*/
virtual void copyData(const GeneralMatrix& y); virtual void copyData(const GeneralMatrix& y);
//! Constant Index into the (i,j) element
/*!
* @param i row
* @param j column
*
* Returns an unchangeable reference to the matrix entry
*/
virtual doublereal operator()(size_t i, size_t j) const { virtual doublereal operator()(size_t i, size_t j) const {
return Array2D::operator()(i, j); return Array2D::operator()(i, j);
} }
//! Return the number of rows in the matrix
virtual size_t nRows() const; virtual size_t nRows() const;
//! Return the size and structure of the matrix //! Return the size and structure of the matrix
@ -215,54 +111,17 @@ public:
*/ */
size_t nRowsAndStruct(size_t* const iStruct = 0) const; size_t nRowsAndStruct(size_t* const iStruct = 0) const;
//! Duplicate this object
virtual GeneralMatrix* duplMyselfAsGeneralMatrix() const; virtual GeneralMatrix* duplMyselfAsGeneralMatrix() const;
//! Return an iterator pointing to the first element
/*!
*/
virtual vector_fp::iterator begin(); virtual vector_fp::iterator begin();
//! Return a const iterator pointing to the first element
virtual vector_fp::const_iterator begin() const; virtual vector_fp::const_iterator begin() const;
//! 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.
*/
virtual doublereal* const* colPts(); virtual doublereal* const* colPts();
//! Check to see if we have any zero rows in the jacobian
/*!
* This utility routine checks to see if any rows are zero.
* The smallest row is returned along with the largest coefficient in that row
*
* @param valueSmall OUTPUT value of the largest coefficient in the smallest row
*
* @return index of the row that is most nearly zero
*/
virtual size_t checkRows(doublereal& valueSmall) const; virtual size_t checkRows(doublereal& valueSmall) const;
//! Check to see if we have any zero columns in the jacobian
/*!
* This utility routine checks to see if any columns are zero.
* The smallest column is returned along with the largest coefficient in that column
*
* @param valueSmall OUTPUT value of the largest coefficient in the smallest column
*
* @return index of the column that is most nearly zero
*/
virtual size_t checkColumns(doublereal& valueSmall) const; virtual size_t checkColumns(doublereal& valueSmall) const;
protected: protected:
//! the factor flag //! the factor flag
int m_factored; int m_factored;
@ -285,4 +144,3 @@ protected:
} }
#endif #endif

View file

@ -21,7 +21,6 @@ using namespace std;
namespace Cantera namespace Cantera
{ {
//====================================================================================================================
BandMatrix::BandMatrix() : BandMatrix::BandMatrix() :
GeneralMatrix(1), GeneralMatrix(1),
m_factored(false), m_factored(false),
@ -33,7 +32,7 @@ BandMatrix::BandMatrix() :
data.clear(); data.clear();
ludata.clear(); ludata.clear();
} }
//====================================================================================================================
BandMatrix::BandMatrix(size_t n, size_t kl, size_t ku, doublereal v) : BandMatrix::BandMatrix(size_t n, size_t kl, size_t ku, doublereal v) :
GeneralMatrix(1), GeneralMatrix(1),
m_factored(false), m_factored(false),
@ -53,7 +52,7 @@ BandMatrix::BandMatrix(size_t n, size_t kl, size_t ku, doublereal v) :
m_colPtrs[j] = &(data[ldab * j]); m_colPtrs[j] = &(data[ldab * j]);
} }
} }
//====================================================================================================================
BandMatrix::BandMatrix(const BandMatrix& y) : BandMatrix::BandMatrix(const BandMatrix& y) :
GeneralMatrix(1), GeneralMatrix(1),
m_factored(false), m_factored(false),
@ -75,7 +74,7 @@ BandMatrix::BandMatrix(const BandMatrix& y) :
m_colPtrs[j] = &(data[ldab * j]); m_colPtrs[j] = &(data[ldab * j]);
} }
} }
//====================================================================================================================
BandMatrix& BandMatrix::operator=(const BandMatrix& y) BandMatrix& BandMatrix::operator=(const BandMatrix& y)
{ {
if (&y == this) { if (&y == this) {
@ -96,7 +95,7 @@ BandMatrix& BandMatrix::operator=(const BandMatrix& y)
} }
return *this; return *this;
} }
//====================================================================================================================
void BandMatrix::resize(size_t n, size_t kl, size_t ku, doublereal v) void BandMatrix::resize(size_t n, size_t kl, size_t ku, doublereal v)
{ {
m_n = n; m_n = n;
@ -113,29 +112,29 @@ void BandMatrix::resize(size_t n, size_t kl, size_t ku, doublereal v)
} }
m_factored = false; m_factored = false;
} }
//====================================================================================================================
void BandMatrix::bfill(doublereal v) void BandMatrix::bfill(doublereal v)
{ {
std::fill(data.begin(), data.end(), v); std::fill(data.begin(), data.end(), v);
m_factored = false; m_factored = false;
} }
//====================================================================================================================
void BandMatrix::zero() void BandMatrix::zero()
{ {
std::fill(data.begin(), data.end(), 0.0); std::fill(data.begin(), data.end(), 0.0);
m_factored = false; m_factored = false;
} }
//====================================================================================================================
doublereal& BandMatrix::operator()(size_t i, size_t j) doublereal& BandMatrix::operator()(size_t i, size_t j)
{ {
return value(i,j); return value(i,j);
} }
//====================================================================================================================
doublereal BandMatrix::operator()(size_t i, size_t j) const doublereal BandMatrix::operator()(size_t i, size_t j) const
{ {
return value(i,j); return value(i,j);
} }
//====================================================================================================================
doublereal& BandMatrix::value(size_t i, size_t j) doublereal& BandMatrix::value(size_t i, size_t j)
{ {
m_factored = false; m_factored = false;
@ -144,7 +143,7 @@ doublereal& BandMatrix::value(size_t i, size_t j)
} }
return data[index(i,j)]; return data[index(i,j)];
} }
//====================================================================================================================
doublereal BandMatrix::value(size_t i, size_t j) const doublereal BandMatrix::value(size_t i, size_t j) const
{ {
if (i + m_ku < j || i > j + m_kl) { if (i + m_ku < j || i > j + m_kl) {
@ -152,7 +151,7 @@ doublereal BandMatrix::value(size_t i, size_t j) const
} }
return data[index(i,j)]; return data[index(i,j)];
} }
//====================================================================================================================
size_t BandMatrix::index(size_t i, size_t j) const size_t BandMatrix::index(size_t i, size_t j) const
{ {
int jj = static_cast<int>(j); int jj = static_cast<int>(j);
@ -160,19 +159,17 @@ size_t BandMatrix::index(size_t i, size_t j) const
size_t rw = (int) m_kl + (int) m_ku + (int) ii - jj; size_t rw = (int) m_kl + (int) m_ku + (int) ii - jj;
return (2*m_kl + m_ku + 1)*j + rw; return (2*m_kl + m_ku + 1)*j + rw;
} }
//====================================================================================================================
doublereal BandMatrix::_value(size_t i, size_t j) const doublereal BandMatrix::_value(size_t i, size_t j) const
{ {
return data[index(i,j)]; return data[index(i,j)];
} }
//====================================================================================================================
// Number of rows
size_t BandMatrix::nRows() const size_t BandMatrix::nRows() const
{ {
return m_n; return m_n;
} }
//====================================================================================================================
// Number of rows
size_t BandMatrix::nRowsAndStruct(size_t* const iStruct) const size_t BandMatrix::nRowsAndStruct(size_t* const iStruct) const
{ {
if (iStruct) { if (iStruct) {
@ -229,10 +226,7 @@ void BandMatrix::mult(const doublereal* b, doublereal* prod) const
prod[m] = sum; prod[m] = sum;
} }
} }
//====================================================================================================================
/*
* Multiply b*A and write result to \c prod.
*/
void BandMatrix::leftMult(const doublereal* const b, doublereal* const prod) const void BandMatrix::leftMult(const doublereal* const b, doublereal* const prod) const
{ {
int kl = static_cast<int>(m_kl); int kl = static_cast<int>(m_kl);
@ -250,11 +244,7 @@ void BandMatrix::leftMult(const doublereal* const b, doublereal* const prod) con
prod[n] = sum; prod[n] = sum;
} }
} }
//====================================================================================================================
/*
* Perform an LU decomposition. LAPACK routine DGBTRF is used.
* The factorization is saved in ludata.
*/
int BandMatrix::factor() int BandMatrix::factor()
{ {
int info=0; int info=0;
@ -273,13 +263,13 @@ int BandMatrix::factor()
} }
return info; return info;
} }
//====================================================================================================================
int BandMatrix::solve(const doublereal* const b, doublereal* const x) int BandMatrix::solve(const doublereal* const b, doublereal* const x)
{ {
copy(b, b + m_n, x); copy(b, b + m_n, x);
return solve(x); return solve(x);
} }
//====================================================================================================================
int BandMatrix::solve(doublereal* b) int BandMatrix::solve(doublereal* b)
{ {
int info = 0; int info = 0;
@ -299,29 +289,29 @@ int BandMatrix::solve(doublereal* b)
} }
return info; return info;
} }
//====================================================================================================================
vector_fp::iterator BandMatrix::begin() vector_fp::iterator BandMatrix::begin()
{ {
m_factored = false; m_factored = false;
return data.begin(); return data.begin();
} }
//====================================================================================================================
vector_fp::iterator BandMatrix::end() vector_fp::iterator BandMatrix::end()
{ {
m_factored = false; m_factored = false;
return data.end(); return data.end();
} }
//====================================================================================================================
vector_fp::const_iterator BandMatrix::begin() const vector_fp::const_iterator BandMatrix::begin() const
{ {
return data.begin(); return data.begin();
} }
//====================================================================================================================
vector_fp::const_iterator BandMatrix::end() const vector_fp::const_iterator BandMatrix::end() const
{ {
return data.end(); return data.end();
} }
//====================================================================================================================
ostream& operator<<(ostream& s, const BandMatrix& m) ostream& operator<<(ostream& s, const BandMatrix& m)
{ {
size_t nr = m.nRows(); size_t nr = m.nRows();
@ -334,45 +324,24 @@ ostream& operator<<(ostream& s, const BandMatrix& m)
} }
return s; return s;
} }
//====================================================================================================================
void BandMatrix::err(const std::string& msg) const void BandMatrix::err(const std::string& msg) const
{ {
throw CanteraError("BandMatrix() unimplemented function", msg); throw CanteraError("BandMatrix() unimplemented function", msg);
} }
//====================================================================================================================
// Factors the A matrix using the QR algorithm, overwriting A
/*
* we set m_factored to 2 to indicate the matrix is now QR factored
*
* @return Returns the info variable from lapack
*/
int BandMatrix::factorQR() int BandMatrix::factorQR()
{ {
factor(); factor();
return 0; return 0;
} }
//====================================================================================================================
// Factors the A matrix using the QR algorithm, overwriting A
// Returns an estimate of the inverse of the condition number for the matrix
/*
* The matrix must have been previously factored using the QR algorithm
*
* @return returns the inverse of the condition number
*/
doublereal BandMatrix::rcondQR() doublereal BandMatrix::rcondQR()
{ {
double a1norm = oneNorm(); double a1norm = oneNorm();
return rcond(a1norm); return rcond(a1norm);
} }
//====================================================================================================================
// Returns an estimate of the inverse of the condition number for the matrix
/*
* The matrix must have been previously factored using the LU algorithm
*
* @param a1norm Norm of the matrix
*
* @return returns the inverse of the condition number
*/
doublereal BandMatrix::rcond(doublereal a1norm) doublereal BandMatrix::rcond(doublereal a1norm)
{ {
int printLevel = 0; int printLevel = 0;
@ -403,24 +372,17 @@ doublereal BandMatrix::rcond(doublereal a1norm)
} }
return rcond; return rcond;
} }
//====================================================================================================================
// Change the way the matrix is factored
/*
* @param fAlgorithm integer
* 0 LU factorization
* 1 QR factorization
*/
void BandMatrix::useFactorAlgorithm(int fAlgorithm) void BandMatrix::useFactorAlgorithm(int fAlgorithm)
{ {
// QR algorithm isn't implemented for banded matrix. // QR algorithm isn't implemented for banded matrix.
} }
//====================================================================================================================
int BandMatrix::factorAlgorithm() const int BandMatrix::factorAlgorithm() const
{ {
return 0; return 0;
} }
//====================================================================================================================
// Returns the one norm of the matrix
doublereal BandMatrix::oneNorm() const doublereal BandMatrix::oneNorm() const
{ {
int ku = static_cast<int>(m_ku); int ku = static_cast<int>(m_ku);
@ -438,7 +400,7 @@ doublereal BandMatrix::oneNorm() const
} }
return value; return value;
} }
//====================================================================================================================
size_t BandMatrix::checkRows(doublereal& valueSmall) const size_t BandMatrix::checkRows(doublereal& valueSmall) const
{ {
valueSmall = 1.0E300; valueSmall = 1.0E300;
@ -464,7 +426,7 @@ size_t BandMatrix::checkRows(doublereal& valueSmall) const
} }
return iSmall; return iSmall;
} }
//====================================================================================================================
size_t BandMatrix::checkColumns(doublereal& valueSmall) const size_t BandMatrix::checkColumns(doublereal& valueSmall) const
{ {
valueSmall = 1.0E300; valueSmall = 1.0E300;
@ -490,46 +452,27 @@ size_t BandMatrix::checkColumns(doublereal& valueSmall) const
} }
return jSmall; return jSmall;
} }
//====================================================================================================================
GeneralMatrix* BandMatrix::duplMyselfAsGeneralMatrix() const GeneralMatrix* BandMatrix::duplMyselfAsGeneralMatrix() const
{ {
return new BandMatrix(*this); return new BandMatrix(*this);
} }
//====================================================================================================================
bool BandMatrix::factored() const bool BandMatrix::factored() const
{ {
return m_factored; return m_factored;
} }
//====================================================================================================================
// Return a pointer to the top of column j, columns are assumed to be contiguous in memory
/*
* @param j Value of the column
*
* @return Returns a pointer to the top of the column
*/
doublereal* BandMatrix::ptrColumn(size_t j) doublereal* BandMatrix::ptrColumn(size_t j)
{ {
return m_colPtrs[j]; return m_colPtrs[j];
} }
//====================================================================================================================
// 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* BandMatrix::colPts() doublereal* const* BandMatrix::colPts()
{ {
return &(m_colPtrs[0]); return &(m_colPtrs[0]);
} }
//====================================================================================================================
// Copy the data from one array into another without doing any checking
/*
* This differs from the assignment operator as no resizing is done and memcpy() is used.
* @param y Array to be copied
*/
void BandMatrix::copyData(const GeneralMatrix& y) void BandMatrix::copyData(const GeneralMatrix& y)
{ {
m_factored = false; m_factored = false;
@ -537,15 +480,10 @@ void BandMatrix::copyData(const GeneralMatrix& y)
GeneralMatrix* yyPtr = const_cast<GeneralMatrix*>(&y); GeneralMatrix* yyPtr = const_cast<GeneralMatrix*>(&y);
(void) memcpy(DATA_PTR(data), yyPtr->ptrColumn(0), n); (void) memcpy(DATA_PTR(data), yyPtr->ptrColumn(0), n);
} }
//====================================================================================================================
/*
* clear the factored flag
*/
void BandMatrix::clearFactorFlag() void BandMatrix::clearFactorFlag()
{ {
m_factored = 0; m_factored = 0;
} }
//====================================================================================================================
//====================================================================================================================
}
}

View file

@ -13,8 +13,7 @@
namespace Cantera namespace Cantera
{ {
//====================================================================================================================
// Default Constructor
DenseMatrix::DenseMatrix() : DenseMatrix::DenseMatrix() :
Array2D(0,0,0.0), Array2D(0,0,0.0),
m_ipiv(0), m_ipiv(0),
@ -22,11 +21,7 @@ DenseMatrix::DenseMatrix() :
m_printLevel(0) m_printLevel(0)
{ {
} }
//====================================================================================================================
/*
* Constructor. Create an \c n by \c m matrix, and initialize
* all elements to \c v.
*/
DenseMatrix::DenseMatrix(size_t n, size_t m, doublereal v) : DenseMatrix::DenseMatrix(size_t n, size_t m, doublereal v) :
Array2D(n, m, v), Array2D(n, m, v),
m_ipiv(0), m_ipiv(0),
@ -41,11 +36,7 @@ DenseMatrix::DenseMatrix(size_t n, size_t m, doublereal v) :
} }
} }
} }
//====================================================================================================================
// Copy constructor
/*
* @param y Object to be copied
*/
DenseMatrix::DenseMatrix(const DenseMatrix& y) : DenseMatrix::DenseMatrix(const DenseMatrix& y) :
Array2D(y), Array2D(y),
m_ipiv(0), m_ipiv(0),
@ -60,8 +51,7 @@ DenseMatrix::DenseMatrix(const DenseMatrix& y) :
} }
} }
} }
//====================================================================================================================
// assignment
DenseMatrix& DenseMatrix::operator=(const DenseMatrix& y) DenseMatrix& DenseMatrix::operator=(const DenseMatrix& y)
{ {
if (&y == this) { if (&y == this) {
@ -77,7 +67,7 @@ DenseMatrix& DenseMatrix::operator=(const DenseMatrix& y)
m_printLevel = y.m_printLevel; m_printLevel = y.m_printLevel;
return *this; return *this;
} }
//====================================================================================================================
void DenseMatrix::resize(size_t n, size_t m, doublereal v) void DenseMatrix::resize(size_t n, size_t m, doublereal v)
{ {
Array2D::resize(n,m,v); Array2D::resize(n,m,v);
@ -89,17 +79,17 @@ void DenseMatrix::resize(size_t n, size_t m, doublereal v)
} }
} }
} }
//====================================================================================================================
doublereal* const* DenseMatrix::colPts() doublereal* const* DenseMatrix::colPts()
{ {
return &(m_colPts[0]); return &(m_colPts[0]);
} }
//====================================================================================================================
const doublereal* const* DenseMatrix::const_colPts() const const doublereal* const* DenseMatrix::const_colPts() const
{ {
return &(m_colPts[0]); return &(m_colPts[0]);
} }
//====================================================================================================================
void DenseMatrix::mult(const double* b, double* prod) const void DenseMatrix::mult(const double* b, double* prod) const
{ {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose,
@ -107,7 +97,7 @@ void DenseMatrix::mult(const double* b, double* prod) const
static_cast<int>(nRows()), 1.0, ptrColumn(0), //begin(), static_cast<int>(nRows()), 1.0, ptrColumn(0), //begin(),
static_cast<int>(nRows()), b, 1, 0.0, prod, 1); static_cast<int>(nRows()), b, 1, 0.0, prod, 1);
} }
//====================================================================================================================
void DenseMatrix::mult(const DenseMatrix& B, DenseMatrix& prod) const void DenseMatrix::mult(const DenseMatrix& B, DenseMatrix& prod) const
{ {
if (m_ncols != B.nColumns() || m_nrows != B.nRows() || m_ncols != m_nrows || m_ncols != prod.nColumns() || m_nrows != prod.nColumns()) { if (m_ncols != B.nColumns() || m_nrows != B.nRows() || m_ncols != m_nrows || m_ncols != prod.nColumns() || m_nrows != prod.nColumns()) {
@ -121,7 +111,7 @@ void DenseMatrix::mult(const DenseMatrix& B, DenseMatrix& prod) const
mult(bcols[col], prodcols[col]); mult(bcols[col], prodcols[col]);
} }
} }
//====================================================================================================================
void DenseMatrix::leftMult(const double* const b, double* const prod) const void DenseMatrix::leftMult(const double* const b, double* const prod) const
{ {
size_t nc = nColumns(); size_t nc = nColumns();
@ -135,12 +125,12 @@ void DenseMatrix::leftMult(const double* const b, double* const prod) const
prod[n] = sum; prod[n] = sum;
} }
} }
//====================================================================================================================
vector_int& DenseMatrix::ipiv() vector_int& DenseMatrix::ipiv()
{ {
return m_ipiv; return m_ipiv;
} }
//====================================================================================================================
int solve(DenseMatrix& A, double* b) int solve(DenseMatrix& A, double* b)
{ {
int info = 0; int info = 0;
@ -186,7 +176,7 @@ int solve(DenseMatrix& A, double* b)
} }
return info; return info;
} }
//====================================================================================================================
int solve(DenseMatrix& A, DenseMatrix& b) int solve(DenseMatrix& A, DenseMatrix& b)
{ {
int info = 0; int info = 0;
@ -239,21 +229,21 @@ int solve(DenseMatrix& A, DenseMatrix& b)
return info; return info;
} }
//====================================================================================================================
void multiply(const DenseMatrix& A, const double* const b, double* const prod) void multiply(const DenseMatrix& A, const double* const b, double* const prod)
{ {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose,
static_cast<int>(A.nRows()), static_cast<int>(A.nColumns()), 1.0, static_cast<int>(A.nRows()), static_cast<int>(A.nColumns()), 1.0,
A.ptrColumn(0), static_cast<int>(A.nRows()), b, 1, 0.0, prod, 1); A.ptrColumn(0), static_cast<int>(A.nRows()), b, 1, 0.0, prod, 1);
} }
//====================================================================================================================
void increment(const DenseMatrix& A, const double* b, double* prod) void increment(const DenseMatrix& A, const double* b, double* prod)
{ {
ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose,
static_cast<int>(A.nRows()), static_cast<int>(A.nRows()), 1.0, static_cast<int>(A.nRows()), static_cast<int>(A.nRows()), 1.0,
A.ptrColumn(0), static_cast<int>(A.nRows()), b, 1, 1.0, prod, 1); A.ptrColumn(0), static_cast<int>(A.nRows()), b, 1, 1.0, prod, 1);
} }
//====================================================================================================================
int invert(DenseMatrix& A, size_t nn) int invert(DenseMatrix& A, size_t nn)
{ {
integer n = static_cast<int>(nn != npos ? nn : A.nRows()); integer n = static_cast<int>(nn != npos ? nn : A.nRows());
@ -284,6 +274,5 @@ int invert(DenseMatrix& A, size_t nn)
} }
return info; return info;
} }
//====================================================================================================================
}
}

View file

@ -14,17 +14,17 @@ using namespace std;
namespace Cantera namespace Cantera
{ {
//====================================================================================================================
GeneralMatrix::GeneralMatrix(int matType) : GeneralMatrix::GeneralMatrix(int matType) :
matrixType_(matType) matrixType_(matType)
{ {
} }
//====================================================================================================================
GeneralMatrix::GeneralMatrix(const GeneralMatrix& y) : GeneralMatrix::GeneralMatrix(const GeneralMatrix& y) :
matrixType_(y.matrixType_) matrixType_(y.matrixType_)
{ {
} }
//====================================================================================================================
GeneralMatrix& GeneralMatrix::operator=(const GeneralMatrix& y) GeneralMatrix& GeneralMatrix::operator=(const GeneralMatrix& y)
{ {
if (&y == this) { if (&y == this) {
@ -33,9 +33,9 @@ GeneralMatrix& GeneralMatrix::operator=(const GeneralMatrix& y)
matrixType_ = y.matrixType_; matrixType_ = y.matrixType_;
return *this; return *this;
} }
//====================================================================================================================
GeneralMatrix::~GeneralMatrix() GeneralMatrix::~GeneralMatrix()
{ {
} }
//====================================================================================================================
} }

View file

@ -24,7 +24,6 @@ using namespace std;
namespace Cantera namespace Cantera
{ {
//====================================================================================================================
SquareMatrix::SquareMatrix() : SquareMatrix::SquareMatrix() :
DenseMatrix(), DenseMatrix(),
GeneralMatrix(0), GeneralMatrix(0),
@ -34,15 +33,6 @@ SquareMatrix::SquareMatrix() :
{ {
} }
//====================================================================================================================
// Constructor.
/*
* Create an \c n by \c n matrix, and initialize
* all elements to \c v.
*
* @param n size of the square matrix
* @param v initial value of all matrix components.
*/
SquareMatrix::SquareMatrix(size_t n, doublereal v) : SquareMatrix::SquareMatrix(size_t n, doublereal v) :
DenseMatrix(n, n, v), DenseMatrix(n, n, v),
GeneralMatrix(0), GeneralMatrix(0),
@ -52,11 +42,7 @@ SquareMatrix::SquareMatrix(size_t n, doublereal v) :
{ {
} }
//====================================================================================================================
/*
*
* copy constructor
*/
SquareMatrix::SquareMatrix(const SquareMatrix& y) : SquareMatrix::SquareMatrix(const SquareMatrix& y) :
DenseMatrix(y), DenseMatrix(y),
GeneralMatrix(0), GeneralMatrix(0),
@ -66,10 +52,6 @@ SquareMatrix::SquareMatrix(const SquareMatrix& y) :
{ {
} }
//====================================================================================================================
/*
* Assignment operator
*/
SquareMatrix& SquareMatrix::operator=(const SquareMatrix& y) SquareMatrix& SquareMatrix::operator=(const SquareMatrix& y)
{ {
if (&y == this) { if (&y == this) {
@ -82,10 +64,7 @@ SquareMatrix& SquareMatrix::operator=(const SquareMatrix& y)
useQR_ = y.useQR_; useQR_ = y.useQR_;
return *this; return *this;
} }
//====================================================================================================================
/*
* Solve Ax = b. Vector b is overwritten on exit with x.
*/
int SquareMatrix::solve(doublereal* b) int SquareMatrix::solve(doublereal* b)
{ {
if (useQR_) { if (useQR_) {
@ -117,10 +96,7 @@ int SquareMatrix::solve(doublereal* b)
} }
return info; return info;
} }
//====================================================================================================================
/*
* Set all entries to zero
*/
void SquareMatrix::zero() void SquareMatrix::zero()
{ {
size_t n = nRows(); size_t n = nRows();
@ -134,47 +110,27 @@ void SquareMatrix::zero()
(void) memset((void*) sm, 0, nn * sizeof(double)); (void) memset((void*) sm, 0, nn * sizeof(double));
} }
} }
//====================================================================================================================
void SquareMatrix::resize(size_t n, size_t m, doublereal v) void SquareMatrix::resize(size_t n, size_t m, doublereal v)
{ {
DenseMatrix::resize(n, m, v); DenseMatrix::resize(n, m, v);
} }
//====================================================================================================================
// Multiply A*b and write result to prod.
/*
* @param b Vector to do the rh multiplication
* @param prod OUTPUT vector to receive the result
*/
void SquareMatrix::mult(const doublereal* b, doublereal* prod) const void SquareMatrix::mult(const doublereal* b, doublereal* prod) const
{ {
DenseMatrix::mult(b, prod); DenseMatrix::mult(b, prod);
} }
//====================================================================================================================
// Multiply A*B and write result to \c prod.
/*
*
* @param b input DenseMatrix B of size NxN
* @param prod output output DenseMatrix prod size NxN
*/
void SquareMatrix::mult(const DenseMatrix& b, DenseMatrix& prod) const void SquareMatrix::mult(const DenseMatrix& b, DenseMatrix& prod) const
{ {
DenseMatrix::mult(b, prod); DenseMatrix::mult(b, prod);
} }
//====================================================================================================================
// Multiply b*A and write result to prod.
/*
* @param b Vector to do the lh multiplication
* @param prod OUTPUT vector to receive the result
*/
void SquareMatrix::leftMult(const doublereal* const b, doublereal* const prod) const void SquareMatrix::leftMult(const doublereal* const b, doublereal* const prod) const
{ {
DenseMatrix::leftMult(b, prod); DenseMatrix::leftMult(b, prod);
} }
//====================================================================================================================
/*
* Factor A. A is overwritten with the LU decomposition of A.
*/
int SquareMatrix::factor() int SquareMatrix::factor()
{ {
if (useQR_) { if (useQR_) {
@ -195,23 +151,17 @@ int SquareMatrix::factor()
} }
return info; return info;
} }
//=====================================================================================================================
/*
* clear the factored flag
*/
void SquareMatrix::clearFactorFlag() void SquareMatrix::clearFactorFlag()
{ {
m_factored = 0; m_factored = 0;
} }
//=====================================================================================================================
/*
* set the factored flag
*/
void SquareMatrix::setFactorFlag() void SquareMatrix::setFactorFlag()
{ {
m_factored = 1; m_factored = 1;
} }
//=====================================================================================================================
int SquareMatrix::factorQR() int SquareMatrix::factorQR()
{ {
if (tau.size() < m_nrows) { if (tau.size() < m_nrows) {
@ -239,10 +189,7 @@ int SquareMatrix::factorQR()
return info; return info;
} }
//=====================================================================================================================
/*
* Solve Ax = b. Vector b is overwritten on exit with x.
*/
int SquareMatrix::solveQR(doublereal* b) int SquareMatrix::solveQR(doublereal* b)
{ {
int info=0; int info=0;
@ -295,7 +242,7 @@ int SquareMatrix::solveQR(doublereal* b)
return info; return info;
} }
//=====================================================================================================================
doublereal SquareMatrix::rcond(doublereal anorm) doublereal SquareMatrix::rcond(doublereal anorm)
{ {
@ -326,12 +273,12 @@ doublereal SquareMatrix::rcond(doublereal anorm)
} }
return rcond; return rcond;
} }
//=====================================================================================================================
doublereal SquareMatrix::oneNorm() const doublereal SquareMatrix::oneNorm() const
{ {
return a1norm_; return a1norm_;
} }
//=====================================================================================================================
doublereal SquareMatrix::rcondQR() doublereal SquareMatrix::rcondQR()
{ {
@ -359,84 +306,62 @@ doublereal SquareMatrix::rcondQR()
} }
return rcond; return rcond;
} }
//=====================================================================================================================
void SquareMatrix::useFactorAlgorithm(int fAlgorithm) void SquareMatrix::useFactorAlgorithm(int fAlgorithm)
{ {
useQR_ = fAlgorithm; useQR_ = fAlgorithm;
} }
//=====================================================================================================================
int SquareMatrix::factorAlgorithm() const int SquareMatrix::factorAlgorithm() const
{ {
return (int) useQR_; return (int) useQR_;
} }
//=====================================================================================================================
bool SquareMatrix::factored() const bool SquareMatrix::factored() const
{ {
return (m_factored != 0); return (m_factored != 0);
} }
//=====================================================================================================================
// Return a pointer to the top of column j, columns are contiguous in memory
/*
* @param j Value of the column
*
* @return Returns a pointer to the top of the column
*/
doublereal* SquareMatrix::ptrColumn(size_t j) doublereal* SquareMatrix::ptrColumn(size_t j)
{ {
return Array2D::ptrColumn(j); return Array2D::ptrColumn(j);
} }
//=====================================================================================================================
// Copy the data from one array into another without doing any checking
/*
* This differs from the assignment operator as no resizing is done and memcpy() is used.
* @param y Array to be copied
*/
void SquareMatrix::copyData(const GeneralMatrix& y) void SquareMatrix::copyData(const GeneralMatrix& y)
{ {
const SquareMatrix* yy_ptr = dynamic_cast<const SquareMatrix*>(& y); const SquareMatrix* yy_ptr = dynamic_cast<const SquareMatrix*>(& y);
Array2D::copyData(*yy_ptr); Array2D::copyData(*yy_ptr);
} }
//=====================================================================================================================
size_t SquareMatrix::nRows() const size_t SquareMatrix::nRows() const
{ {
return m_nrows; return m_nrows;
} }
//=====================================================================================================================
size_t SquareMatrix::nRowsAndStruct(size_t* const iStruct) const size_t SquareMatrix::nRowsAndStruct(size_t* const iStruct) const
{ {
return m_nrows; return m_nrows;
} }
//=====================================================================================================================
GeneralMatrix* SquareMatrix::duplMyselfAsGeneralMatrix() const GeneralMatrix* SquareMatrix::duplMyselfAsGeneralMatrix() const
{ {
return new SquareMatrix(*this); return new SquareMatrix(*this);
} }
//=====================================================================================================================
// Return an iterator pointing to the first element
vector_fp::iterator SquareMatrix::begin() vector_fp::iterator SquareMatrix::begin()
{ {
return m_data.begin(); return m_data.begin();
} }
//=====================================================================================================================
// Return a const iterator pointing to the first element
vector_fp::const_iterator SquareMatrix::begin() const vector_fp::const_iterator SquareMatrix::begin() const
{ {
return m_data.begin(); return m_data.begin();
} }
//=====================================================================================================================
// 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* SquareMatrix::colPts() doublereal* const* SquareMatrix::colPts()
{ {
return DenseMatrix::colPts(); return DenseMatrix::colPts();
} }
//=====================================================================================================================
size_t SquareMatrix::checkRows(doublereal& valueSmall) const size_t SquareMatrix::checkRows(doublereal& valueSmall) const
{ {
@ -456,7 +381,7 @@ size_t SquareMatrix::checkRows(doublereal& valueSmall) const
} }
return iSmall; return iSmall;
} }
//=====================================================================================================================
size_t SquareMatrix::checkColumns(doublereal& valueSmall) const size_t SquareMatrix::checkColumns(doublereal& valueSmall) const
{ {
valueSmall = 1.0E300; valueSmall = 1.0E300;
@ -475,8 +400,5 @@ size_t SquareMatrix::checkColumns(doublereal& valueSmall) const
} }
return jSmall; return jSmall;
} }
//=====================================================================================================================
} }