QDP++
qdp_primcolorvec.h
Go to the documentation of this file.
1// -*- C++ -*-
2
6
7
8#ifndef QDP_PRIMCOLORVEC_H
9#define QDP_PRIMCOLORVEC_H
10
11namespace QDP {
12
13//-------------------------------------------------------------------------------------
21
23template <class T, int N> class PColorVector : public PVector<T, N, PColorVector>
24{
25public:
27
28 template<class T1>
29 inline
31 {
32 this->assign(rhs);
33 return *this;
34 }
35
36};
37 // end of group primcolorvector
39
40//-----------------------------------------------------------------------------
41// Traits classes
42//-----------------------------------------------------------------------------
43
44// Underlying word type
45template<class T1, int N>
46struct WordType<PColorVector<T1,N> >
47{
48 typedef typename WordType<T1>::Type_t Type_t;
49};
50
51
52
53template<class T1, int N>
58
59
60template<class T1, int N>
65
66
67// Internally used scalars
68template<class T, int N>
72
73// Makes a primitive scalar leaving other indices along
74template<class T, int N>
78
79// Makes a lattice scalar leaving primitive indices alone
80template<class T, int N>
84
85//-----------------------------------------------------------------------------
86// Traits classes to support return types
87//-----------------------------------------------------------------------------
88
89// Default unary(PColorVector) -> PColorVector
90template<class T1, int N, class Op>
94// Default binary(PScalar,PColorVector) -> PColorVector
95template<class T1, class T2, int N, class Op>
99
100// Default binary(PColorMatrix,PColorVector) -> PColorVector
101template<class T1, class T2, int N, class Op>
105
106// Default binary(PColorVector,PScalar) -> PColorVector
107template<class T1, class T2, int N, class Op>
111
112// Default binary(PColorVector,PColorVector) -> PColorVector
113template<class T1, class T2, int N, class Op>
117
118
119#if 0
120template<class T1, class T2>
121struct UnaryReturn<PScalar<T2>, OpCast<T1> > {
123// typedef T1 Type_t;
124};
125#endif
126
127
128// Assignment is different
129template<class T1, class T2, int N>
133
134template<class T1, class T2, int N>
138
139template<class T1, class T2, int N>
143
144template<class T1, class T2, int N>
148
149template<class T1, class T2, int N>
153
154
155// ColorVector
156template<class T, int N>
160
161template<class T, int N>
165
166template<class T, int N>
170
171template<class T1, class T2, int N>
175
176template<class T1, class T2, int N>
180
181template<class T1, class T2, int N>
185
186template<class T1, class T2, int N>
190
191
192
193
194//-----------------------------------------------------------------------------
195// Operators
196//-----------------------------------------------------------------------------
197
199template<class T1, class T2, int N>
203
204template<class T1, class T2, int N>
207{
209
210 // The traceColor is eaten here
211 d.elem() = adj(l.elem(0)) * r.elem(0);
212 for(int k=1; k < N; ++k)
213 d.elem() += adj(l.elem(k)) * r.elem(k);
214
215 return d;
216}
217
218
219//-----------------------------------------------
220// Peeking and poking
222template<class T, int N>
226
227template<class T, int N>
229peekColor(const PColorVector<T,N>& l, int row)
230{
232
233 // Note, do not need to propagate down since the function is eaten at this level
234 d.elem() = l.elem(row);
235 return d;
236}
237
239template<class T1, class T2, int N>
240inline PColorVector<T1,N>&
242{
243 // Note, do not need to propagate down since the function is eaten at this level
244 l.elem(row) = r.elem();
245 return l;
246}
247
248
249//-----------------------------------------------------------------------------
250// Contraction for color vectors
251// colorContract
252template<class T1, class T2, class T3, int N>
256
258
264template<class T1, class T2, class T3>
267{
269
270 // Permutations: +(0,1,2)+(1,2,0)+(2,0,1)-(1,0,2)-(0,2,1)-(2,1,0)
271
272 // d = \epsilon^{i,j,k} V1^{i} V2^{j} V3^{k}
273 d.elem() = (s1.elem(0)*s2.elem(1)
274 - s1.elem(1)*s2.elem(0))*s3.elem(2)
275 + (s1.elem(1)*s2.elem(2)
276 - s1.elem(2)*s2.elem(1))*s3.elem(0)
277 + (s1.elem(2)*s2.elem(0)
278 - s1.elem(0)*s2.elem(2))*s3.elem(1);
279
280 return d;
281}
282
283
284//-----------------------------------------------------------------------------
285// Contraction for color vectors
286// colorContract
287template<class T1, class T2, int N>
291
293
297template<class T1, class T2, int N>
300{
302
303 // d = V1^{i} V2^{i}
304 d.elem() = s1.elem(0)*s2.elem(0);
305 for(int i=1; i < N; ++i)
306 d.elem() += s1.elem(i)*s2.elem(i);
307
308 return d;
309}
310
311
312//-----------------------------------------------------------------------------
313// diquark color cross product s1 X s2
315template<class T1, class T2>
319
321
327template<class T1, class T2>
330{
332
333 d.elem(0) = s1.elem(1)*s2.elem(2) - s1.elem(2)*s2.elem(1);
334 d.elem(1) = s1.elem(2)*s2.elem(0) - s1.elem(0)*s2.elem(2);
335 d.elem(2) = s1.elem(0)*s2.elem(1) - s1.elem(1)*s2.elem(0);
336
337 return d;
338}
339
340
341
342} // namespace QDP
343
344#endif
345
Primitive color Matrix class.
Primitive color Vector class.
PColorVector & operator=(const PColorVector< T1, N > &rhs)
PColorVector = PColorVector.
Primitive Scalar.
T & elem(int i)
CC & assign(const PColorVector< T1, N > &rhs)
Yet another random number generator.
MakeReturn< BinaryNode< FnColorCrossProduct, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, FnColorCrossProduct >::Type_t >::Expression_t colorCrossProduct(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
Definition qdp.h:2396
MakeReturn< UnaryNode< FnAdjoint, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, typenameUnaryReturn< C1, FnAdjoint >::Type_t >::Expression_t adj(const QDPExpr< T1, C1 > &l)
Definition qdp.h:4842
MakeReturn< UnaryNode< FnPeekColorMatrix, typenameCreateLeaf< QDPExpr< T1, C1 > >::Leaf_t >, C1 >::Expression_t peekColor(const QDPExpr< T1, C1 > &l, int row, int col)
Definition qdp_newops.h:161
MakeReturn< TrinaryNode< FnColorContract, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPType< T2, C2 > >::Leaf_t, typenameCreateLeaf< typenameSimpleScalar< typenameWordType< C1 >::Type_t >::Type_t >::Leaf_t >, typenameTrinaryReturn< C1, C2, typenameSimpleScalar< typenameWordType< C1 >::Type_t >::Type_t, FnColorContract >::Type_t >::Expression_t colorContract(const QDPType< T1, C1 > &a, const QDPType< T2, C2 > &b, const typename WordType< C1 >::Type_t &c)
Definition qdp.h:4557
MakeReturn< BinaryNode< FnColorVectorContract, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, FnColorVectorContract >::Type_t >::Expression_t colorVectorContract(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
Definition qdp.h:2380
MakeReturn< BinaryNode< FnLocalColorInnerProduct, typenameCreateLeaf< QDPType< T1, C1 > >::Leaf_t, typenameCreateLeaf< QDPExpr< T2, C2 > >::Leaf_t >, typenameBinaryReturn< C1, C2, FnLocalColorInnerProduct >::Type_t >::Expression_t localColorInnerProduct(const QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r)
Definition qdp.h:2444
C1 & pokeColor(QDPType< T1, C1 > &l, const QDPExpr< T2, C2 > &r, int row, int col)
Definition qdp_newops.h:360
PColorVector< typename BinaryReturn< T1, T2, Op >::Type_t, N > Type_t
PColorVector< typename BinaryReturn< T1, T2, FnColorCrossProduct >::Type_t, 3 > Type_t
PScalar< typename BinaryReturn< T1, T2, FnLocalInnerProductReal >::Type_t > Type_t
PScalar< typename BinaryReturn< T1, T2, FnLocalColorInnerProduct >::Type_t > Type_t
PScalar< typename BinaryReturn< T1, T2, FnLocalInnerProduct >::Type_t > Type_t
PScalar< typename BinaryReturn< T1, T2, FnInnerProductReal >::Type_t > Type_t
PScalar< typename BinaryReturn< T1, T2, FnInnerProduct >::Type_t > Type_t
PColorVector< typename BinaryReturn< T1, T2, Op >::Type_t, N > Type_t
PScalar< typename BinaryReturn< T1, T2, FnColorVectorContract >::Type_t > Type_t
PColorVector< typename BinaryReturn< T1, T2, Op >::Type_t, N > Type_t
PColorVector< typename BinaryReturn< T1, T2, Op >::Type_t, N > Type_t
PColorVector< typename DoublePrecType< T1 >::Type_t, N > Type_t
Structure for extracting color vector components.
Definition qdp_newops.h:173
PScalar< typename InternalScalar< T >::Type_t > Type_t
Construct simple word type used at some level within primitives.
Definition qdp_traits.h:98
PColorVector< typename LatticeScalar< T >::Type_t, N > Type_t
Makes a lattice scalar leaving primitive indices alone.
Definition qdp_traits.h:108
PScalar< typename PrimitiveScalar< T >::Type_t > Type_t
Makes a primitive scalar leaving grid alone.
Definition qdp_traits.h:103
PColorVector< typename SinglePrecType< T1 >::Type_t, N > Type_t
PColorVector< typename UnaryReturn< T1, Op >::Type_t, N > Type_t
PScalar< typename UnaryReturn< T, FnLocalNorm2 >::Type_t > Type_t
PScalar< typename UnaryReturn< T, FnNorm2 >::Type_t > Type_t
PScalar< typename UnaryReturn< T, FnPeekColorVector >::Type_t > Type_t
PColorVector< typename UnaryReturn< T, FnSumMulti >::Type_t, N > Type_t
Find the underlying word type of a field.
Definition qdp_traits.h:29