v0.14.0
Kronecker_Delta.hpp
Go to the documentation of this file.
1 /**
2  * @file Kronecker_Delta.hpp
3  *
4  */
5 
6 #pragma once
7 
8 namespace FTensor {
9 
10 /**
11  * @brief Kronecker Delta class
12  *
13  * @tparam int
14  */
15 template <class T = int> class Kronecker_Delta {
16 public:
17  constexpr T operator()(const int N1, const int N2) const {
18  return (N1 == N2) ? T(1) : T(0);
19  }
20 
21  template <char i, char j, int Dim0, int Dim1>
22  Tensor2_Expr<Kronecker_Delta<T>, T, Dim0, Dim1, i, j>
23  operator()(const Index<i, Dim0> &, const Index<j, Dim1> &) const {
24  return Tensor2_Expr<Kronecker_Delta<T>, T, Dim0, Dim1, i, j>(*this);
25  };
26 
27  template <char i, int Dim0>
28  constexpr auto operator()(const Index<i, Dim0> &, const int &N1) const {
29  auto TensorExpr = [this, N1](const int &N0) {
30  return this->operator()(N0, N1);
31  };
33  };
34 
35  template <char j, int Dim1>
36  constexpr auto operator()(const int &N0, const Index<j, Dim1> &) const {
37  auto TensorExpr = [this, N0](const int &N1) {
38  return this->operator()(N0, N1);
39  };
40  return Tensor1_Expr<decltype(TensorExpr), T, Dim1, j>{TensorExpr};
41  };
42 };
43 
44 /**
45  * @brief Kronecker Delta class symmetric
46  *
47  * @tparam int
48  */
49 template <class T = int> class Kronecker_Delta_symmetric {
50 public:
51  constexpr T operator()(const int N1, const int N2) const {
52  return (N1 == N2) ? T(1) : T(0);
53  }
54 
55  template <char i, char j, int Dim>
57  operator()(const Index<i, Dim> &, const Index<j, Dim> &) const {
59  };
60 
61  template <char i, int Dim0>
62  constexpr auto operator()(const Index<i, Dim0> &, const int &N1) const {
63  auto TensorExpr = [this, N1](const int &N0) {
64  return this->operator()(N0, N1);
65  };
67  };
68 
69  template <char j, int Dim1>
70  constexpr auto operator()(const int &N0, const Index<j, Dim1> &) const {
71  auto TensorExpr = [this, N0](const int &N1) {
72  return this->operator()(N0, N1);
73  };
74  return Tensor1_Expr<decltype(TensorExpr), T, Dim1, j>{TensorExpr};
75  };
76 };
77 
78 /// Rank 2
79 template <class T = int, char i, char j, int Dim0, int Dim1>
80 Tensor2_Expr<Kronecker_Delta<T>, T, Dim0, Dim1, i, j>
83 }
84 
85 template <class T = int, char i, int Dim0>
86 constexpr auto kronecker_delta(const Index<i, Dim0> &, const int &N1) {
87  return Kronecker_Delta<T>()(Index<i, Dim0>(), N1);
88 }
89 
90 template <class T = int, char j, int Dim1>
91 constexpr auto kronecker_delta(const int &N0, const Index<j, Dim1> &) {
92  return Kronecker_Delta<T>()(N0, Index<j, Dim1>());
93 }
94 
95 template <class T = int, char i, char j, int Dim>
96 Tensor2_symmetric_Expr<Kronecker_Delta_symmetric<T>, T, Dim, i, j>
99 }
100 
101 template <class T = int, char i, int Dim0>
103  const int &N1) {
105 }
106 
107 template <class T = int, char j, int Dim1>
108 constexpr auto kronecker_delta_symmetric(const int &N0,
109  const Index<j, Dim1> &) {
111 }
112 
113 } // namespace FTensor
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::Tensor2_symmetric_Expr
Definition: Tensor2_symmetric_Expr.hpp:36
FTensor::Kronecker_Delta_symmetric::operator()
constexpr auto operator()(const int &N0, const Index< j, Dim1 > &) const
Definition: Kronecker_Delta.hpp:70
FTensor::Tensor2_Expr
Definition: Tensor2_Expr.hpp:26
FTensor::Kronecker_Delta
Kronecker Delta class.
Definition: Kronecker_Delta.hpp:15
FTensor::Kronecker_Delta_symmetric::operator()
Tensor2_symmetric_Expr< Kronecker_Delta_symmetric< T >, T, Dim, i, j > operator()(const Index< i, Dim > &, const Index< j, Dim > &) const
Definition: Kronecker_Delta.hpp:57
FTensor::Tensor1_Expr
Definition: Tensor1_Expr.hpp:27
FTensor::Kronecker_Delta::operator()
constexpr auto operator()(const int &N0, const Index< j, Dim1 > &) const
Definition: Kronecker_Delta.hpp:36
FTensor::Kronecker_Delta::operator()
Tensor2_Expr< Kronecker_Delta< T >, T, Dim0, Dim1, i, j > operator()(const Index< i, Dim0 > &, const Index< j, Dim1 > &) const
Definition: Kronecker_Delta.hpp:23
FTensor::Kronecker_Delta::operator()
constexpr T operator()(const int N1, const int N2) const
Definition: Kronecker_Delta.hpp:17
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::Index
Definition: Index.hpp:23
FTensor::kronecker_delta_symmetric
Tensor2_symmetric_Expr< Kronecker_Delta_symmetric< T >, T, Dim, i, j > kronecker_delta_symmetric(const Index< i, Dim > &, const Index< j, Dim > &)
Definition: Kronecker_Delta.hpp:97
FTensor::kronecker_delta
Tensor2_Expr< Kronecker_Delta< T >, T, Dim0, Dim1, i, j > kronecker_delta(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
Rank 2.
Definition: Kronecker_Delta.hpp:81
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::Kronecker_Delta_symmetric::operator()
constexpr auto operator()(const Index< i, Dim0 > &, const int &N1) const
Definition: Kronecker_Delta.hpp:62
FTensor::Kronecker_Delta_symmetric::operator()
constexpr T operator()(const int N1, const int N2) const
Definition: Kronecker_Delta.hpp:51
FTensor::Kronecker_Delta_symmetric
Kronecker Delta class symmetric.
Definition: Kronecker_Delta.hpp:49
FTensor::Kronecker_Delta::operator()
constexpr auto operator()(const Index< i, Dim0 > &, const int &N1) const
Definition: Kronecker_Delta.hpp:28