v0.10.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) {
88 }
89 
90 template <class T = int, char j, int Dim1>
91 constexpr auto kronecker_delta(const int &N0, const 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
const double T
Kronecker Delta class.
constexpr auto operator()(const int &N0, const Index< j, Dim1 > &) const
constexpr T operator()(const int N1, const int N2) const
JSON compatible output.
Kronecker Delta class symmetric.
constexpr auto operator()(const Index< i, Dim0 > &, const int &N1) const
Tensor2_symmetric_Expr< Kronecker_Delta_symmetric< T >, T, Dim, i, j > kronecker_delta_symmetric(const Index< i, Dim > &, const Index< j, Dim > &)
Tensor2_symmetric_Expr< Kronecker_Delta_symmetric< T >, T, Dim, i, j > operator()(const Index< i, Dim > &, const Index< j, Dim > &) const
static Index< 'i', 3 > i
static Number< 2 > N2
static Index< 'j', 3 > j
constexpr T operator()(const int N1, const int N2) const
static Number< 1 > N1
Tensor2_Expr< Kronecker_Delta< T >, T, Dim0, Dim1, i, j > operator()(const Index< i, Dim0 > &, const Index< j, Dim1 > &) const
constexpr auto operator()(const Index< i, Dim0 > &, const int &N1) const
Tensor2_Expr< Kronecker_Delta< T >, T, Dim0, Dim1, i, j > kronecker_delta(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
Rank 2.
static Number< 0 > N0
constexpr auto operator()(const int &N0, const Index< j, Dim1 > &) const