OPAL (Object Oriented Parallel Accelerator Library) 2022.1
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
20template<class T1, class OP> struct TSV_MetaUnary {};
21
23//
24// Specializations for Vektors of arbitrary size.
25//
27
28template<class T1, class OP, unsigned D>
29struct TSV_MetaUnary< Vektor<T1,D> , OP >
30{
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
47template<class T1, class OP>
48struct TSV_MetaUnary< Vektor<T1,1> , OP >
49{
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
63template<class T1, class OP>
64struct TSV_MetaUnary< Vektor<T1,2> , OP >
65{
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
80template<class T1, class OP>
81struct TSV_MetaUnary< Vektor<T1,3> , OP >
82{
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
98template<class T1, class OP, unsigned D>
99struct 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
117template<class T1, class OP>
118struct 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
133template<class T1, class OP>
134struct 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
152template<class T1, class OP>
153struct 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
176template<class T1, class OP, unsigned D>
177struct 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
195template<class T1, class OP>
196struct 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
211template<class T1, class OP>
212struct 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
229template<class T1, class OP>
230struct 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
250template<class T1, class OP, unsigned D>
251struct 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
269template<class T1, class OP>
270struct 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
285template<class T1, class OP>
286struct 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
301template<class T1, class OP>
302struct 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 > &, T &a, const T &b)
Definition: BCond.hpp:353
Definition: Tenzor.h:35
Definition: Vektor.h:32
static Vektor< T0, D > apply(const Vektor< T1, D > &lhs)
Definition: TSVMetaUnary.h:33
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:31
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:50
static Vektor< T0, 1 > apply(const Vektor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:52
static Vektor< T0, 2 > apply(const Vektor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:68
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:66
static Vektor< T0, 3 > apply(const Vektor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:85
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:83
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:101
static Tenzor< T0, D > apply(const Tenzor< T1, D > &lhs)
Definition: TSVMetaUnary.h:103
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:120
static Tenzor< T0, 1 > apply(const Tenzor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:122
static Tenzor< T0, 2 > apply(const Tenzor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:138
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:136
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:155
static Tenzor< T0, 3 > apply(const Tenzor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:157
static SymTenzor< T0, D > apply(const SymTenzor< T1, D > &lhs)
Definition: TSVMetaUnary.h:181
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:179
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:198
static SymTenzor< T0, 1 > apply(const SymTenzor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:200
static SymTenzor< T0, 2 > apply(const SymTenzor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:216
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:214
static SymTenzor< T0, 3 > apply(const SymTenzor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:234
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:232
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:253
static AntiSymTenzor< T0, D > apply(const AntiSymTenzor< T1, D > &lhs)
Definition: TSVMetaUnary.h:255
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:272
static AntiSymTenzor< T0, 1 > apply(const AntiSymTenzor< T1, 1 > &lhs)
Definition: TSVMetaUnary.h:274
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:288
static AntiSymTenzor< T0, 2 > apply(const AntiSymTenzor< T1, 2 > &lhs)
Definition: TSVMetaUnary.h:290
PETEUnaryReturn< T1, OP >::type T0
Definition: TSVMetaUnary.h:304
static AntiSymTenzor< T0, 3 > apply(const AntiSymTenzor< T1, 3 > &lhs)
Definition: TSVMetaUnary.h:306
PETE_ComputeUnaryType< T, Op, Op::tag >::type type