QDP++
qdp_globalfuncs.h
Go to the documentation of this file.
1// -*- C++ -*-
2
6
7#ifndef QDP_GLOBALFUNCS_H
8#define QDP_GLOBALFUNCS_H
9
10namespace QDP
11{
12
18 //-----------------------------------------------
19 // Global sums
21
25 template<class T, class C>
26 inline typename UnaryReturn<C, FnSum>::Type_t
27 sum(const QDPType<T,C>& s1)
28 {
29 return sum(PETE_identity(s1));
30 }
31
32
34
38 template<class T, class C>
39 inline typename UnaryReturn<C, FnSum>::Type_t
40 sum(const QDPType<T,C>& s1, const Subset& s)
41 {
42 return sum(PETE_identity(s1),s);
43 }
44
45
47
53 template<class T, class C>
56 {
57 return sum(localNorm2(s1));
58 }
59
60 template<class T, class C>
63 {
64 return sum(localNorm2(s1));
65 }
66
67
69
75 template<class T, class C>
77 norm2(const QDPType<T,C>& s1, const Subset& s)
78 {
79 return sum(localNorm2(s1),s);
80 }
81
82 template<class T, class C>
84 norm2(const QDPExpr<T,C>& s1, const Subset& s)
85 {
86 return sum(localNorm2(s1),s);
87 }
88
89
91
96 template<class T1, class C1, class T2, class C2>
99 {
100 return sum(localInnerProduct(s1,s2));
101 }
102
103 template<class T1, class C1, class T2, class C2>
106 {
107 return sum(localInnerProduct(s1,s2));
108 }
109
110 template<class T1, class C1, class T2, class C2>
113 {
114 return sum(localInnerProduct(s1,s2));
115 }
116
117 template<class T1, class C1, class T2, class C2>
120 {
121 return sum(localInnerProduct(s1,s2));
122 }
123
124
126
131 template<class T1, class C1, class T2, class C2>
134 const Subset& s)
135 {
136 return sum(localInnerProduct(s1,s2),s);
137 }
138
139 template<class T1, class C1, class T2, class C2>
142 const Subset& s)
143 {
144 return sum(localInnerProduct(s1,s2),s);
145 }
146
147 template<class T1, class C1, class T2, class C2>
150 const Subset& s)
151 {
152 return sum(localInnerProduct(s1,s2),s);
153 }
154
155 template<class T1, class C1, class T2, class C2>
158 const Subset& s)
159 {
160 return sum(localInnerProduct(s1,s2),s);
161 }
162
163
165
170 template<class T1, class C1, class T2, class C2>
173 {
174 return sum(localInnerProductReal(s1,s2));
175 }
176
177 template<class T1, class C1, class T2, class C2>
180 {
181 return sum(localInnerProductReal(s1,s2));
182 }
183
184 template<class T1, class C1, class T2, class C2>
187 {
188 return sum(localInnerProductReal(s1,s2));
189 }
190
191 template<class T1, class C1, class T2, class C2>
194 {
195 return sum(localInnerProductReal(s1,s2));
196 }
197
198
200
205 template<class T1, class C1, class T2, class C2>
208 const Subset& s)
209 {
210 return sum(localInnerProductReal(s1,s2),s);
211 }
212
213 template<class T1, class C1, class T2, class C2>
216 const Subset& s)
217 {
218 return sum(localInnerProductReal(s1,s2),s);
219 }
220
221 template<class T1, class C1, class T2, class C2>
224 const Subset& s)
225 {
226 return sum(localInnerProductReal(s1,s2),s);
227 }
228
229 template<class T1, class C1, class T2, class C2>
232 const Subset& s)
233 {
234 return sum(localInnerProductReal(s1,s2),s);
235 }
236
237
238 //-----------------------------------------------------------------------------
239 // Multiple global sums
241
249 template<class T, class C>
251 sumMulti(const QDPType<T,C>& s1, const Set& ss)
252 {
253 return sumMulti(PETE_identity(s1), ss);
254 }
255
256
257 //-----------------------------------------------
258 // Global max and min
260
263 template<class T, class C>
266 {
267 return globalMax(PETE_identity(s1));
268 }
269
270
272
275 template<class T, class C>
278 {
279 return globalMin(PETE_identity(s1));
280 }
281
282
283 //-----------------------------------------------------------------------------
284 // These functions always return bool
286
289 template<class T, class C>
290 inline bool
292 {
293 return isnan(C(s1));
294 }
295
297
300 template<class T, class C>
301 inline bool
303 {
304 return isinf(C(s1));
305 }
306
308
311 template<class T, class C>
312 inline bool
314 {
315 return isnormal(C(s1));
316 }
317
319
322 template<class T, class C>
323 inline bool
325 {
326 return isfinite(C(s1));
327 }
328
329 // end of group3
331
332
338
339 //-----------------------------------------------
340 // Spin projection
342
343 template<class T, class C>
345 spinProject(const QDPType<T,C>& s1, int mu, int isign)
346 {
347 typedef typename UnaryReturn<C, FnSpinProject>::Type_t Ret_t;
348 Ret_t d;
349
350 switch (isign)
351 {
352 case -1:
353 switch (mu)
354 {
355 case 0:
356 d = spinProjectDir0Minus(s1);
357 break;
358 case 1:
359 d = spinProjectDir1Minus(s1);
360 break;
361 case 2:
362 d = spinProjectDir2Minus(s1);
363 break;
364 case 3:
365 d = spinProjectDir3Minus(s1);
366 break;
367 default:
368 std::cerr << "Spin project: illegal direction\n";
369 exit(1);
370 }
371 break;
372
373 case +1:
374 switch (mu)
375 {
376 case 0:
377 d = spinProjectDir0Plus(s1);
378 break;
379 case 1:
380 d = spinProjectDir1Plus(s1);
381 break;
382 case 2:
383 d = spinProjectDir2Plus(s1);
384 break;
385 case 3:
386 d = spinProjectDir3Plus(s1);
387 break;
388 default:
389 std::cerr << "Spin project: illegal direction\n";
390 exit(1);
391 }
392 break;
393
394 default:
395 std::cerr << "Spin project: isign must be pos or neg.\n";
396 exit(1);
397 }
398
399 return d;
400 }
401
402
403 //-----------------------------------------------
404 // Spin reconstruction
406
407 template<class T, class C>
409 spinReconstruct(const QDPType<T,C>& s1, int mu, int isign)
410 {
411 // typedef typename UnaryReturn<C, FnSpinReconstruct>::Type_t Ret_t;
412 // Ret_t d;
413
414 switch (isign)
415 {
416 case -1:
417 switch (mu)
418 {
419 case 0:
420 return spinReconstructDir0Minus(s1);
421 case 1:
422 return spinReconstructDir1Minus(s1);
423 case 2:
424 return spinReconstructDir2Minus(s1);
425 case 3:
426 return spinReconstructDir3Minus(s1);
427 default:
428 std::cerr << "Spin reconstruct: illegal direction\n";
429 exit(1);
430 }
431 break;
432
433 case +1:
434 switch (mu)
435 {
436 case 0:
437 return spinReconstructDir0Plus(s1);
438 case 1:
439 return spinReconstructDir1Plus(s1);
440 case 2:
441 return spinReconstructDir2Plus(s1);
442 case 3:
443 return spinReconstructDir3Plus(s1);
444 default:
445 std::cerr << "Spin reconstruct: illegal direction\n";
446 exit(1);
447 }
448 break;
449
450 default:
451 std::cerr << "Spin reconstruct: isign must be pos or neg.\n";
452 exit(1);
453 }
454
455 // return d;
456 }
457
458 // end of group5
460
461} // namespace QDP
462
463#endif
Expression class for QDP.
Definition qdp_qdpexpr.h:16
QDPType - major type class/container for all QDP objects.
Definition qdp_qdptype.h:29
Set - collection of subsets controlling which sites are involved in an operation.
Definition qdp_subset.h:96
Subsets - controls how lattices are looped.
Definition qdp_subset.h:39
BinaryReturn< C1, C2, FnInnerProductReal >::Type_t innerProductReal(const QDPType< T1, C1 > &s1, const QDPType< T2, C2 > &s2)
OScalar = innerProductReal(adj(source1)*source2).
UnaryReturn< C, FnGlobalMin >::Type_t globalMin(const QDPType< T, C > &s1)
OScalar = globalMin(source).
UnaryReturn< C, FnNorm2 >::Type_t norm2(const QDPType< T, C > &s1)
OScalar = norm2(trace(adj(source)*source)).
bool isnan(const QDPExpr< T, C > &s1)
bool = isnan(source)
bool isfinite(const QDPExpr< T, C > &s1)
bool = isfinite(source)
BinaryReturn< C1, C2, FnInnerProduct >::Type_t innerProduct(const QDPType< T1, C1 > &s1, const QDPType< T2, C2 > &s2)
OScalar = innerProduct(adj(source1)*source2).
bool isnormal(const QDPExpr< T, C > &s1)
bool = isnormal(source)
bool isinf(const QDPExpr< T, C > &s1)
bool = isinf(source)
UnaryReturn< C, FnGlobalMax >::Type_t globalMax(const QDPType< T, C > &s1)
OScalar = globalMax(source).
UnaryReturn< C, FnSumMulti >::Type_t sumMulti(const QDPType< T, C > &s1, const Set &ss)
dest = sumMulti(source1,Set)
UnaryReturn< C, FnSum >::Type_t sum(const QDPType< T, C > &s1)
OScalar = sum(source).
UnaryReturn< C, FnSpinProject >::Type_t spinProject(const QDPType< T, C > &s1, int mu, int isign)
dest = spinProject(source1)
UnaryReturn< C, FnSpinReconstruct >::Type_t spinReconstruct(const QDPType< T, C > &s1, int mu, int isign)
dest = spinReconstruct(source1)
OLattice< PScalar< PColorMatrix< RComplexFloat, 3 > > > C
Yet another random number generator.
MakeReturn< UnaryNode< FnSpinProjectDir2Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir2Minus >::Type_t >::Expression_t spinProjectDir2Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5128
MakeReturn< UnaryNode< FnSpinProjectDir1Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir1Minus >::Type_t >::Expression_t spinProjectDir1Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5115
MakeReturn< UnaryNode< FnSpinProjectDir0Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir0Plus >::Type_t >::Expression_t spinProjectDir0Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5050
MakeReturn< UnaryNode< FnSpinReconstructDir2Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir2Minus >::Type_t >::Expression_t spinReconstructDir2Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5232
MakeReturn< BinaryNode< FnLocalInnerProductReal, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, FnLocalInnerProductReal >::Type_t >::Expression_t localInnerProductReal(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
Definition qdp.h:2428
MakeReturn< UnaryNode< OpIdentity, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, OpIdentity >::Type_t >::Expression_t PETE_identity(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5531
MakeReturn< UnaryNode< FnSpinReconstructDir2Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir2Plus >::Type_t >::Expression_t spinReconstructDir2Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5180
MakeReturn< UnaryNode< FnSpinProjectDir3Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir3Minus >::Type_t >::Expression_t spinProjectDir3Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5141
MakeReturn< UnaryNode< FnSpinReconstructDir0Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir0Plus >::Type_t >::Expression_t spinReconstructDir0Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5154
MakeReturn< UnaryNode< FnSpinReconstructDir1Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir1Plus >::Type_t >::Expression_t spinReconstructDir1Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5167
MakeReturn< UnaryNode< FnSpinReconstructDir1Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir1Minus >::Type_t >::Expression_t spinReconstructDir1Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5219
MakeReturn< UnaryNode< FnSpinProjectDir2Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir2Plus >::Type_t >::Expression_t spinProjectDir2Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5076
MakeReturn< BinaryNode< FnLocalInnerProduct, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, FnLocalInnerProduct >::Type_t >::Expression_t localInnerProduct(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
Definition qdp.h:2412
MakeReturn< UnaryNode< FnSpinProjectDir3Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir3Plus >::Type_t >::Expression_t spinProjectDir3Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5089
MakeReturn< UnaryNode< FnSpinReconstructDir3Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir3Minus >::Type_t >::Expression_t spinReconstructDir3Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5245
MakeReturn< UnaryNode< FnSpinReconstructDir0Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir0Minus >::Type_t >::Expression_t spinReconstructDir0Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5206
MakeReturn< UnaryNode< FnSpinProjectDir0Minus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir0Minus >::Type_t >::Expression_t spinProjectDir0Minus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5102
MakeReturn< UnaryNode< FnLocalNorm2, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnLocalNorm2 >::Type_t >::Expression_t localNorm2(const QDPExpr< T1, C1 > &l)
Definition qdp.h:4998
MakeReturn< UnaryNode< FnSpinReconstructDir3Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinReconstructDir3Plus >::Type_t >::Expression_t spinReconstructDir3Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5193
MakeReturn< UnaryNode< FnSpinProjectDir1Plus, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnSpinProjectDir1Plus >::Type_t >::Expression_t spinProjectDir1Plus(const QDPExpr< T1, C1 > &l)
Definition qdp.h:5063
Promote< T1, T2 >::Type_t Type_t