Commit 0fa536e5 authored by Elias Pipping's avatar Elias Pipping

Static size checks for FieldMatrix::rightmultiply

Previously, the following piece of code would compile and only
only predictable fail at runtime with assertions enabled.

  Dune::FieldMatrix<double, 2, 3> A;
  // populate A

  Dune::FieldMatrix<double, 3, 2> B_bad;
  // populate B_bad
  A.rightmultiply(B_bad);

It now fails to compile.
parent db1f4459
......@@ -137,8 +137,11 @@ namespace Dune
using Base::rightmultiply;
//! Multiplies M from the right to this matrix
FieldMatrix& rightmultiply (const FieldMatrix<K,cols,cols>& M)
template <int r, int c>
FieldMatrix& rightmultiply (const FieldMatrix<K,r,c>& M)
{
static_assert(r == c, "Cannot rightmultiply with non-square matrix");
static_assert(r == cols, "Size mismatch");
FieldMatrix<K,rows,cols> C(*this);
for (size_type i=0; i<rows; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment