MultiTypeMatrixTest.cpp 1.09 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <dune/amdis/common/FieldMatVec.hpp>
#include <dune/amdis/common/MultiTypeMatrix.hpp>

using namespace AMDiS;

int main()
{
  using V0 = MultiTypeVector<FieldMatrix<double,2,2>, FieldMatrix<double,2,3>>;
  using V1 = MultiTypeVector<FieldMatrix<double,3,2>, FieldMatrix<double,3,3>>;
  using M = MultiTypeMatrix<V0, V1>;

  // constructors
  M m0{}; // default constructor

  V0 v0{};
  V1 v1{};

  M m1{v0,v1}; // constructor with Vi arguments
  M m2{m1}; // copy constructor
  m0 = m1; // copy assignment

  M m3{0.0}; // construction from constant
  m3 = 1.0; // assignment of constant

  {
    M m0_tmp;
    M m1_tmp{std::move(m0_tmp)}; // move constructor
    m1 = std::move(m1_tmp); // move assignment
  }

  using namespace Dune::Indices;

  // element access
  DUNE_UNUSED auto fm0 = m1(_0,_0); // const block access
  DUNE_UNUSED auto fm1 = m1[_1][_1]; // const block access
  m2(_0,_0) = fm0; // mutable block access
  m2[_1][_1] = fm1; // mutable block access

  DUNE_UNUSED double x = m2(_0,_0)[1][1];  // const access

  // compound assignment operators
  m1 += m2;
  m1 *= 2.0;
  m1 /= 2.0;

}