Skip to content
Snippets Groups Projects
Commit 157c684f authored by Christoph Gersbacher's avatar Christoph Gersbacher
Browse files

Interface check for DiagonalMatrix + minor fixes.

[[Imported from SVN: r7103]]
parent f17471bf
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,8 @@ namespace Dune { ...@@ -50,7 +50,8 @@ namespace Dune {
//===== type definitions and constants //===== type definitions and constants
//! export the type representing the field //! export the type representing the field
typedef K field_type; typedef K value_type;
typedef value_type field_type;
//! export the type representing the components //! export the type representing the components
typedef K block_type; typedef K block_type;
...@@ -67,8 +68,10 @@ namespace Dune { ...@@ -67,8 +68,10 @@ namespace Dune {
//! Each row is implemented by a field vector //! Each row is implemented by a field vector
typedef DiagonalRowVector<K,n> row_type; typedef DiagonalRowVector<K,n> row_type;
typedef row_type reference; typedef row_type reference;
typedef row_type row_reference;
typedef DiagonalRowVectorConst<K,n> const_row_type; typedef DiagonalRowVectorConst<K,n> const_row_type;
typedef const_row_type const_reference; typedef const_row_type const_reference;
typedef const_row_type const_row_reference;
//! export size //! export size
enum { enum {
...@@ -78,7 +81,12 @@ namespace Dune { ...@@ -78,7 +81,12 @@ namespace Dune {
cols = n cols = n
}; };
//==== size
size_type size () const
{
return rows;
}
//===== constructors //===== constructors
......
...@@ -10,9 +10,36 @@ ...@@ -10,9 +10,36 @@
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/exceptions.hh> #include <dune/common/exceptions.hh>
#include "checkmatrixinterface.hh"
using namespace Dune; using namespace Dune;
namespace CheckMatrixInterface
{
namespace Capabilities
{
template< class K, int n >
struct hasStaticSizes< Dune::DiagonalMatrix<K,n> >
{
static const bool v = true;
static const int rows = n;
static const int cols = n;
};
template< class K, int n >
struct isRegular< Dune::DiagonalMatrix<K,n> >
{
static const bool v = true;
};
} // namespace Capabilities
} // namespace CheckMatrixInterface
template<class K, int n> template<class K, int n>
void test_matrix() void test_matrix()
{ {
...@@ -50,12 +77,26 @@ void test_matrix() ...@@ -50,12 +77,26 @@ void test_matrix()
DUNE_UNUSED FieldMatrix<K,n,n> AFM = FieldMatrix<K,n,n>(A); DUNE_UNUSED FieldMatrix<K,n,n> AFM = FieldMatrix<K,n,n>(A);
} }
template<class K, int n>
void test_interface()
{
typedef CheckMatrixInterface::UseFieldVector<K,n,n> Traits;
typedef Dune::DiagonalMatrix<K,n> DiagonalMatrix;
const DiagonalMatrix A(1);
checkMatrixInterface< DiagonalMatrix >( A );
checkMatrixInterface< DiagonalMatrix, Traits >( A );
}
int main() int main()
{ {
try { try {
test_matrix<float, 1>(); test_matrix<float, 1>();
test_interface<float, 1>();
test_matrix<double, 1>(); test_matrix<double, 1>();
test_interface<double, 1>();
test_matrix<double, 5>(); test_matrix<double, 5>();
test_interface<double, 5>();
} }
catch (Dune::Exception & e) 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