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

Add interface check for FieldMatrix and DynamicMatrix.

[[Imported from SVN: r7102]]
parent 9b2a5671
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,8 @@
#include <algorithm>
#include <vector>
#include "checkmatrixinterface.hh"
using namespace Dune;
template<typename T, std::size_t n>
......@@ -386,14 +388,17 @@ int test_determinant()
int main()
{
try {
Dune::DynamicMatrix<double> A( 5, 5 );
checkMatrixInterface( A );
test_matrix<float, 1, 1>();
test_matrix<double, 1, 1>();
test_matrix<int, 10, 5>();
test_matrix<double, 5, 10>();
test_determinant();
Dune::DynamicMatrix<double> A(34, 34, 1e-15);
for (int i=0; i<34; i++) A[i][i] = 1;
A.invert();
Dune::DynamicMatrix<double> B(34, 34, 1e-15);
for (int i=0; i<34; i++) B[i][i] = 1;
B.invert();
return test_invert_solve();
}
catch (Dune::Exception & e)
......
......@@ -16,8 +16,34 @@
#include <cassert>
#include <complex>
#include "checkmatrixinterface.hh"
using namespace Dune;
namespace CheckMatrixInterface
{
namespace Capabilities
{
template< class K, int r, int c >
struct hasStaticSizes< Dune::FieldMatrix< K, r, c > >
{
static const bool v = true;
static const int rows = r;
static const int cols = c;
};
template< class K, int rows, int cols >
struct isRegular< Dune::FieldMatrix< K, rows, cols > >
{
static const bool v = ( rows == cols );
};
} // namespace Capabilities
} // namespace CheckMatrixInterface
template<typename T, std::size_t n>
int test_invert_solve(T A_data[n*n], T inv_data[n*n],
T x_data[n], T b_data[n])
......@@ -539,6 +565,18 @@ test_infinity_norms()
assert(std::abs(m.infinity_norm_real()-28.0) < 1e-10); // max(7+7, 14+14)
}
template< class K, int rows, int cols >
void test_interface()
{
typedef CheckMatrixInterface::UseFieldVector< K, rows, cols > Traits;
typedef Dune::FieldMatrix< K, rows, cols > FMatrix;
FMatrix m;
checkMatrixInterface< FMatrix >( m );
checkMatrixInterface< FMatrix, Traits >( m );
}
int main()
{
try {
......@@ -546,13 +584,16 @@ int main()
test_infinity_norms();
// test 1 x 1 matrices
test_interface<float, 1, 1>();
test_matrix<float, 1, 1>();
ScalarOperatorTest<float>();
test_matrix<double, 1, 1>();
ScalarOperatorTest<double>();
// test n x m matrices
test_interface<int, 10, 5>();
test_matrix<int, 10, 5>();
test_matrix<double, 5, 10>();
test_interface<double, 5, 10>();
// test complex matrices
test_matrix<std::complex<float>, 1, 1>();
test_matrix<std::complex<double>, 5, 10>();
......
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