OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
TSVMetaUnary.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef TSV_META_UNARY_H
12 #define TSV_META_UNARY_H
13 
15 //
16 // Definition of the struct TSV_MetaUnary.
17 //
19 
20 template<class T1, class OP> struct TSV_MetaUnary {};
21 
23 //
24 // Specializations for Vektors of arbitrary size.
25 //
27 
28 template<class T1, class OP, unsigned D>
29 struct TSV_MetaUnary< Vektor<T1,D> , OP >
30 {
31  typedef typename PETEUnaryReturn<T1,OP>::type T0;
32  inline static Vektor<T0,D>
33  apply(const Vektor<T1,D>& lhs) {
34  Vektor<T0,D> ret;
35  for (unsigned d=0; d<D; ++d)
36  ret[d] = PETE_apply(OP(),lhs[d]);
37  return ret;
38  }
39 };
40 
42 //
43 // Specializations of TSV_MetaUnary for Vektors with D=1.
44 //
46 
47 template<class T1, class OP>
48 struct TSV_MetaUnary< Vektor<T1,1> , OP >
49 {
50  typedef typename PETEUnaryReturn<T1,OP>::type T0;
51  inline static Vektor<T0,1>
52  apply(const Vektor<T1,1>& lhs) {
53  return Vektor<T0,1>( PETE_apply( OP(), lhs[0] ) );
54  }
55 };
56 
58 //
59 // Specializations of TSV_MetaUnary for Vektors with D=2.
60 //
62 
63 template<class T1, class OP>
64 struct TSV_MetaUnary< Vektor<T1,2> , OP >
65 {
66  typedef typename PETEUnaryReturn<T1,OP>::type T0;
67  inline static Vektor<T0,2>
68  apply(const Vektor<T1,2>& lhs) {
69  return Vektor<T0,2>( PETE_apply( OP(), lhs[0] ) ,
70  PETE_apply( OP(), lhs[1] ) );
71  }
72 };
73 
75 //
76 // Specializations of TSV_MetaUnary for Vektors with D=3.
77 //
79 
80 template<class T1, class OP>
81 struct TSV_MetaUnary< Vektor<T1,3> , OP >
82 {
83  typedef typename PETEUnaryReturn<T1,OP>::type T0;
84  inline static Vektor<T0,3>
85  apply(const Vektor<T1,3>& lhs) {
86  return Vektor<T0,3>( PETE_apply( OP(), lhs[0] ) ,
87  PETE_apply( OP(), lhs[1] ) ,
88  PETE_apply( OP(), lhs[2] ) );
89  }
90 };
91 
93 //
94 // Specializations for Tenzors of arbitrary size.
95 //
97 
98 template<class T1, class OP, unsigned D>
99 struct TSV_MetaUnary< Tenzor<T1,D> , OP >
100 {
102  inline static Tenzor<T0,D>
103  apply(const Tenzor<T1,D>& lhs) {
104  Tenzor<T0,D> ret;
105  for (unsigned d=0; d<D*D; ++d)
106  ret[d] = PETE_apply(OP(),lhs[d]);
107  return ret;
108  }
109 };
110 
112 //
113 // Specializations of TSV_MetaUnary for Tenzors with D=1.
114 //
116 
117 template<class T1, class OP>
118 struct TSV_MetaUnary< Tenzor<T1,1> , OP >
119 {
121  inline static Tenzor<T0,1>
122  apply(const Tenzor<T1,1>& lhs) {
123  return Tenzor<T0,1>( PETE_apply( OP(), lhs[0] ) );
124  }
125 };
126 
128 //
129 // Specializations of TSV_MetaUnary for Tenzors with D=2.
130 //
132 
133 template<class T1, class OP>
134 struct TSV_MetaUnary< Tenzor<T1,2> , OP >
135 {
137  inline static Tenzor<T0,2>
138  apply(const Tenzor<T1,2>& lhs) {
139  return Tenzor<T0,2>( PETE_apply( OP(), lhs[0] ) ,
140  PETE_apply( OP(), lhs[1] ) ,
141  PETE_apply( OP(), lhs[2] ) ,
142  PETE_apply( OP(), lhs[3] ) );
143  }
144 };
145 
147 //
148 // Specializations of TSV_MetaUnary for Tenzors with D=3.
149 //
151 
152 template<class T1, class OP>
153 struct TSV_MetaUnary< Tenzor<T1,3> , OP >
154 {
156  inline static Tenzor<T0,3>
157  apply(const Tenzor<T1,3>& lhs) {
158  return Tenzor<T0,3>( PETE_apply( OP(), lhs[0] ) ,
159  PETE_apply( OP(), lhs[1] ) ,
160  PETE_apply( OP(), lhs[2] ) ,
161  PETE_apply( OP(), lhs[3] ) ,
162  PETE_apply( OP(), lhs[4] ) ,
163  PETE_apply( OP(), lhs[5] ) ,
164  PETE_apply( OP(), lhs[6] ) ,
165  PETE_apply( OP(), lhs[7] ) ,
166  PETE_apply( OP(), lhs[8] ) );
167  }
168 };
169 
171 //
172 // Specializations for SymTenzors of arbitrary size.
173 //
175 
176 template<class T1, class OP, unsigned D>
177 struct TSV_MetaUnary< SymTenzor<T1,D> , OP >
178 {
180  inline static SymTenzor<T0,D>
181  apply(const SymTenzor<T1,D>& lhs) {
182  SymTenzor<T0,D> ret;
183  for (unsigned d=0; d<D*(D+1)/2; ++d)
184  ret[d] = PETE_apply(OP(),lhs[d]);
185  return ret;
186  }
187 };
188 
190 //
191 // Specializations of TSV_MetaUnary for SymTenzors with D=1.
192 //
194 
195 template<class T1, class OP>
196 struct TSV_MetaUnary< SymTenzor<T1,1> , OP >
197 {
199  inline static SymTenzor<T0,1>
200  apply(const SymTenzor<T1,1>& lhs) {
201  return SymTenzor<T0,1>( PETE_apply( OP(), lhs[0] ) );
202  }
203 };
204 
206 //
207 // Specializations of TSV_MetaUnary for SymTenzors with D=2.
208 //
210 
211 template<class T1, class OP>
212 struct TSV_MetaUnary< SymTenzor<T1,2> , OP >
213 {
215  inline static SymTenzor<T0,2>
216  apply(const SymTenzor<T1,2>& lhs) {
217  return SymTenzor<T0,2>( PETE_apply( OP(), lhs[0] ) ,
218  PETE_apply( OP(), lhs[1] ) ,
219  PETE_apply( OP(), lhs[2] ) );
220  }
221 };
222 
224 //
225 // Specializations of TSV_MetaUnary for SymTenzors with D=3.
226 //
228 
229 template<class T1, class OP>
230 struct TSV_MetaUnary< SymTenzor<T1,3> , OP >
231 {
233  inline static SymTenzor<T0,3>
234  apply(const SymTenzor<T1,3>& lhs) {
235  return SymTenzor<T0,3>( PETE_apply( OP(), lhs[0] ) ,
236  PETE_apply( OP(), lhs[1] ) ,
237  PETE_apply( OP(), lhs[2] ) ,
238  PETE_apply( OP(), lhs[3] ) ,
239  PETE_apply( OP(), lhs[4] ) ,
240  PETE_apply( OP(), lhs[5] ) );
241  }
242 };
243 
245 //
246 // Specializations for AntiSymTenzors of arbitrary size.
247 //
249 
250 template<class T1, class OP, unsigned D>
251 struct TSV_MetaUnary< AntiSymTenzor<T1,D> , OP >
252 {
254  inline static AntiSymTenzor<T0,D>
257  for (unsigned d=0; d<D*(D-1)/2; ++d)
258  ret[d] = PETE_apply(OP(),lhs[d]);
259  return ret;
260  }
261 };
262 
264 //
265 // Specializations of TSV_MetaUnary for AntiSymTenzors with D=1.
266 //
268 
269 template<class T1, class OP>
270 struct TSV_MetaUnary< AntiSymTenzor<T1,1> , OP >
271 {
273  inline static AntiSymTenzor<T0,1>
275  return AntiSymTenzor<T0,1>( PETE_apply( OP(), lhs[0] ) );
276  }
277 };
278 
280 //
281 // Specializations of TSV_MetaUnary for AntiSymTenzors with D=2.
282 //
284 
285 template<class T1, class OP>
286 struct TSV_MetaUnary< AntiSymTenzor<T1,2> , OP >
287 {
289  inline static AntiSymTenzor<T0,2>
291  return AntiSymTenzor<T0,2>( PETE_apply( OP(), lhs[0] ) );
292  }
293 };
294 
296 //
297 // Specializations of TSV_MetaUnary for AntiSymTenzors with D=3.
298 //
300 
301 template<class T1, class OP>
302 struct TSV_MetaUnary< AntiSymTenzor<T1,3> , OP >
303 {
305  inline static AntiSymTenzor<T0,3>
307  return AntiSymTenzor<T0,3>( PETE_apply( OP(), lhs[0] ) ,
308  PETE_apply( OP(), lhs[1] ) ,
309  PETE_apply( OP(), lhs[2] ) );
310  }
311 };
312 
314 
315 #endif // TSV_META_UNARY_H
316 
317 /***************************************************************************
318  * $RCSfile: TSVMetaUnary.h,v $ $Author: adelmann $
319  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $
320  * IPPL_VERSION_ID: $Id: TSVMetaUnary.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $
321  ***************************************************************************/
322 
void PETE_apply(const OpPeriodic< T > &e, T &a, const T &b)
Definition: BCond.hpp:373
Definition: TSVMeta.h:24
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:179
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:83
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:68
PETE_ComputeUnaryType< PETE_Type2Index< T >::val, Op::tag >::type type
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:66
static Tenzor< T0, D > apply(const Tenzor< T1, D > &lhs)
Definition: TSVMetaUnary.h:103
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:155
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:50
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:232
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:31
static AntiSymTenzor< T0, 2 > apply(const AntiSymTenzor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:290
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:214
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:198
static Tenzor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:138
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:253
static SymTenzor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:216
static AntiSymTenzor< T0, 1 > apply(const AntiSymTenzor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:274
static SymTenzor< T0, D > apply(const SymTenzor< T1, D > &lhs)
Definition: TSVMetaUnary.h:181
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:288
static AntiSymTenzor< T0, D > apply(const AntiSymTenzor< T1, D > &lhs)
Definition: TSVMetaUnary.h:255
static SymTenzor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:200
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:85
static SymTenzor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:234
static Tenzor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:122
static Vektor< T0, 1 > apply(const Vektor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:52
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:101
static AntiSymTenzor< T0, 3 > apply(const AntiSymTenzor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:306
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:136
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:272
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:304
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:120
static Tenzor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:157
static Vektor< T0, D > apply(const Vektor< T1, D > &lhs)
Definition: TSVMetaUnary.h:33