v0.14.0
Tensor2_symmetric_Expr_equals.hpp
Go to the documentation of this file.
1 /* Various assignment operators. I have to explicitly declare the
2  second operator= because otherwise the compiler will generate its
3  own and not use the template code. */
4 
5 /* T2s=T2s */
6 
7 #pragma once
8 
9 namespace FTensor
10 {
11  template <class A, class B, class U, int Dim, char i, char j,
12  int Current_Dim0, int Current_Dim1>
13  void
17  {
18  iter(Current_Dim0 - 1, Current_Dim1 - 1)
19  = result(Current_Dim0 - 1, Current_Dim1 - 1);
22  }
23 
24  template <class A, class B, class U, int Dim, char i, char j,
25  int Current_Dim1>
26  void T2s_equals_T2s(A &iter,
28  const Number<1> &, const Number<Current_Dim1> &)
29  {
30  iter(0, Current_Dim1 - 1) = result(0, Current_Dim1 - 1);
33  }
34 
35  template <class A, class B, class U, int Dim, char i, char j>
36  void T2s_equals_T2s(A &iter,
38  const Number<1> &, const Number<1> &)
39  {
40  iter(0, 0) = result(0, 0);
41  }
42 
43  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
44  template <class B, class U>
45  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
46  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
47  operator=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result)
48  {
49  T2s_equals_T2s(iter, result, Number<Dim>(), Number<Dim>());
50  return *this;
51  }
52 
53  /* T2s=T2s_Expr(T2s) */
54 
55  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
59  Dim, i, j> &result)
60  {
61  return operator=<Tensor2_symmetric<A, Tensor_Dim>, T>(result);
62  }
63  /* ADOL-C T2s<<=T2s left */
64 
65  template <class A, class B, class U, int Dim, char i, char j,
66  int Current_Dim0, int Current_Dim1>
68  A &iter, const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result,
70  {
71  iter(Current_Dim0 - 1, Current_Dim1 - 1)
72  <<= result(Current_Dim0 - 1, Current_Dim1 - 1);
75  }
76 
77  template <class A, class B, class U, int Dim, char i, char j,
78  int Current_Dim1>
80  A &iter, const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result,
81  const Number<1> &, const Number<Current_Dim1> &)
82  {
83  iter(0, Current_Dim1 - 1) <<= result(0, Current_Dim1 - 1);
86  }
87 
88  template <class A, class B, class U, int Dim, char i, char j>
90  A &iter, const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result,
91  const Number<1> &, const Number<1> &)
92  {
93  iter(0, 0) <<= result(0, 0);
94  }
95 
96  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
97  template <class B, class U>
98  inline const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim,
99  i, j> &
100  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
101  operator<<=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result)
102  {
104  return *this;
105  }
106 
107  /* ADOL-C left T2s=T2s_Expr(T2s) */
108 
109  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
111  i, j> &
114  Dim, i, j> &result)
115  {
116  return operator<<=<Tensor2_symmetric<A, Tensor_Dim>, T>(result);
117  }
118 
119  /* T2s+=T2s */
120 
121  template <class A, class B, class U, int Dim, char i, char j,
122  int Current_Dim0, int Current_Dim1>
123  void
126  const Number<Current_Dim0> &,
127  const Number<Current_Dim1> &)
128  {
129  iter(Current_Dim0 - 1, Current_Dim1 - 1)
130  += result(Current_Dim0 - 1, Current_Dim1 - 1);
133  }
134 
135  template <class A, class B, class U, int Dim, char i, char j,
136  int Current_Dim1>
137  void
140  const Number<1> &, const Number<Current_Dim1> &)
141  {
142  iter(0, Current_Dim1 - 1) += result(0, Current_Dim1 - 1);
145  }
146 
147  template <class A, class B, class U, int Dim, char i, char j>
148  void
151  const Number<1> &, const Number<1> &)
152  {
153  iter(0, 0) += result(0, 0);
154  }
155 
156  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
157  template <class B, class U>
158  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
159  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
160  operator+=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result)
161  {
162  T2s_plus_equals_T2s(iter, result, Number<Dim>(), Number<Dim>());
163  return *this;
164  }
165 
166  /* T2s-=T2s */
167 
168  template <class A, class B, class U, int Dim, char i, char j,
169  int Current_Dim0, int Current_Dim1>
170  void
173  const Number<Current_Dim0> &,
174  const Number<Current_Dim1> &)
175  {
176  iter(Current_Dim0 - 1, Current_Dim1 - 1)
177  -= result(Current_Dim0 - 1, Current_Dim1 - 1);
180  }
181 
182  template <class A, class B, class U, int Dim, char i, char j,
183  int Current_Dim1>
184  void
187  const Number<1> &, const Number<Current_Dim1> &)
188  {
189  iter(0, Current_Dim1 - 1) -= result(0, Current_Dim1 - 1);
192  }
193 
194  template <class A, class B, class U, int Dim, char i, char j>
195  void
198  const Number<1> &, const Number<1> &)
199  {
200  iter(0, 0) -= result(0, 0);
201  }
202 
203  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
204  template <class B, class U>
205  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
206  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
207  operator-=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result)
208  {
209  T2s_minus_equals_T2s(iter, result, Number<Dim>(), Number<Dim>());
210  return *this;
211  }
212 
213  /* T2s&=T2s */
214 
215  template <class A, class B, class U, int Dim, char i, char j,
216  int Current_Dim0, int Current_Dim1>
217  void
220  const Number<Current_Dim0> &,
221  const Number<Current_Dim1> &)
222  {
223  iter(Current_Dim0 - 1, Current_Dim1 - 1)
224  *= result(Current_Dim0 - 1, Current_Dim1 - 1);
227  }
228 
229  template <class A, class B, class U, int Dim, char i, char j,
230  int Current_Dim1>
231  void
234  const Number<1> &, const Number<Current_Dim1> &)
235  {
236  iter(0, Current_Dim1 - 1) *= result(0, Current_Dim1 - 1);
239  }
240 
241  template <class A, class B, class U, int Dim, char i, char j>
242  void
245  const Number<1> &, const Number<1> &)
246  {
247  iter(0, 0) *= result(0, 0);
248  }
249 
250  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
251  template <class B, class U>
252  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
253  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
254  operator&=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result)
255  {
256  T2s_and_equals_T2s(iter, result, Number<Dim>(), Number<Dim>());
257  return *this;
258  }
259 
260  /* This is for when the indices are switched (i,j) -> (j,i). */
261 
262  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
263  template <class B, class U>
267  {
268  T2s_equals_T2s(iter, result, Number<Dim>(), Number<Dim>());
269  return *this;
270  }
271 
272  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
273  template <class B, class U>
276  operator+=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result)
277  {
278  T2s_plus_equals_T2s(iter, result, Number<Dim>(), Number<Dim>());
279  return *this;
280  }
281 
282  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
283  template <class B, class U>
286  operator-=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result)
287  {
288  T2s_minus_equals_T2s(iter, result, Number<Dim>(), Number<Dim>());
289  return *this;
290  }
291 
292  /* Operations with just generics. */
293 
294  /* T2s=U */
295 
296  template <class A, class U, int Current_Dim0, int Current_Dim1>
297  void T2s_equals_generic(A &iter, const U &u, const Number<Current_Dim0> &,
298  const Number<Current_Dim1> &)
299  {
300  iter(Current_Dim0 - 1, Current_Dim1 - 1) = u;
303  }
304 
305  template <class A, class U, int Current_Dim1>
306  void T2s_equals_generic(A &iter, const U &u, const Number<1> &,
307  const Number<Current_Dim1> &)
308  {
309  iter(0, Current_Dim1 - 1) = u;
312  }
313 
314  template <class A, class U>
315  void
316  T2s_equals_generic(A &iter, const U &u, const Number<1> &, const Number<1> &)
317  {
318  iter(0, 0) = u;
319  }
320 
321  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
322  template <class U>
323  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
324  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
325  operator=(const U &u)
326  {
328  return *this;
329  }
330 
331  /* T2s+=U */
332 
333  template <class A, class U, int Current_Dim0, int Current_Dim1>
334  void
336  const Number<Current_Dim1> &)
337  {
338  iter(Current_Dim0 - 1, Current_Dim1 - 1) += u;
341  }
342 
343  template <class A, class U, int Current_Dim1>
344  void T2s_plus_equals_generic(A &iter, const U &u, const Number<1> &,
345  const Number<Current_Dim1> &)
346  {
347  iter(0, Current_Dim1 - 1) += u;
350  }
351 
352  template <class A, class U>
353  void T2s_plus_equals_generic(A &iter, const U &u, const Number<1> &,
354  const Number<1> &)
355  {
356  iter(0, 0) += u;
357  }
358 
359  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
360  template <class U>
361  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
362  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
363  operator+=(const U &u)
364  {
366  return *this;
367  }
368 
369  /* T2s-=U */
370 
371  template <class A, class U, int Current_Dim0, int Current_Dim1>
372  void
374  const Number<Current_Dim1> &)
375  {
376  iter(Current_Dim0 - 1, Current_Dim1 - 1) -= u;
379  }
380 
381  template <class A, class U, int Current_Dim1>
382  void T2s_minus_equals_generic(A &iter, const U &u, const Number<1> &,
383  const Number<Current_Dim1> &)
384  {
385  iter(0, Current_Dim1 - 1) -= u;
388  }
389 
390  template <class A, class U>
391  void T2s_minus_equals_generic(A &iter, const U &u, const Number<1> &,
392  const Number<1> &)
393  {
394  iter(0, 0) -= u;
395  }
396 
397  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
398  template <class U>
399  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
400  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
401  operator-=(const U &u)
402  {
404  return *this;
405  }
406 
407  /* T2s*=U */
408 
409  template <class A, class U, int Current_Dim0, int Current_Dim1>
410  void
412  const Number<Current_Dim1> &)
413  {
414  iter(Current_Dim0 - 1, Current_Dim1 - 1) *= u;
417  }
418 
419  template <class A, class U, int Current_Dim1>
420  void T2s_times_equals_generic(A &iter, const U &u, const Number<1> &,
421  const Number<Current_Dim1> &)
422  {
423  iter(0, Current_Dim1 - 1) *= u;
426  }
427 
428  template <class A, class U>
429  void T2s_times_equals_generic(A &iter, const U &u, const Number<1> &,
430  const Number<1> &)
431  {
432  iter(0, 0) *= u;
433  }
434 
435  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
436  template <class U>
437  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
438  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
439  operator*=(const U &u)
440  {
442  return *this;
443  }
444 
445  /* T2s/=U */
446 
447  template <class A, class U, int Current_Dim0, int Current_Dim1>
448  void
450  const Number<Current_Dim1> &)
451  {
452  iter(Current_Dim0 - 1, Current_Dim1 - 1) /= u;
455  }
456 
457  template <class A, class U, int Current_Dim1>
458  void T2s_divide_equals_generic(A &iter, const U &u, const Number<1> &,
459  const Number<Current_Dim1> &)
460  {
461  iter(0, Current_Dim1 - 1) /= u;
464  }
465 
466  template <class A, class U>
467  void T2s_divide_equals_generic(A &iter, const U &u, const Number<1> &,
468  const Number<1> &)
469  {
470  iter(0, 0) /= u;
471  }
472 
473  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
474  template <class U>
475  const Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j> &
476  Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>::
477  operator/=(const U &u)
478  {
480  return *this;
481  }
482 
483  /* Various assignment operators for Dg_number_rhs_2. I have
484  to explicitly declare the second operator= because otherwise the
485  compiler will generate its own and not use the template code. */
486 
487  template <class A, class B, class U, int Dim01, char i, char j, int N,
488  int Current_Dim0, int Current_Dim1>
489  void
492  const Number<Current_Dim0> &,
493  const Number<Current_Dim1> &, const Number<N> &)
494  {
495  iter(Current_Dim0 - 1, Current_Dim1 - 1, N)
496  = result(Current_Dim0 - 1, Current_Dim1 - 1);
499  }
500 
501  template <class A, class B, class U, int Dim01, char i, char j, int N,
502  int Current_Dim1>
503  void
506  const Number<1> &, const Number<Current_Dim1> &,
507  const Number<N> &)
508  {
509  iter(0, Current_Dim1 - 1, N) = result(0, Current_Dim1 - 1);
512  }
513 
514  template <class A, class B, class U, int Dim01, char i, char j, int N>
515  void
518  const Number<1> &, const Number<1> &, const Number<N> &)
519  {
520  iter(0, 0, N) = result(0, 0);
521  }
522 
523  template <class A, class T, int Dim, char i, char j, int N>
524  template <class B, class U>
525  const Tensor2_symmetric_Expr<Dg_number_rhs_2<A, T, N>, T, Dim, i, j> &
526  Tensor2_symmetric_Expr<Dg_number_rhs_2<A, T, N>, T, Dim, i, j>::
528  {
529  T3dgrhs2_equals_T2s(iter, result, Number<Dim>(), Number<Dim>(),
530  Number<N>());
531  return *this;
532  }
533 
534  template <class A, class T, int Dim, char i, char j, int N>
538  j> &result)
539  {
540  return operator=<Dg_number_rhs_2<A, T, N>, T>(result);
541  }
542 
543  /* Various assignment operators for Ddg_number_rhs_01. I have
544  to explicitly declare the second operator= because otherwise the
545  compiler will generate its own and not use the template code. */
546 
547  template <class A, class B, class U, int Dim01, char i, char j, int N0,
548  int N1, int Current_Dim0, int Current_Dim1>
550  A &iter, const Tensor2_symmetric_Expr<B, U, Dim01, i, j> &result,
552  const Number<N0> &, const Number<N1> &)
553  {
554  iter(N0, N1, Current_Dim0 - 1, Current_Dim1 - 1)
555  = result(Current_Dim0 - 1, Current_Dim1 - 1);
558  }
559 
560  template <class A, class B, class U, int Dim01, char i, char j, int N0,
561  int N1, int Current_Dim1>
563  A &iter, const Tensor2_symmetric_Expr<B, U, Dim01, i, j> &result,
564  const Number<1> &, const Number<Current_Dim1> &, const Number<N0> &,
565  const Number<N1> &)
566  {
567  iter(N0, N1, 0, Current_Dim1 - 1) = result(0, Current_Dim1 - 1);
570  Number<N1>());
571  }
572 
573  template <class A, class B, class U, int Dim01, char i, char j, int N0,
574  int N1>
576  A &iter, const Tensor2_symmetric_Expr<B, U, Dim01, i, j> &result,
577  const Number<1> &, const Number<1> &, const Number<N0> &,
578  const Number<N1> &)
579  {
580  iter(N0, N1, 0, 0) = result(0, 0);
581  }
582 
583  template <class A, class T, int Dim, char i, char j, int N0, int N1>
584  template <class B, class U>
585  const Tensor2_symmetric_Expr<Ddg_number_rhs_01<A, T, N0, N1>, T, Dim, i, j> &
586  Tensor2_symmetric_Expr<Ddg_number_rhs_01<A, T, N0, N1>, T, Dim, i, j>::
588  {
589  T4ddgrhs01_equals_T2s(iter, result, Number<Dim>(), Number<Dim>(),
590  Number<N0>(), Number<N1>());
591  return *this;
592  }
593 
594  template <class A, class T, int Dim, char i, char j, int N0, int N1>
598  Dim, i, j> &result)
599  {
600  return operator=<Ddg_number_rhs_01<A, T, N0, N1>, T>(result);
601  }
602 }
FTensor
JSON compatible output.
Definition: Christof_constructor.hpp:6
FTensor::T2s_equals_generic
void T2s_equals_generic(A &iter, const U &u, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:297
FTensor::Tensor2_symmetric_Expr< B, U, Dim, i, j >
A
constexpr AssemblyType A
Definition: operators_tests.cpp:30
FTensor::Tensor2_symmetric< A, Tensor_Dim >
FTensor::T2s_plus_equals_T2s
void T2s_plus_equals_T2s(A &iter, const Tensor2_symmetric_Expr< B, U, Dim, i, j > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:124
FTensor::T2s_plus_equals_generic
void T2s_plus_equals_generic(A &iter, const U &u, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:335
FTensor::T2s_times_equals_generic
void T2s_times_equals_generic(A &iter, const U &u, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:411
FTensor::T2s_equals_T2s
void T2s_equals_T2s(A &iter, const Tensor2_symmetric_Expr< B, U, Dim, i, j > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:14
FTensor::Number
Definition: Number.hpp:11
FTensor::T2s_minus_equals_T2s
void T2s_minus_equals_T2s(A &iter, const Tensor2_symmetric_Expr< B, U, Dim, i, j > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:171
FTensor::T3dgrhs2_equals_T2s
void T3dgrhs2_equals_T2s(A &iter, const Tensor2_symmetric_Expr< B, U, Dim01, i, j > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< N > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:490
FTensor::Dg_number_rhs_2
Definition: Dg_number.hpp:34
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
FTensor::T2s_divide_equals_generic
void T2s_divide_equals_generic(A &iter, const U &u, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:449
FTensor::T4ddgrhs01_equals_T2s
void T4ddgrhs01_equals_T2s(A &iter, const Tensor2_symmetric_Expr< B, U, Dim01, i, j > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &, const Number< N0 > &, const Number< N1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:549
FTensor::Ddg_number_rhs_01
Definition: Ddg_number.hpp:23
N
const int N
Definition: speed_test.cpp:3
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
FTensor::T2s_minus_equals_generic
void T2s_minus_equals_generic(A &iter, const U &u, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:373
FTensor::T2s_and_equals_T2s
void T2s_and_equals_T2s(A &iter, const Tensor2_symmetric_Expr< B, U, Dim, i, j > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:218
FTensor::T2s_equals_adolc_left_T2s
void T2s_equals_adolc_left_T2s(A &iter, const Tensor2_symmetric_Expr< B, U, Dim, i, j > &result, const Number< Current_Dim0 > &, const Number< Current_Dim1 > &)
Definition: Tensor2_symmetric_Expr_equals.hpp:67
EshelbianPlasticity::U
@ U
Definition: EshelbianContact.cpp:197