Skip to content
Snippets Groups Projects
Commit e56fd02e authored by Felix Schindler's avatar Felix Schindler
Browse files

[common.fmatrix] added specialization for 1x1

This allows a 1x1 matrix to be constructed from a 1d vector
parent 1eb4d87f
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,65 @@ public:
}; // class FieldMatrix
template <class K>
class FieldMatrix<K, 1, 1> : public Dune::FieldMatrix<K, 1, 1>
{
static const int ROWS = 1;
static const int COLS = 1;
typedef Dune::FieldMatrix<K, ROWS, COLS> BaseType;
typedef FieldMatrix<K, ROWS, COLS> ThisType;
public:
FieldMatrix(const size_t rr, const size_t cc, const K kk = K(0))
: BaseType(kk)
{
if (rr != ROWS || cc != COLS)
DUNE_THROW_COLORFULLY(Exceptions::wrong_input_given,
"You are trying to construct a FieldMatrix< ..., " << ROWS << ", " << COLS << " > (of "
<< "static size) with "
<< rr
<< " rows and "
<< cc
<< " columns!");
} // ... FieldMatrix(...)
FieldMatrix(const BaseType& other)
: BaseType(other)
{
}
FieldMatrix(const FieldVector<K, 1>& other)
: BaseType(other[0])
{
}
ThisType& operator=(const BaseType& other)
{
return BaseType::operator=(other);
}
ThisType& operator=(const FieldVector<K, 1>& other)
{
return BaseType::operator=(other[0]);
}
FieldVector<K, ROWS> operator*(const FieldVector<K, COLS>& vec) const
{
FieldVector<K, ROWS> ret;
this->mv(vec, ret);
return ret;
} // ... operator*(...)
ThisType operator*(const K& scal) const
{
ThisType ret(*this);
ret *= scal;
return ret;
} // ... operator*(...)
}; // class FieldMatrix
} // namespace Common
} // namespace Stuff
} // namespace Dune
......
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