Skip to content
Snippets Groups Projects
Commit ceb58ec2 authored by Christian Engwer's avatar Christian Engwer
Browse files

add methods to multiply FieldMatrizes of different size

[[Imported from SVN: r5431]]
parent 9db6b67a
No related branches found
No related tags found
No related merge requests found
......@@ -284,6 +284,7 @@ namespace Dune {
void mv (const X& x, Y& y) const
{
#ifdef DUNE_FMatrix_WITH_CHECKING
assert(&x != &y);
if (x.N()!=M()) DUNE_THROW(FMatrixError,"index out of range");
if (y.N()!=N()) DUNE_THROW(FMatrixError,"index out of range");
#endif
......@@ -485,6 +486,22 @@ namespace Dune {
return *this;
}
//! Multiplies M from the left to this matrix, this matrix is not modified
template<int l>
FieldMatrix<K,l,m> leftmultiplyany (const FieldMatrix<K,l,n>& M)
{
FieldMatrix<K,l,m> C;
for (size_type i=0; i<l; i++) {
for (size_type j=0; j<m; j++) {
C[i][j] = 0;
for (size_type k=0; k<n; k++)
C[i][j] += M[i][k]*(*this)[k][j];
}
}
return C;
}
//! Multiplies M from the right to this matrix
FieldMatrix& rightmultiply (const FieldMatrix<K,m,m>& M)
{
......@@ -499,6 +516,22 @@ namespace Dune {
return *this;
}
//! Multiplies M from the right to this matrix, this matrix is not modified
template<int l>
FieldMatrix<K,n,l> rightmultiplyany (const FieldMatrix<K,m,l>& M)
{
FieldMatrix<K,n,l> C;
for (size_type i=0; i<n; i++) {
for (size_type j=0; j<l; j++) {
C[i][j] = 0;
for (size_type k=0; k<m; k++)
C[i][j] += (*this)[i][k]*M[k][j];
}
}
return C;
}
//===== sizes
......
......@@ -228,6 +228,9 @@ int main()
test_matrix<double, 1, 1>();
test_matrix<int, 10, 5>();
test_matrix<double, 5, 10>();
Dune::FieldMatrix<double, 34, 34> A(1e-15);
for (int i=0; i<34; i++) A[i][i] = 1;
A.invert();
return test_invert_solve();
}
catch (Dune::Exception & e)
......
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