v0.11.1
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 
23 #include "dTensor2_symmetric.hpp"
26 #include "ddTensor2_symmetric.hpp"
32 
33 namespace FTensor
34 {
35  template <class A, class T, int Dim, char i, char j>
37  {
38  A iter;
39 
40  public:
41  Tensor2_symmetric_Expr(const A &a) : iter(a) {}
42  T operator()(const int N1, const int N2) const { return iter(N1, N2); }
43  };
44 
45  template <class A, class T, int Tensor_Dim, int Dim, char i, char j>
46  class Tensor2_symmetric_Expr<Tensor2_symmetric<A, Tensor_Dim>, T, Dim, i, j>
47  {
49 
50  public:
52  T &operator()(const int N1, const int N2) { return iter(N1, N2); }
53  T operator()(const int N1, const int N2) const { return iter(N1, N2); }
54 
55  /* Various assignment operators. I have to explicitly declare the
56  second operator= because otherwise the compiler will generate its
57  own and not use the template code. */
58 
59  template <class B, class U>
61  j> &
62  operator=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
63 
65  j> &
67  Dim, i, j> &result);
68 
69  template <class B, class U>
71  j> &
72  operator+=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
73 
74  template <class B, class U>
76  j> &
77  operator-=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
78 
79  template <class B, class U>
81  j> &
82  operator&=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
83 
84  /* This is for when the indices are switched (i,j) -> (j,i). */
85 
86  template <class B, class U>
88  j> &
89  operator=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
90 
91  template <class B, class U>
93  j> &
94  operator+=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
95 
96  template <class B, class U>
98  j> &
99  operator-=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
100 
101  /* Operations with just generics. */
102 
103  template <class U>
105  j> &
106  operator=(const U &d);
107  template <class U>
109  j> &
110  operator+=(const U &d);
111  template <class U>
113  j> &
114  operator-=(const U &d);
115  template <class U>
117  j> &
118  operator*=(const U &d);
119  template <class U>
121  j> &
122  operator/=(const U &d);
123  /* ADOL-C operators. */
124 
125  template <class B, class U>
127  j> &
128  operator<<=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
129 
131  j> &
133  T, Dim, i, j> &result);
134 
135  template <class B, class U>
137  Dim, i, j> &
138  operator<<=(const Tensor2_symmetric_Expr<B, U, Dim, j, i> &result);
139 
140  template <class U>
142  Dim, i, j> &
143  operator<<=(const U &d);
144  };
145 
146  /* Specialized for Dg_number_rhs_2 (Dg with the
147  second index explicitly given). */
148 
149  template <class A, class T, int Dim, char i, char j, int N>
151  {
152  A &iter;
153 
154  public:
156  T &operator()(const int N1, const int N2) { return iter(N1, N2, N); }
157  T operator()(const int N1, const int N2) const { return iter(N1, N2, N); }
158 
159  /* Various assignment operators. I have to explicitly declare the
160  second operator= because otherwise the compiler will generate its
161  own and not use the template code. */
162 
163  template <class B, class U>
165  operator=(const Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
166 
168  operator=(const Tensor2_symmetric_Expr<Dg_number_rhs_2<A, T, N>, T, Dim, i,
169  j> &result);
170  };
171 
172  /* Specialized for Ddg_number_rhs_01 (Ddg with the
173  first and second index explicitly given). */
174 
175  template <class A, class T, int Dim, char i, char j, int N0, int N1>
177  {
178  A &iter;
179 
180  public:
182  T &operator()(const int N2, const int N3) { return iter(N0, N1, N2, N3); }
183  T operator()(const int N2, const int N3) const
184  {
185  return iter(N0, N1, N2, N3);
186  }
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 Tensor2_symmetric_Expr<B, U, Dim, i, j> &result);
195 
198  T, Dim, i, j> &result);
199  };
200 }
201 
static Number< 2 > N2
static Number< 1 > N1
static Number< 0 > N0
T operator()(const int N1, const int N2) const
FTensor::Index< 'j', 3 > j
FTensor::Index< 'i', 3 > i
const double T
JSON compatible output.
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
const int N
Definition: speed_test.cpp:3