v0.8.4
Tensor2_symmetric_Expr.hpp
Go to the documentation of this file.
1 /* Declares a wrapper class for symmetric rank 2 Tensor expressions.
2  It is specialized for Tensor3_number_rhs_2. Note that
3  Tensor2_symmetric_Expr_equals.hpp is included at the end, because it
4  needs the definition of Tensor2_symmetric_Expr. */
5 
6 #pragma once
7 
22 #include "dTensor2_symmetric.hpp"
25 #include "ddTensor2_symmetric.hpp"
31 
32 namespace FTensor
33 {
34  template <class A, class T, int Dim, char i, char j>
36  {
37  A iter;
38 
39  public:
40  Tensor2_symmetric_Expr(const A &a) : iter(a) {}
41  T operator()(const int N1, const int N2) const { return iter(N1, N2); }
42  };
43 
44  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
45  class Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>
46  {
48 
49  public:
51  T &operator()(const int N1, const int N2) { return iter(N1, N2); }
52  T operator()(const int N1, const int N2) const { return iter(N1, N2); }
53 
54  /* Various assignment operators. I have to explicitly declare the
55  second operator= because otherwise the compiler will generate its
56  own and not use the template code. */
57 
58  template <class B, class U>
60  j> &
61  operator=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
62 
64  j> &
66  Dim, i, j> &result);
67 
68  template <class B, class U>
70  j> &
71  operator+=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
72 
73  template <class B, class U>
75  j> &
76  operator-=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
77 
78  template <class B, class U>
80  j> &
81  operator&=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
82 
83  /* This is for when the indices are switched (i,j) -> (j,i). */
84 
85  template <class B, class U>
87  j> &
88  operator=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
89 
90  template <class B, class U>
92  j> &
93  operator+=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
94 
95  template <class B, class U>
97  j> &
98  operator-=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
99 
100  /* Operations with just generics. */
101 
102  template <class U>
104  j> &
105  operator=(const U &d);
106  template <class U>
108  j> &
109  operator+=(const U &d);
110  template <class U>
112  j> &
113  operator-=(const U &d);
114  template <class U>
116  j> &
117  operator*=(const U &d);
118  template <class U>
120  j> &
121  operator/=(const U &d);
122  /* ADOL-C operators. */
123 
124  template <class B, class U>
126  j> &
127  operator<<=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
128 
130  j> &
131  operator<<=(const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>,
132  T, Dim, i, j> &result);
133 
134  template <class B, class U>
136  Dim, i, j> &
137  operator<<=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
138 
139  template <class U>
141  Dim, i, j> &
142  operator<<=(const U &d);
143  };
144 
145  /* Specialized for Dg_number_rhs_2 (Dg with the
146  second index explicitly given). */
147 
148  template <class A, class T, int Dim, char i, char j, int N>
149  class Tensor2_symmetric_Expr<Dg_number_rhs_2<A, T, N>, T, Dim, i, j>
150  {
151  A &iter;
152 
153  public:
154  Tensor2_symmetric_Expr(A &a) : iter(a) {}
155  T &operator()(const int N1, const int N2) { return iter(N1, N2, N); }
156  T operator()(const int N1, const int N2) const { return iter(N1, N2, N); }
157 
158  /* Various assignment operators. I have to explicitly declare the
159  second operator= because otherwise the compiler will generate its
160  own and not use the template code. */
161 
162  template <class B, class U>
164  operator=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
165 
167  operator=(const Tensor2_symmetric_Expr<Dg_number_rhs_2<A, T, N>, T, Dim, i,
168  j> &result);
169  };
170 
171  /* Specialized for Ddg_number_rhs_01 (Ddg with the
172  first and second index explicitly given). */
173 
174  template <class A, class T, int Dim, char i, char j, int N0, int N1>
175  class Tensor2_symmetric_Expr<Ddg_number_rhs_01<A, T, N0, N1>, T, Dim, i, j>
176  {
177  A &iter;
178 
179  public:
180  Tensor2_symmetric_Expr(A &a) : iter(a) {}
181  T &operator()(const int N2, const int N3) { return iter(N0, N1, N2, N3); }
182  T operator()(const int N2, const int N3) const
183  {
184  return iter(N0, N1, N2, N3);
185  }
186 
187  /* Various assignment operators. I have to explicitly declare the
188  second operator= because otherwise the compiler will generate its
189  own and not use the template code. */
190 
191  template <class B, class U>
193  &operator=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
194 
197  T, Dim, i, j> &result);
198  };
199 }
200 
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:27
Fully Antisymmetric Levi-Civita Tensor.
T operator()(const int N1, const int N2) const
const int N
Definition: speed_test.cpp:3