Skip to content
Snippets Groups Projects
Commit 4773d50a authored by Oliver Sander's avatar Oliver Sander
Browse files

Copy the test for DiagonalMatrix from dune-istl to here

[[Imported from SVN: r6997]]
parent a11d8fa5
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ Makefile.in
.deps
.libs
semantic.cache
diagonalmatrixtest
dynvectortest
fvectortest
mpicollectivecommunication
......
......@@ -8,6 +8,7 @@ TESTPROGS = \
bitsetvectortest \
check_fvector_size \
conversiontest \
diagonalmatrixtest \
dynmatrixtest \
dynvectortest \
enumsettest \
......@@ -98,6 +99,8 @@ parametertreetest_SOURCES = parametertreetest.cc
bitsetvectortest_SOURCES = bitsetvectortest.cc
diagonalmatrixtest_SOURCES = diagonalmatrixtest.cc
nullptr_test_SOURCES = nullptr-test.cc nullptr-test2.cc
nullptr_test_fail_SOURCES = nullptr-test.cc
nullptr_test_fail_CPPFLAGS = $(AM_CPPFLAGS) -DFAIL
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include "config.h"
#include <dune/common/diagonalmatrix.hh>
#include <iostream>
#include <algorithm>
#include <dune/common/fvector.hh>
#include <dune/common/exceptions.hh>
using namespace Dune;
template<class K, int n>
void test_matrix()
{
typedef typename DiagonalMatrix<K,n>::size_type size_type;
DiagonalMatrix<K,n> A(1);
FieldVector<K,n> f;
FieldVector<K,n> v;
// assign matrix
A=2;
// assign vector
f = 1;
v = 2;
// matrix vector product
A.umv(v,f);
// test norms
A.frobenius_norm();
A.frobenius_norm2();
A.infinity_norm();
A.infinity_norm_real();
std::sort(v.begin(), v.end());
// print matrix
std::cout << A << std::endl;
// print vector
std::cout << f << std::endl;
// assign to FieldMatrix
FieldMatrix<K,n,n> AFM = FieldMatrix<K,n,n>(A);
}
int main()
{
try {
test_matrix<float, 1>();
test_matrix<double, 1>();
test_matrix<double, 5>();
}
catch (Dune::Exception & e)
{
std::cerr << "Exception: " << e << std::endl;
}
}
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