Skip to content
Snippets Groups Projects
Commit a48c33a5 authored by Elias Pipping's avatar Elias Pipping Committed by Christoph Grüninger
Browse files

Remove conversion operator

A FieldMatrix can still have a DiagonalMatrix assigned to it through the
new DenseMatrixAssigner specialisation. The restriction from general
DenseMatrix implementations to the FieldMatrix class is removed in the
process.
parent 1d7528ea
No related branches found
No related tags found
No related merge requests found
#ifndef DUNE_COMMON_IDENTITYMATRIX_HH
#define DUNE_COMMON_IDENTITYMATRIX_HH
#include <dune/common/boundschecking.hh>
#include <dune/common/fmatrix.hh>
#include <dune/common/ftraits.hh>
#include <dune/common/math.hh>
......@@ -146,17 +147,18 @@ namespace Dune
{
return FieldTraits< field_type >::real_type( 1 );
}
};
/** \brief cast to FieldMatrix */
operator FieldMatrix< field_type, N, N > () const
{
FieldMatrix< field_type, N, N > fieldMatrix( 0 );
for( int i = 0; i < N; ++i )
fieldMatrix[ i ][ i ] = field_type( 1 );
return fieldMatrix;
template <class DenseMatrix, class field, int N>
struct DenseMatrixAssigner<DenseMatrix, IdentityMatrix<field, N>> {
static void apply(DenseMatrix &denseMatrix, IdentityMatrix<field, N> const &rhs) {
DUNE_ASSERT_BOUNDS(denseMatrix.M() == N);
DUNE_ASSERT_BOUNDS(denseMatrix.N() == N);
denseMatrix = field(0);
for (int i = 0; i < N; ++i)
denseMatrix[i][i] = field(1);
}
};
} // namespace Dune
#endif // #ifndef DUNE_COMMON_IDENTITYMATRIX_HH
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