AMDiS  0.3
The Adaptive Multi-Dimensional Simulation Toolbox
Operations.hpp
1 #pragma once
2 
3 #include <amdis/linearalgebra/istl/MatrixBackend.hpp>
4 #include <amdis/linearalgebra/istl/VectorBackend.hpp>
5 
6 namespace AMDiS {
7 
8  // ||b - A*x||
9  template <class T1, class C1, class T2, class T3>
10  auto residuum(ISTLBCRSMatrix<T1,C1> const& A, ISTLBlockVector<T2> const& x, ISTLBlockVector<T3> const& b)
11  {
12  auto r = b.vector();
13  A.matrix().mmv(x.vector(), r);
14  return r.two_norm();
15  }
16 
17  // ||b - A*x|| / ||b||
18  template <class T1, class C1, class T2, class T3>
19  auto relResiduum(ISTLBCRSMatrix<T1,C1> const& A, ISTLBlockVector<T2> const& x, ISTLBlockVector<T3> const& b)
20  {
21  return residuum(A,x,b) / b.vector().two_norm();
22  }
23 
24 } // end namespace AMDiS
Definition: AdaptBase.hpp:6