Skip to content
Snippets Groups Projects
Commit f6b5250c authored by Mark Woolrich's avatar Mark Woolrich
Browse files

*** empty log message ***

parent fd078afb
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,6 @@
/* CCOPYRIGHT */
#include <iostream>
#include <iomanip>
#include <strstream>
......@@ -222,6 +221,30 @@ namespace MISCMATHS {
}
}
void multiply(const DiagonalMatrix& lm, const SparseMatrix& rm, SparseMatrix& ret)
{
Tracer_Plus tr("SparseMatrix::multiply");
int nrows = lm.Nrows();
int ncols = rm.Ncols();
if(lm.Ncols() != rm.Nrows()) throw Exception("Rows and cols don't match in SparseMatrix::multiply");
ret.ReSize(nrows,ncols);
for(int j = 1; j<=nrows; j++)
{
const SparseMatrix::Row& row = rm.row(j);
for(SparseMatrix::Row::const_iterator it=row.begin();it!=row.end();it++)
{
int c = (*it).first+1;
double val = (*it).second;
ret.insert(j,c,val*lm(j,j));
}
}
}
void multiply(const SparseMatrix& lm, const SparseMatrix::Row& rm, ColumnVector& ret)
{
Tracer_Plus tr("SparseMatrix::multiply3");
......
......@@ -128,6 +128,7 @@ namespace MISCMATHS {
};
void multiply(const SparseMatrix& lm, const SparseMatrix& rm, SparseMatrix& ret);
void multiply(const DiagonalMatrix& lm, const SparseMatrix& rm, SparseMatrix& ret);
void multiply(const SparseMatrix& lm, const ColumnVector& rm, ColumnVector& ret);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment