v0.13.2
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 T operator()(const int N) const { return iter(N); }
34 };
35
36 template <class A, class T, int Tensor_Dim, int Dim, char i>
37 class Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i>
38 {
40
41 public:
43
44 T &operator()(const int N) { return iter(N); }
45 T operator()(const int N) const { return iter(N); }
46
47 /* Various assignment operators. I have to explicitly declare the
48 second operator= because otherwise the compiler will generate its
49 own and not use the template code. */
50
51 template <class B, class U>
53 operator=(const Tensor1_Expr<B, U, Dim, i> &result);
54
56 operator=(const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &result);
57
58 template <class B, class U>
60 operator+=(const Tensor1_Expr<B, U, Dim, i> &result);
61
62 template <class B, class U>
64 operator-=(const Tensor1_Expr<B, U, Dim, i> &result);
65
66 /* General template assignment operators intended mostly for
67 doubles (type T), but could be applied to anything you want, like
68 complex, etc. All that is required is that T=B works (or T+=B,
69 etc.) */
70
71 template <class B>
73 operator=(const B &d);
74 template <class B>
76 operator+=(const B &d);
77 template <class B>
79 operator-=(const B &d);
80 template <class B>
82 operator*=(const B &d);
83 template <class B>
85 operator/=(const B &d);
86
87
88 /** Assignments operators for ADOL-C
89 */
90
91 template <class B, class U>
92 inline const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
93 operator<<=(const Tensor1_Expr<B, U, Dim, i> &result);
94
96 operator<<=(const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &result);
97
98 template <class B>
100 operator<<=(const B &d);
101
102 template <class B, class U>
103 inline const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
104 operator>>=(const Tensor1_Expr<B, U, Dim, i> &result);
105
108
109 template <class B>
110 inline const Tensor1_Expr<Tensor1<A, Tensor_Dim>, T, Dim, i> &
111 operator>>=(const B &d);
112 };
113
114 /* Specialized for Tensor2_number_rhs_0 (Tensor2{_symmetric} with the
115 first index explicitly given). */
116
117 template <class A, class T, int Dim1, char i, int N>
119 {
121
122 public:
124 T &operator()(const int N1) { return iter(N, N1); }
125 T operator()(const int N1) const { return iter(N, N1); }
126
127 /* Various assignment operators. I have to explicitly declare the
128 second operator= because otherwise the compiler will generate its
129 own and not use the template code. */
130
131 template <class B, class U>
133 operator=(const Tensor1_Expr<B, U, Dim1, i> &result);
134
135 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &operator=(
136 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &result);
137
138 template <class B, class U>
140 operator+=(const Tensor1_Expr<B, U, Dim1, i> &result);
141
142 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &operator+=(
143 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &result);
144
145 template <class B, class U>
147 operator-=(const Tensor1_Expr<B, U, Dim1, i> &result);
148
149 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &operator-=(
150 const Tensor1_Expr<Tensor2_number_rhs_0<A, T, N>, T, Dim1, i> &result);
151
152 template <class B>
154 operator=(const B &result);
155
156 template <class B>
158 operator+=(const B &result);
159
160 template <class B>
162 operator-=(const B &result);
163
164 template <class B>
166 operator*=(const B &result);
167
168 template <class B>
170 operator/=(const B &result);
171 };
172
173 /* Specialized for Tensor2_number_rhs_1 (Tensor2{_symmetric} with the
174 second index explicitly given). */
175
176 template <class A, class T, int Dim1, char i, int N>
178 {
180
181 public:
183 T &operator()(const int N1) { return iter(N1, N); }
184 T operator()(const int N1) const { return iter(N1, N); }
185
186 /* Various assignment operators. I have to explicitly declare the
187 second operator= because otherwise the compiler will generate its
188 own and not use the template code. */
189
190 template <class B, class U>
192 operator=(const Tensor1_Expr<B, U, Dim1, i> &result);
193
194 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &operator=(
195 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &result);
196
197 template <class B, class U>
199 operator+=(const Tensor1_Expr<B, U, Dim1, i> &result);
200
201 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &operator+=(
202 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &result);
203
204 template <class B, class U>
206 operator-=(const Tensor1_Expr<B, U, Dim1, i> &result);
207
208 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &operator-=(
209 const Tensor1_Expr<Tensor2_number_rhs_1<A, T, N>, T, Dim1, i> &result);
210
211 template <class B>
213 operator=(const B &result);
214
215 template <class B>
217 operator+=(const B &result);
218
219 template <class B>
221 operator-=(const B &result);
222
223 template <class B>
225 operator*=(const B &result);
226
227 template <class B>
229 operator/=(const B &result);
230 };
231
232 /* Specialized for Dg_number_rhs_12 (A Dg with
233 explicit numbers in the (first or second) and third slots). */
234
235 template <class A, class T, int Dim, char i, int N1, int N2>
237 {
239
240 public:
242 T &operator()(const int N) { return iter(N, N1, N2); }
243 T operator()(const int N) const { return iter(N, N1, N2); }
244
245 /* Various assignment operators. I have to explicitly declare the
246 second operator= because otherwise the compiler will generate its
247 own and not use the template code. */
248
249 template <class B, class U>
251 operator=(const Tensor1_Expr<B, U, Dim, i> &result);
252
253 const Tensor1_Expr<Dg_number_rhs_12<A, T, N1, N2>, T, Dim, i> &operator=(
254 const Tensor1_Expr<Dg_number_rhs_12<A, T, N1, N2>, T, Dim, i> &result);
255 };
256
257 /* Specialized for Dg_number_rhs_01 (A Dg with
258 explicit numbers in the first and second slots). */
259
260 template <class A, class T, int Dim, char i, int N1, int N2>
262 {
264
265 public:
267 T &operator()(const int N) { return iter(N1, N2, N); }
268 T operator()(const int N) const { return iter(N1, N2, N); }
269
270 /* Various assignment operators. I have to explicitly declare the
271 second operator= because otherwise the compiler will generate its
272 own and not use the template code. */
273
274 template <class B, class U>
276 operator=(const Tensor1_Expr<B, U, Dim, i> &result);
277
278 const Tensor1_Expr<Dg_number_rhs_01<A, T, N1, N2>, T, Dim, i> &operator=(
279 const Tensor1_Expr<Dg_number_rhs_01<A, T, N1, N2>, T, Dim, i> &result);
280 };
281}
282
static Number< 2 > N2
static Number< 1 > N1
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 A &a)
T operator()(const int N) const
FTensor::Index< 'i', SPACE_DIM > i
const double T
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