v0.6.9
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 
22 #include "dTensor2_symmetric.hpp"
23 #include "ddTensor2_symmetric.hpp"
29 
30 
31 template<class A, class T, int Dim, char i, char j>
33 {
34  A iter;
35 public:
36  Tensor2_symmetric_Expr(A &a): iter(a) {}
37  T operator()(const int N1, const int N2) const
38  {
39  return iter(N1,N2);
40  }
41 };
42 
43 template<class A, class T, int Tensor_Dim, int Dim, char i, char j>
44 class Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j>
45 {
47 public:
49  T & operator()(const int N1, const int N2)
50  {
51  return iter(N1,N2);
52  }
53  T operator()(const int N1, const int N2) const
54  {
55  return iter(N1,N2);
56  }
57 
58  /* Various assignment operators. I have to explicitly declare the
59  second operator= because otherwise the compiler will generate its
60  own and not use the template code. */
61 
62  template<class B, class U>
64  operator=(const Tensor2_symmetric_Expr<B,U,Dim,i,j> &result);
65 
67  operator=(const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> &result);
68 
69  template<class B, class U> inline
71  operator+=(const Tensor2_symmetric_Expr<B,U,Dim,i,j> &result);
72 
73  template<class B, class U> inline
75  operator-=(const Tensor2_symmetric_Expr<B,U,Dim,i,j> &result);
76 
77  template<class B, class U> inline
79  operator&=(const Tensor2_symmetric_Expr<B,U,Dim,i,j> &result);
80 
81  /* This is for when the indices are switched (i,j) -> (j,i). */
82 
83  template<class B, class U> inline
85  operator=(const Tensor2_symmetric_Expr<B,U,Dim,j,i> &result);
86 
87  template<class B, class U> inline
89  operator+=(const Tensor2_symmetric_Expr<B,U,Dim,j,i> &result);
90 
91  template<class B, class U> inline
93  operator-=(const Tensor2_symmetric_Expr<B,U,Dim,j,i> &result);
94 
95  /* Operations with just generics. */
96 
97  template<class U> inline
98  const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> & operator=(const U &d);
99  template<class U> inline
100  const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> & operator+=(const U &d);
101  template<class U> inline
102  const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> & operator-=(const U &d);
103  template<class U> inline
104  const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> & operator*=(const U &d);
105  template<class U> inline
106  const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> & operator/=(const U &d);
107 
108  /* ADOL-C operators. */
109 
110  template<class B, class U>
112  operator<<=(const Tensor2_symmetric_Expr<B,U,Dim,i,j> &result);
113 
115  operator<<=(const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> &result);
116 
117  template<class B, class U> inline
119  operator<<=(const Tensor2_symmetric_Expr<B,U,Dim,j,i> &result);
120 
121  template<class U> inline
122  const Tensor2_symmetric_Expr<Tensor2_symmetric<A,Tensor_Dim>,T,Dim,i,j> & operator<<=(const U &d);
123 
124 
125 };
126 
127 /* Specialized for Tensor3_dg_number_rhs_2 (Tensor3_dg with the
128  second index explicitly given). */
129 
130 template<class A, class T, int Dim, char i, char j, int N>
132 {
133  A &iter;
134 public:
135  Tensor2_symmetric_Expr(A &a): iter(a) {}
136  T & operator()(const int N1, const int N2)
137  {
138  return iter(N1,N2,N);
139  }
140  T operator()(const int N1, const int N2) const
141  {
142  return iter(N1,N2,N);
143  }
144 
145  /* Various assignment operators. I have to explicitly declare the
146  second operator= because otherwise the compiler will generate its
147  own and not use the template code. */
148 
149  template<class B, class U>
151  T,Dim,i,j> &
152  operator=(const Tensor2_symmetric_Expr<B,U,Dim,i,j> &result);
153 
155  T,Dim,i,j> &
157  T,Dim,i,j> &result);
158 };
159 
160 /* Specialized for Tensor4_ddg_number_rhs_01 (Tensor4_ddg with the
161  first and second index explicitly given). */
162 
163 template<class A, class T, int Dim, char i, char j, int N0, int N1>
165 {
166  A &iter;
167 public:
168  Tensor2_symmetric_Expr(A &a): iter(a) {}
169  T & operator()(const int N2, const int N3)
170  {
171  return iter(N0,N1,N2,N3);
172  }
173  T operator()(const int N2, const int N3) const
174  {
175  return iter(N0,N1,N2,N3);
176  }
177 
178  /* Various assignment operators. I have to explicitly declare the
179  second operator= because otherwise the compiler will generate its
180  own and not use the template code. */
181 
182  template<class B, class U>
184  T,Dim,i,j> &
185  operator=(const Tensor2_symmetric_Expr<B,U,Dim,i,j> &result);
186 
188  T,Dim,i,j> &
190  T,Dim,i,j> &result);
191 };
192 
T operator()(const int N1, const int N2) const
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:22
const int N
Definition: speed_test.cpp:3