Debian Codegraph @

dune/istl/test/bcrsmatrixtest.cc

raw
1 // SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
2 // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
3 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
4 // vi: set et ts=4 sw=2 sts=2:
5
6 #include <dune/common/fmatrix.hh>
7 #include <dune/common/fvector.hh>
8 #include <dune/common/float_cmp.hh>
9
10 #include <dune/istl/bvector.hh>
11 #include <dune/istl/test/laplacian.hh>
12 #include <dune/istl/test/matrixtest.hh>
13
14 using namespace Dune;
15
16 template <class Matrix, class Vector>
17 int testBCRSMatrix(int size)
18 {
19 // Set up a test matrix
20 Matrix mat;
21 setupLaplacian(mat, size);
22
23 // Test vector space operations
24 testVectorSpaceOperations(mat);
25
26 // Test the matrix norms
27 testNorms(mat);
28
29 // Test whether matrix class has the required constructors
30 testMatrixConstructibility<Matrix>();
31
32 // Test the matrix vector products
33 Vector domain(mat.M());
34 domain = 0;
35 Vector range(mat.N());
36
37 testMatrixVectorProducts(mat,domain,range);
38
39 return 0;
40 }
41
42 int main(int argc, char** argv)
43 {
44 // Test scalar matrices and vectors
45 int ret = testBCRSMatrix<BCRSMatrix<double>, BlockVector<double> >(10);
46
47 // Test block matrices and vectors with trivial blocks
48 ret = testBCRSMatrix<BCRSMatrix<FieldMatrix<double,1,1> >, BlockVector<FieldVector<double,1> > >(10);
49
50 return ret;
51 }