v0.13.1
Kronecker_Delta.hpp
Go to the documentation of this file.
1/**
2 * @file Kronecker_Delta.hpp
3 *
4 */
5
6#pragma once
7
8namespace FTensor {
9
10/**
11 * @brief Kronecker Delta class
12 *
13 * @tparam int
14 */
15template <class T = int> class Kronecker_Delta {
16public:
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 */
49template <class T = int> class Kronecker_Delta_symmetric {
50public:
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
79template <class T = int, char i, char j, int Dim0, int Dim1>
80Tensor2_Expr<Kronecker_Delta<T>, T, Dim0, Dim1, i, j>
83}
84
85template <class T = int, char i, int Dim0>
86constexpr auto kronecker_delta(const Index<i, Dim0> &, const int &N1) {
88}
89
90template <class T = int, char j, int Dim1>
91constexpr auto kronecker_delta(const int &N0, const Index<j, Dim1> &) {
93}
94
95template <class T = int, char i, char j, int Dim>
96Tensor2_symmetric_Expr<Kronecker_Delta_symmetric<T>, T, Dim, i, j>
99}
100
101template <class T = int, char i, int Dim0>
103 const int &N1) {
105}
106
107template <class T = int, char j, int Dim1>
108constexpr auto kronecker_delta_symmetric(const int &N0,
109 const Index<j, Dim1> &) {
111}
112
113} // namespace FTensor
static Number< 2 > N2
static Number< 1 > N1
static Number< 0 > N0
Kronecker Delta class symmetric.
constexpr auto operator()(const int &N0, const Index< j, Dim1 > &) const
Tensor2_symmetric_Expr< Kronecker_Delta_symmetric< T >, T, Dim, i, j > operator()(const Index< i, Dim > &, const Index< j, Dim > &) const
constexpr auto operator()(const Index< i, Dim0 > &, const int &N1) const
constexpr T operator()(const int N1, const int N2) const
Kronecker Delta class.
constexpr auto operator()(const Index< i, Dim0 > &, const int &N1) const
constexpr T operator()(const int N1, const int N2) const
Tensor2_Expr< Kronecker_Delta< T >, T, Dim0, Dim1, i, j > operator()(const Index< i, Dim0 > &, const Index< j, Dim1 > &) const
constexpr auto operator()(const int &N0, const Index< j, Dim1 > &) const
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
const double T
Tensors class implemented by Walter Landry.
Definition: FTensor.hpp:51
Tensor2_symmetric_Expr< Kronecker_Delta_symmetric< T >, T, Dim, i, j > kronecker_delta_symmetric(const Index< i, Dim > &, const Index< j, Dim > &)
Tensor2_Expr< Kronecker_Delta< T >, T, Dim0, Dim1, i, j > kronecker_delta(const Index< i, Dim0 > &, const Index< j, Dim1 > &)
Rank 2.