Add function to DenseMatrix that multiplies two square matrices.

This commit is contained in:
Victor Brunini 2013-01-07 18:18:10 +00:00
parent 205706f5dd
commit 9b6b65fe04
2 changed files with 24 additions and 0 deletions

View file

@ -138,6 +138,14 @@ public:
*/
virtual void mult(const double* b, double* 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;
//! Left-multiply the matrix by transpose(b), and write the result to prod.
/*!
* @param b left multiply by this vector. The length must be equal to n

View file

@ -113,6 +113,22 @@ void DenseMatrix::mult(const double* b, double* prod) const
static_cast<int>(nRows()), b, 1, 0.0, prod, 1);
}
//====================================================================================================================
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() )
{
throw CanteraError("mult(const DenseMatrix &B, DenseMatrix &prod)",
"Cannot multiply matrices that are not square and/or not the same size.");
}
const doublereal * const *bcols = B.const_colPts();
doublereal * const *prodcols = prod.colPts();
for(size_t col=0; col < m_ncols; ++col)
{
// Loop over ncols multiplying A*column of B and storing in corresponding prod column
mult(bcols[col], prodcols[col]);
}
}
//====================================================================================================================
void DenseMatrix::leftMult(const double* const b, double* const prod) const
{
size_t nc = nColumns();