Skip to content
Snippets Groups Projects
Commit 2066c358 authored by Robert Klöfkorn's avatar Robert Klöfkorn
Browse files

check FieldMatrix with n=m=1 and vectors different from FieldVector.

[[Imported from SVN: r5913]]
parent cb9a5d98
Branches
Tags
No related merge requests found
......@@ -7,6 +7,7 @@
#include "../fmatrix.hh"
#include <iostream>
#include <algorithm>
#include <vector>
using namespace Dune;
......@@ -139,6 +140,25 @@ int test_invert_solve()
return ret + test_invert_solve<double,3>(A_data2, inv_data2, x2, b2);
}
template<class K, int n, int m, class X, class Y>
void test_mult(FieldMatrix<K, n, m>& A,
const X& v, Y& f)
{
// test the various matrix-vector products
A.mv(v,f);
A.mtv(v,f);
A.umv(v,f);
A.umtv(v,f);
A.umhv(v,f);
A.mmv(v,f);
A.mmtv(v,f);
A.mmhv(v,f);
A.usmv(0.5,v,f);
A.usmtv(0.5,v,f);
A.usmhv(0.5,v,f);
}
template<class K, int n, int m>
void test_matrix()
{
......@@ -211,19 +231,23 @@ void test_matrix()
}
}
// test the various matrix-vector products
A.mv(v,f);
A.mtv(v,f);
A.umv(v,f);
A.umtv(v,f);
A.umhv(v,f);
A.mmv(v,f);
A.mmtv(v,f);
A.mmhv(v,f);
A.usmv(0.5,v,f);
A.usmtv(0.5,v,f);
A.usmhv(0.5,v,f);
test_mult(A, v, f );
{
std::vector<K> v1( n ) ;
std::vector<K> f1( m, 1 ) ;
// random access vector
for (size_type i=0; i<n; i++) v1[i] = i;
test_mult(A, v1, f1 );
}
{
K v2[ n ];
K f2[ m ];
// random access vector
for (size_type i=0; i<n; i++) v2[i] = i;
for (size_type i=0; i<m; i++) f2[i] = 1;
test_mult(A, v2, f2 );
}
// Test the different matrix norms
assert( A.frobenius_norm() >= 0 );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment