RFFGen
 All Classes Namespaces Files Functions Typedefs Enumerations Groups
deviator.hh
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the C++-library RFFGen. */
4 /* Copyright 2015 Lars Lubkoll */
5 /* */
6 /* RFFGen is free software: you can redistribute it and/or modify */
7 /* it under the terms of the GNU General Public License as published by */
8 /* the Free Software Foundation, either version 3 of the License, or */
9 /* (at your option) any later version. */
10 /* */
11 /* RFFGen is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with RFFGen. If not, see <http://www.gnu.org/licenses/>. */
18 /* */
19 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20 
21 #ifndef RFFGEN_LINEAR_ALGEBRA_DEVIATOR_HH
22 #define RFFGEN_LINEAR_ALGEBRA_DEVIATOR_HH
23 
24 #include "../generate.hh"
25 #include "../identity.hh"
26 #include "trace.hh"
27 #include "unitMatrix.hh"
28 
29 namespace RFFGen
30 {
34  namespace Concepts { template <class> struct SymmetricMatrixConceptChecks; }
39  namespace LinearAlgebra
40  {
45  template <class Matrix, class = Concepts::SymmetricMatrixConceptCheck<Matrix>>
46  auto deviator(const Matrix& A)
47  {
48  return Identity<Matrix>(A) + (-1./dimension<Matrix>()) * ( trace(A) * Constant<Matrix>( unitMatrix<Matrix>() ) );
49  }
50 
55  template <class Matrix>
56  class Deviator : public decltype( deviator( std::declval<Matrix>() ) )
57  {
58  private:
59  using Base = decltype( deviator( std::declval<Matrix>() ) );
60  public:
61  Deviator() = default;
62  Deviator(const Matrix& A) : Base( deviator(A) )
63  {}
64  };
65  }
66 }
67 
68 #endif // RFFGEN_LINEAR_ALGEBRA_DEVIATOR_HH
auto trace(const Arg &arg)
Convenient generation of Trace<Matrix>.
Definition: trace.hh:250
auto deviator(const Matrix &A)
Deviator of a matrix , i.e. .
Definition: deviator.hh:46
Identity mapping .
Definition: identity.hh:39
Type of the deviator of a matrix , i.e. .
Definition: deviator.hh:56
Wrap a constant.
Definition: constant.hh:41