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