v0.9.2
Tensor3_contracted.hpp
Go to the documentation of this file.
1 /* A helper class that automatically returns the internal contraction
2  of a rank 3 tensor. */
3 
4 #pragma once
5 
6 namespace FTensor
7 {
8  /* Contracts second and third indices. */
9 
10  template <class A, class T, int Dim> class Tensor3_contracted_12
11  {
12  A iterA;
13 
14  template <int Current_Dim>
15  T eval(const int N, const Number<Current_Dim> &) const
16  {
17  return iterA(N, Current_Dim - 1, Current_Dim - 1)
19  }
20  T eval(const int N, const Number<1> &) const { return iterA(N, 0, 0); }
21 
22  public:
23  T operator()(const int N) const { return eval(N, Number<Dim>()); }
24  Tensor3_contracted_12(const A &a) : iterA(a) {}
25  };
26 
27  /* Contracts first and third indices. */
28 
29  template <class A, class T, int Dim> class Tensor3_contracted_02
30  {
31  A iterA;
32 
33  template <int Current_Dim>
34  T eval(const int N, const Number<Current_Dim> &) const
35  {
36  return iterA(Current_Dim - 1, N, Current_Dim - 1)
38  }
39  T eval(const int N, const Number<1> &) const { return iterA(0, N, 0); }
40 
41  public:
42  T operator()(const int N) const { return eval(N, Number<Dim>()); }
43  Tensor3_contracted_02(const A &a) : iterA(a) {}
44  };
45 
46  /* Contracts first and second indices. */
47 
48  template <class A, class T, int Dim> class Tensor3_contracted_01
49  {
50  A iterA;
51 
52  template <int Current_Dim>
53  T eval(const int N, const Number<Current_Dim> &) const
54  {
55  return iterA(Current_Dim - 1, Current_Dim - 1, N)
57  }
58  T eval(const int N, const Number<1> &) const { return iterA(0, 0, N); }
59 
60  public:
61  T operator()(const int N) const { return eval(N, Number<Dim>()); }
62  Tensor3_contracted_01(const A &a) : iterA(a) {}
63  };
64 }
T eval(const int N, const Number< 1 > &) const
JSON compatible output.
T eval(const int N, const Number< 1 > &) const
T eval(const int N, const Number< Current_Dim > &) const
T eval(const int N, const Number< Current_Dim > &) const
T eval(const int N, const Number< Current_Dim > &) const
T eval(const int N, const Number< 1 > &) const
const int N
Definition: speed_test.cpp:3