v0.6.9
Tensor3_dg_Expr.hpp
Go to the documentation of this file.
1 /* Declares a wrapper class for symmetric rank 3 Tensor expressions
2  that are symmetric on the first two indices. It is also used for
3  Tensor3_christof's but with some games played with the
4  indices. */
5 
18 #include "minus_Tensor3_dg.hpp"
19 
20 template<class A, class T, int Dim01, int Dim2, char i, char j, char k>
22 {
23  A iter;
24 public:
25  Tensor3_dg_Expr(A &a): iter(a) {}
26  T operator()(const int N1, const int N2, const int N3) const
27  {
28  return iter(N1,N2,N3);
29  }
30 };
31 
32 template<class A, class T, int Tensor_Dim01, int Tensor_Dim2,
33  int Dim01, int Dim2, char i, char j, char k>
34 class Tensor3_dg_Expr<Tensor3_dg<A,Tensor_Dim01,Tensor_Dim2>,T,Dim01,Dim2,i,j,k>
35 {
37 public:
39  T & operator()(const int N1, const int N2, const int N3)
40  {
41  return iter(N1,N2,N3);
42  }
43  T operator()(const int N1, const int N2, const int N3) const
44  {
45  return iter(N1,N2,N3);
46  }
47 
48  /* Various assignment operators. I have to explicitly declare the
49  second operator= because otherwise the compiler will generate its
50  own and not use the template code. */
51 
52  template<class B, class U> inline
54  operator=(const Tensor3_dg_Expr<B,U,Dim01,Dim2,i,j,k> &result);
55 
57  operator=(const Tensor3_dg_Expr<Tensor3_dg<A,Tensor_Dim01,Tensor_Dim2>,T,Dim01,Dim2,i,j,k> &result);
58 
59  template <class U> inline
61  operator=(const U &d);
62 };
63 
64 /* I need a version for const and non-const Tensor3_christof,
65  otherwise it will use the default and the index order will get all
66  messed up. The class A is either T or T*, depending on whether
67  Tensor3_christof has an array of T's or T *'s. */
68 
69 template<class A, class T, int Tensor_Dim0, int Tensor_Dim12,
70  int Dim12, int Dim0, char i, char j, char k>
71 class Tensor3_dg_Expr<const Tensor3_christof<A,Tensor_Dim0,Tensor_Dim12>,
72  T,Dim12,Dim0,i,j,k>
73 {
75 public:
77 
78  /* Need to switch the index order because a christof tensor is just
79  a dg tensor with the indices switched. */
80 
81  T operator()(const int N1, const int N2, const int N3) const
82  {
83  return iter(N3,N1,N2);
84  }
85 };
86 
87 template<class A, class T, int Tensor_Dim0, int Tensor_Dim12,
88  int Dim12, int Dim0, char i, char j, char k>
89 class Tensor3_dg_Expr<Tensor3_christof<A,Tensor_Dim0,Tensor_Dim12>,T,Dim12,Dim0,i,j,k>
90 {
92 public:
94 
95  /* Need to switch the index order because a christof tensor is just
96  a dg tensor with the indices switched. I have to explicitly
97  declare the second operator= because otherwise the compiler will
98  generate its own and not use the template code. */
99 
100  T operator()(const int N1, const int N2, const int N3) const
101  {
102  return iter(N3,N1,N2);
103  }
104  template<class B, class U> inline
106  operator=(const Tensor3_dg_Expr<B,U,Dim12,Dim0,i,j,k> &result);
107 
108  inline
111  T,Dim12,Dim0,i,j,k> &result);
112 
113  template<class U> inline
115  operator=(const U &d);
116 };
117 
118 /* Specialized for Tensor4_ddg_number_rhs_0 (Tensor4_ddg with the
119  first index explicitly given). */
120 
121 template<class A, class T, int Dim23, int Dim1, char i, char j, char k, int N0>
123  T,Dim23,Dim1,i,j,k>
124 {
125  A &iter;
126 public:
127  Tensor3_dg_Expr(A &a): iter(a) {}
128  T & operator()(const int N1, const int N2, const int N3)
129  {
130  return iter(N0,N1,N2,N3);
131  }
132  T operator()(const int N1, const int N2, const int N3) const
133  {
134  return iter(N0,N1,N2,N3);
135  }
136 
137  /* Various assignment operators. I have to explicitly declare the
138  second operator= because otherwise the compiler will generate its
139  own and not use the template code. */
140 
141  template<class B, class U>
143  T,Dim23,Dim1,i,j,k> &
144  operator=(const Tensor3_dg_Expr<B,U,Dim23,Dim1,i,j,k> &result);
145 
147  T,Dim23,Dim1,i,j,k> &
149  T,Dim23,Dim1,i,j,k> &result);
150 };
151 
T operator()(const int N1, const int N2, const int N3) const
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T *> &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:22