thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
LorentzRank3Tensor.h
1// -*- C++ -*-
2//
3// LorentzRank3Tensor.h is a part of ThePEG - Toolkit for HEP Event Generation
4// Copyright (C) 2003-2019 Peter Richardson, Leif Lonnblad
5//
6// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7// Please respect the MCnet academic guidelines, see GUIDELINES for details.
8//
9#ifndef ThePEG_LorentzRank3Tensor_H
10#define ThePEG_LorentzRank3Tensor_H
11// This is the declaration of the LorentzRank3Tensor class.
12
15#include "LorentzTensor.h"
16
17namespace ThePEG {
18namespace Helicity {
19
20// compiler magic needs these pre-declarations to make friend templates work
21template<typename Value> class LorentzRank3Tensor;
22
36template<typename Value>
38
39public:
40
44 LorentzRank3Tensor() = default;
45
49 complex<Value> operator () (int i, int j, int k) const {
50 assert( i>=0 && i<=3 && j>=0 && j<=3 && k>=0 && k<=3);
51 return _tensor[i][j][k];
52 }
53
57 complex<Value> & operator () (int i, int j, int k) {
58 assert( i>=0 && i<=3 && j>=0 && j<=3 && k>=0 && k<=3);
59 return _tensor[i][j][k];
60 }
62
68 LorentzRank3Tensor & boost(double,double,double);
69
74 return boost(b.x(), b.y(), b.z());
75 }
76
81 unsigned int ix,iy,iz,ixa,iya,iza;
83 complex<Value> temp;
84 for(ix=0;ix<4;++ix) {
85 for(iy=0;iy<4;++iy) {
86 for(iz=0;iz<4;++iz) {
87 output(ix,iy,iz) = complex<Value>();
88 for(ixa=0;ixa<4;++ixa) {
89 for(iya=0;iya<4;++iya) {
90 for(iza=0;iza<4;++iza)
91 output(ix,iy,iz) += r(ix,ixa)*r(iy,iya)*r(iz,iza)*(*this)(ixa,iya,iza);
92 }
93 }
94 }
95 }
96 }
97 *this=output;
98 return *this;
99 }
100
106 for(unsigned int ix=0;ix<4;++ix) {
107 for(unsigned int iy=0;iy<4;++iy) {
108 for(unsigned int iz=0;iz<4;++iz) {
109 output(ix,iy,iz) = conj(_tensor[ix][iy][iz]);
110 }
111 }
112 }
113 return output;
114 }
115
117
124 for(int ix=0;ix<4;++ix)
125 for(int iy=0;iy<4;++iy)
126 for(int iz=0;iz<4;++iz) _tensor[ix][iy][iz]*=a;
127 return *this;
128 }
129
133 template <typename T, typename U>
134 friend auto
135 operator*(const LorentzRank3Tensor<T> & t, const LorentzRank3Tensor<U> & u) -> decltype(t.xx()*u.xx());
136
142 for(int ix=0;ix<4;++ix)
143 for(int iy=0;iy<4;++iy)
144 for(int iz=0;iz<4;++iz) output(ix,iy,iz) = _tensor[ix][iy][iz] + in(ix,iy,iz);
145 }
146
152 for(int ix=0;ix<4;++ix)
153 for(int iy=0;iy<4;++iy)
154 for(int iz=0;iz<4;++iz) output(ix,iy,iz) = _tensor[ix][iy][iz] - in(ix,iy,iz);
155 }
156
160 template<typename ValueB>
161 auto dot(const LorentzVector<complex<ValueB> > & vec, unsigned int iloc) const
162 -> LorentzTensor<decltype(ValueB()*Value())> {
163 LorentzTensor<decltype(ValueB()*Value())> output;
164 if(iloc==0) {
165 for(unsigned int iy=0;iy<4;++iy) {
166 for(unsigned int iz=0;iz<4;++iz) {
167 output(iy,iz) =
168 vec.t()*_tensor[3][iy][iz] - vec.x()*_tensor[0][iy][iz] -
169 vec.y()*_tensor[1][iy][iz] - vec.z()*_tensor[2][iy][iz];
170 }
171 }
172 }
173 else if(iloc==1) {
174 for(unsigned int iy=0;iy<4;++iy) {
175 for(unsigned int iz=0;iz<4;++iz) {
176 output(iy,iz) =
177 vec.t()*_tensor[iy][3][iz] - vec.x()*_tensor[iy][0][iz] -
178 vec.y()*_tensor[iy][1][iz] - vec.z()*_tensor[iy][2][iz];
179 }
180 }
181 }
182 else if(iloc==2) {
183 for(unsigned int iy=0;iy<4;++iy) {
184 for(unsigned int iz=0;iz<4;++iz) {
185 output(iy,iz) =
186 vec.t()*_tensor[iy][iz][3] - vec.x()*_tensor[iy][iz][0] -
187 vec.y()*_tensor[iy][iz][1] - vec.z()*_tensor[iy][iz][2];
188 }
189 }
190 }
191 else
192 assert(false);
193 return output;
194 }
195
199 auto dot (const Lorentz5Momentum & vec,unsigned int iloc) const
200 -> LorentzTensor<decltype(vec.x()*Value())>
201 {
202 LorentzTensor<decltype(vec.x()*Value())> output;
203 if(iloc==0) {
204 for(unsigned int iy=0;iy<4;++iy) {
205 for(unsigned int iz=0;iz<4;++iz) {
206 output(iy,iz) =
207 vec.t()*_tensor[3][iy][iz] - vec.x()*_tensor[0][iy][iz] -
208 vec.y()*_tensor[1][iy][iz] - vec.z()*_tensor[2][iy][iz];
209 }
210 }
211 }
212 else if(iloc==1) {
213 for(unsigned int iy=0;iy<4;++iy) {
214 for(unsigned int iz=0;iz<4;++iz) {
215 output(iy,iz) =
216 vec.t()*_tensor[iy][3][iz] - vec.x()*_tensor[iy][0][iz] -
217 vec.y()*_tensor[iy][1][iz] - vec.z()*_tensor[iy][2][iz];
218 }
219 }
220 }
221 else if(iloc==2) {
222 for(unsigned int iy=0;iy<4;++iy) {
223 for(unsigned int iz=0;iz<4;++iz) {
224 output(iy,iz) =
225 vec.t()*_tensor[iy][iz][3] - vec.x()*_tensor[iy][iz][0] -
226 vec.y()*_tensor[iy][iz][1] - vec.z()*_tensor[iy][iz][2];
227 }
228 }
229 }
230 else
231 assert(false);
232 return output;
233 }
235
236private:
237
241 std::array<std::array<std::array<complex<Value>,4>,4>,4> _tensor;
242
243};
244
248template<typename T, typename U>
249inline auto
250operator*(complex<U> a, const LorentzRank3Tensor<T> & t) -> LorentzRank3Tensor<decltype(a.real()*t.xx().real())> {
251 LorentzRank3Tensor<decltype(a.real()*t.xx().real())> output;
252 for(int ix=0;ix<4;++ix)
253 for(int iy=0;iy<4;++iy)
254 for(int iz=0;iz<4;++iz) output(ix,iy,iz) = a*t(ix,iy,iz);
255 return output;
256}
257
261template<typename T, typename U>
262inline auto
263operator*(const LorentzRank3Tensor<T> & t,complex<U> a) -> LorentzRank3Tensor<decltype(a.real()*t.xx().real())> {
264 LorentzRank3Tensor<decltype(a.real()*t.xx().real())> output;
265 for(int ix=0;ix<4;++ix)
266 for(int iy=0;iy<4;++iy)
267 for(int iz=0;iz<4;++iz) output(ix,iy,iz) = a*t(ix,iy,iz);
268 return output;
269}
270
271}
272}
273
274#ifndef ThePEG_TEMPLATES_IN_CC_FILE
275#include "LorentzRank3Tensor.tcc"
276#endif
277
278#endif
Overloads for operations on complex physical quantities.
This is the main config header file for ThePEG.
The LorentzRank3Tensor class is designed to implement the storage of a complex tensor to be used to r...
auto dot(const Lorentz5Momentum &vec, unsigned int iloc) const -> LorentzTensor< decltype(vec.x() *Value())>
dot product with momentum
LorentzRank3Tensor< Value > operator+(const LorentzRank3Tensor< Value > &in) const
Addition.
LorentzRank3Tensor()=default
Default zero constructor.
auto dot(const LorentzVector< complex< ValueB > > &vec, unsigned int iloc) const -> LorentzTensor< decltype(ValueB() *Value())>
Dot product with the ith index.
LorentzRank3Tensor & boost(double, double, double)
Standard Lorentz boost specifying the components of the beta vector.
friend auto operator*(const LorentzRank3Tensor< T > &t, const LorentzRank3Tensor< U > &u) -> decltype(t.xx() *u.xx())
Scalar product with other tensor.
LorentzRank3Tensor< Value > conjugate()
Return the complex conjugate.
LorentzRank3Tensor< Value > operator-(const LorentzRank3Tensor< Value > &in) const
Subtraction.
std::array< std::array< std::array< complex< Value >, 4 >, 4 >, 4 > _tensor
The components.
LorentzRank3Tensor & transform(const SpinOneLorentzRotation &r)
General Lorentz transformation.
LorentzRank3Tensor< Value > & boost(const Boost &b)
Standard Lorentz boost specifying the beta vector.
complex< Value > operator()(int i, int j, int k) const
Get components by indices.
LorentzRank3Tensor< Value > operator*=(Complex a)
Scaling with a complex number.
The LorentzTensor class is designed to implement the storage of a complex tensor to be used to repres...
Definition: LorentzTensor.h:37
A 4-component Lorentz vector.
Definition: LorentzVector.h:44
The SpinOneLorentzRotation class is ...
A 3-component vector.
Definition: ThreeVector.h:35
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
std::complex< double > Complex
ThePEG code should use Complex for all complex scalars.
Definition: Complex.h:23