ENH: multiply(ans, A, B) for matrices templated on Matrix type. Previously only worked for rectangular matrices.

This commit is contained in:
laurence
2012-12-20 12:00:14 +00:00
parent 3b9cdac8f4
commit 1e3d4eb067
3 changed files with 40 additions and 38 deletions

View File

@ -136,41 +136,6 @@ void Foam::LUDecompose
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
void Foam::multiply
(
scalarRectangularMatrix& ans, // value changed in return
const scalarRectangularMatrix& A,
const scalarRectangularMatrix& B
)
{
if (A.m() != B.n())
{
FatalErrorIn
(
"multiply("
"scalarRectangularMatrix& answer "
"const scalarRectangularMatrix& A, "
"const scalarRectangularMatrix& B)"
) << "A and B must have identical inner dimensions but A.m = "
<< A.m() << " and B.n = " << B.n()
<< abort(FatalError);
}
ans = scalarRectangularMatrix(A.n(), B.m(), scalar(0));
for (register label i = 0; i < A.n(); i++)
{
for (register label j = 0; j < B.m(); j++)
{
for (register label l = 0; l < B.n(); l++)
{
ans[i][j] += A[i][l]*B[l][j];
}
}
}
}
void Foam::multiply
(
scalarRectangularMatrix& ans, // value changed in return