v0.16.0
Loading...
Searching...
No Matches
DiffSymmetrize.hpp
Go to the documentation of this file.
1/**
2 * @file DiffSymmetrize.hpp
3 *
4 */
5
6#pragma once
7
8namespace FTensor {
9
10/**
11 * @brief Fourth-order symmetrization tensor
12 *
13 * @tparam T
14 */
15template <class T = int> class DiffSymmetrize {
16public:
18
19 constexpr value_type operator()(const int N0, const int N1, const int N2,
20 const int N3) const {
21 const auto first =
22 (N0 == N2 && N1 == N3) ? value_type(1) : value_type(0);
23 const auto second =
24 (N0 == N3 && N1 == N2) ? value_type(1) : value_type(0);
25 return (first + second) / value_type(2);
26 }
27
28 template <char i, char j, char k, char l, int Dim0, int Dim1, int Dim2,
29 int Dim3>
30 Tensor4_Expr<DiffSymmetrize<T>, value_type, Dim0, Dim1, Dim2, Dim3, i, j, k,
31 l>
33 const Index<k, Dim2> &, const Index<l, Dim3> &) const {
34 return Tensor4_Expr<DiffSymmetrize<T>, value_type, Dim0, Dim1, Dim2, Dim3,
35 i, j, k, l>(*this);
36 };
37};
38
39template <class T = int> constexpr auto diff_symmetrize() {
40 return DiffSymmetrize<T>();
41}
42
43template <class T = int, char i, char j, char k, char l, int Dim0, int Dim1,
44 int Dim2, int Dim3>
45Tensor4_Expr<DiffSymmetrize<T>, typename DiffSymmetrize<T>::value_type, Dim0,
46 Dim1, Dim2, Dim3, i, j, k, l>
52
53} // namespace FTensor
Fourth-order symmetrization tensor.
Tensor4_Expr< DiffSymmetrize< T >, value_type, Dim0, Dim1, Dim2, Dim3, i, j, k, l > operator()(const Index< i, Dim0 > &, const Index< j, Dim1 > &, const Index< k, Dim2 > &, const Index< l, Dim3 > &) const
constexpr value_type operator()(const int N0, const int N1, const int N2, const int N3) const
typename promote< T, double >::V value_type
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
Tensors class implemented by Walter Landry.
Definition FTensor.hpp:51
constexpr auto diff_symmetrize()