v0.16.0
Loading...
Searching...
No Matches
Tensor1_Expr.hpp
Go to the documentation of this file.
1/* Declares a wrapper class for rank 1 Tensor expressions. Note that
2 Tensor1_Expr_equals is included at the end, since it needs the
3 definition of the class in order to compile. */
4
5#pragma once
6
17#include "dTensor1.hpp"
19#include "ddTensor1.hpp"
20#include "diffusion_Tensor1.hpp"
23#include "minus_Tensor1.hpp"
24
25namespace FTensor
26{
27 template <class A, class T, int Dim, char i> class Tensor1_Expr
28 {
30
31 public:
32 Tensor1_Expr(const A &a) : iter(a) {}
33 Tensor1_Expr(const Tensor1_Expr &) = default;
34 T operator()(const int N) const { return iter(N); }
35 };
36
37 template <class A, class T, int Tensor_Dim, int Dim, char i>
38 class Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i>
39 {
41
42 public:
44 Tensor1_Expr(const Tensor1_Expr &) = default;
45
46 T &operator()(const int N) { return iter(N); }
47 T operator()(const int N) const { return iter(N); }
48
49 /* Various assignment operators. I have to explicitly declare the
50 second operator= because otherwise the compiler will generate its
51 own and not use the template code. */
52
53 template <class B, class U>
55 operator=(const Tensor1_Expr<B, U, Dim, i> &result);
56
58 operator=(const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &result);
59
60 template <class B, class U>
62 operator+=(const Tensor1_Expr<B, U, Dim, i> &result);
63
64 template <class B, class U>
66 operator-=(const Tensor1_Expr<B, U, Dim, i> &result);
67
68 /* General template assignment operators intended mostly for
69 doubles (type T), but could be applied to anything you want, like
70 complex, etc. All that is required is that T=B works (or T+=B,
71 etc.) */
72
73 template <class B>
75 operator=(const B &d);
76 template <class B>
78 operator+=(const B &d);
79 template <class B>
81 operator-=(const B &d);
82 template <class B>
84 operator*=(const B &d);
85 template <class B>
87 operator/=(const B &d);
88
89
90 /** Assignments operators for ADOL-C
91 */
92
93 template <class B, class U>
94 inline const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
95 operator<<=(const Tensor1_Expr<B, U, Dim, i> &result);
96
98 operator<<=(const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &result);
99
100 template <class B>
101 inline const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
102 operator<<=(const B &d);
103
104 template <class B, class U>
105 inline const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
106 operator>>=(const Tensor1_Expr<B, U, Dim, i> &result);
107
108 const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
110
111 template <class B>
112 inline const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
113 operator>>=(const B &d);
114 };
115
116 /* Specialized for Tensor2_number_rhs_0 (Tensor2{_symmetric} with the
117 first index explicitly given). */
118
119 template <class A, class T, int Dim1, char i, int N>
120 class Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i>
121 {
123
124 public:
126 T &operator()(const int N1) { return iter(N, N1); }
127 T operator()(const int N1) const { return iter(N, N1); }
128
129 /* Various assignment operators. I have to explicitly declare the
130 second operator= because otherwise the compiler will generate its
131 own and not use the template code. */
132
133 template <class B, class U>
135 operator=(const Tensor1_Expr<B, U, Dim1, i> &result);
136
137 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &operator=(
138 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &result);
139
140 template <class B, class U>
142 operator+=(const Tensor1_Expr<B, U, Dim1, i> &result);
143
144 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &operator+=(
145 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &result);
146
147 template <class B, class U>
149 operator-=(const Tensor1_Expr<B, U, Dim1, i> &result);
150
151 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &operator-=(
152 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &result);
153
154 template <class B>
156 operator=(const B &result);
157
158 template <class B>
160 operator+=(const B &result);
161
162 template <class B>
164 operator-=(const B &result);
165
166 template <class B>
168 operator*=(const B &result);
169
170 template <class B>
172 operator/=(const B &result);
173 };
174
175 /* Specialized for Tensor2_number_rhs_1 (Tensor2{_symmetric} with the
176 second index explicitly given). */
177
178 template <class A, class T, int Dim1, char i, int N>
179 class Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i>
180 {
182
183 public:
185 T &operator()(const int N1) { return iter(N1, N); }
186 T operator()(const int N1) const { return iter(N1, N); }
187
188 /* Various assignment operators. I have to explicitly declare the
189 second operator= because otherwise the compiler will generate its
190 own and not use the template code. */
191
192 template <class B, class U>
194 operator=(const Tensor1_Expr<B, U, Dim1, i> &result);
195
196 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &operator=(
197 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &result);
198
199 template <class B, class U>
201 operator+=(const Tensor1_Expr<B, U, Dim1, i> &result);
202
203 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &operator+=(
204 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &result);
205
206 template <class B, class U>
208 operator-=(const Tensor1_Expr<B, U, Dim1, i> &result);
209
210 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &operator-=(
211 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &result);
212
213 template <class B>
215 operator=(const B &result);
216
217 template <class B>
219 operator+=(const B &result);
220
221 template <class B>
223 operator-=(const B &result);
224
225 template <class B>
227 operator*=(const B &result);
228
229 template <class B>
231 operator/=(const B &result);
232 };
233
234 /* Specialized for Dg_number_rhs_12 (A Dg with
235 explicit numbers in the (first or second) and third slots). */
236
237 template <class A, class T, int Dim, char i, int N1, int N2>
238 class Tensor1_Expr<Dg_number_rhs_12<A, T, N1, N2>, T, Dim, i>
239 {
241
242 public:
244 T &operator()(const int N) { return iter(N, N1, N2); }
245 T operator()(const int N) const { return iter(N, N1, N2); }
246
247 /* Various assignment operators. I have to explicitly declare the
248 second operator= because otherwise the compiler will generate its
249 own and not use the template code. */
250
251 template <class B, class U>
253 operator=(const Tensor1_Expr<B, U, Dim, i> &result);
254
255 const Tensor1_Expr<Dg_number_rhs_12<A, T, N1, N2>, T, Dim, i> &operator=(
256 const Tensor1_Expr<Dg_number_rhs_12<A, T, N1, N2>, T, Dim, i> &result);
257 };
258
259 /* Specialized for Dg_number_rhs_01 (A Dg with
260 explicit numbers in the first and second slots). */
261
262 template <class A, class T, int Dim, char i, int N1, int N2>
263 class Tensor1_Expr<Dg_number_rhs_01<A, T, N1, N2>, T, Dim, i>
264 {
266
267 public:
269 T &operator()(const int N) { return iter(N1, N2, N); }
270 T operator()(const int N) const { return iter(N1, N2, N); }
271
272 /* Various assignment operators. I have to explicitly declare the
273 second operator= because otherwise the compiler will generate its
274 own and not use the template code. */
275
276 template <class B, class U>
278 operator=(const Tensor1_Expr<B, U, Dim, i> &result);
279
280 const Tensor1_Expr<Dg_number_rhs_01<A, T, N1, N2>, T, Dim, i> &operator=(
281 const Tensor1_Expr<Dg_number_rhs_01<A, T, N1, N2>, T, Dim, i> &result);
282 };
283}
284
constexpr double a
const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > & operator>>=(const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > &result)
const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > & operator*=(const B &d)
const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > & operator>>=(const B &d)
const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > & operator=(const B &d)
const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > & operator-=(const B &d)
const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > & operator+=(const B &d)
const Tensor1_Expr< Tensor1< A, Tensor_Dim >, T, Dim, i > & operator/=(const B &d)
const Tensor1_Expr< Tensor2_number_rhs_0< A, T, N >, T, Dim1, i > & operator*=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_0< A, T, N >, T, Dim1, i > & operator+=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_0< A, T, N >, T, Dim1, i > & operator=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_0< A, T, N >, T, Dim1, i > & operator/=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_0< A, T, N >, T, Dim1, i > & operator-=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_1< A, T, N >, T, Dim1, i > & operator-=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_1< A, T, N >, T, Dim1, i > & operator/=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_1< A, T, N >, T, Dim1, i > & operator+=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_1< A, T, N >, T, Dim1, i > & operator=(const B &result)
const Tensor1_Expr< Tensor2_number_rhs_1< A, T, N >, T, Dim1, i > & operator*=(const B &result)
Tensor1_Expr(const Tensor1_Expr &)=default
T operator()(const int N) const
FTensor::Index< 'i', SPACE_DIM > i
Tensors class implemented by Walter Landry.
Definition FTensor.hpp:51
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
constexpr AssemblyType A
const int N
Definition speed_test.cpp:3