mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: multiply(ans, A, B) for matrices templated on Matrix type. Previously only worked for rectangular matrices.
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user