Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F8309845
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Subscribers
None
View Options
diff --git a/include/HEJ/Tensor.hh b/include/HEJ/Tensor.hh
index 4afda37..0bf7c91 100644
--- a/include/HEJ/Tensor.hh
+++ b/include/HEJ/Tensor.hh
@@ -1,333 +1,380 @@
/** \file
* \brief Tensor Template Class declaration.
*
* This file contains the declaration of the Tensor Template class. This
* is used to calculate some of the more complex currents within the
* W+Jets implementation particularly.
*
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019
* \copyright GPLv2 or later
*/
#pragma once
#include <array>
///@TODO remove function implementation from header
///@TODO put in some namespace
template <unsigned int N, unsigned int D>
class Tensor{
public:
- //Constructor
+ //! Constructor
Tensor();
Tensor(COM x);
- //Destructor
+ //! Destructor
virtual ~Tensor();
+ /**
+ *\brief Returns Rank of Tensor (N in T<N,D>)
+ */
int rank();
+ /**
+ *\brief Returns dimension of Tensor (D in T<N,D>)
+ */
int dim();
+ /**
+ *\brief Returns dim of Tensor
+ */
int len();
+ /**
+ *\brief Value of rank 1 Tensor for given i value.
+ */
COM at(int i);
+
+ /**
+ *\brief Value of rank 2 Tensor for given (i,j) value.
+ */
COM at(int i, int j);
+
+ /**
+ *\brief Value of rank 3 Tensor for given (i,j,k) value.
+ */
COM at(int i, int j, int k);
+
+ /**
+ *\brief Value of rank 4 Tensor for given (i,j,k,l) value.
+ */
COM at(int i,int j, int k,int l);
+
+ /**
+ *\brief Value of rank 3 Tensor for given (i,j,k,l,m) value.
+ */
COM at(int i,int j, int k,int l, int m);
+ /**
+ *\brief Checks that components of Tensor non zero.
+ */
bool isSet();
void Fill(COM x);
- //Set component indexed by i,j,k,l,m
+ /**
+ *\brief Set value of rank 1 Tensor for given i value to x.
+ */
void Set(int i,COM x);
+ /**
+ *\brief Set value of rank 2 Tensor for given i,j value to x.
+ */
void Set(int i, int j, COM x);
+ /**
+ *\brief Set value of rank 3 Tensor for given i,j,k value to x.
+ */
void Set(int i, int j, int k, COM x);
+ /**
+ *\brief Set value of rank 4 Tensor for given i,j,k,l value to x.
+ */
void Set(int i,int j, int k,int l,COM x);
+ /**
+ *\brief Set value of rank 5 Tensor for given i,j,k,l,m value to x.
+ */
void Set(int i,int j, int k,int l, int m, COM x);
Tensor<N,D> operator*(const double x);
Tensor<N,D> operator*(const COM x);
Tensor<N,D> operator/(const double x);
Tensor<N,D> operator/(const COM x);
Tensor<N,D> operator+(const Tensor<N,D> T2);
Tensor<N,D> operator-(const Tensor<N,D> T2);
void operator+=(const Tensor<N,D> T2);
void operator-=(const Tensor<N,D> T2);
/**
* \brief Multiply Tensor from Right: T1^(mu1...mk..mN-1)T2_(muN)
* @param T2 Tensor of Rank 1 to multiply from right with with.
* @returns T1.contract(T2,1) -> T1^(mu,nu,rho...)T2^sigma
*/
Tensor<N+1,D> rightprod(const Tensor<1,D> T2);
/**
* \brief Multiply Tensor from Left: T2_(muN)T1^(mu1...mk..mN-1)
* @param T2 Tensor of Rank 1 to multiply from left with with.
* @returns T1.contract(T2,1) -> T2^sigma T1^(mu,nu,rho...)
*/
Tensor<N+1,D> leftprod(const Tensor<1,D> T2);
/**
* \brief T^(mu1...mk..mN)T2_(muk) contract kth index, where k member of [1,N]
* @param T2 Tensor of Rank 1 to contract with.
* @param k int to contract Tensor T2 with from original Tensor.
* @returns T1.contract(T2,1) -> T1^(mu,nu,rho...)T2_mu
*/
Tensor<N-1,D> contract(const Tensor<1,D> T2, int k);
std::valarray<COM> components;
private:
-
int size;
- COM sign(unsigned int i){
- if(i==0)
- return 1.;
- else
- return -1.;
- }
-
+ COM sign(unsigned int i);
};
template <unsigned int N, unsigned int D>
Tensor<N,D>::Tensor(){
size = pow(D,N);
components.resize(size);
}
template <unsigned int N, unsigned int D>
Tensor<N,D>::Tensor(COM x) {
size = pow(D,N);
components.resize(size, x);
}
template <unsigned int N, unsigned int D>
Tensor<N,D>::~Tensor() {}
template <unsigned int N, unsigned int D>
int Tensor<N,D>::rank(){
return N;
}
template <unsigned int N, unsigned int D>
int Tensor<N,D>::dim(){
return D;
}
template <unsigned int N, unsigned int D>
int Tensor<N,D>::len(){
return size;
}
template <unsigned int N, unsigned int D>
COM Tensor<N,D>::at(int i){
return components[i];
}
template <unsigned int N, unsigned int D>
COM Tensor<N,D>::at(int i, int j) {
return components[D*i +j];
}
template <unsigned int N, unsigned int D>
COM Tensor<N,D>::at(int i, int j, int k) {
return components[D*(D*i + j)+ k];
}
template <unsigned int N, unsigned int D>
COM Tensor<N,D>::at(int i,int j, int k,int l) {
return components[D*(D*(D*i +j) + k) + l];
}
template <unsigned int N, unsigned int D>
COM Tensor<N,D>::at(int i,int j, int k,int l, int m){
return components[D*(D*(D*(D*i + j) + k) + l) + m];
}
template <unsigned int N, unsigned int D>
bool Tensor<N,D>::isSet(){
if(components.size()==0)
return false;
else
return true;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::Fill(COM x){
components=x;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::Set(int i,COM x){
components[i] = x;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::Set(int i, int j, COM x) {
components[D*i +j] = x;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::Set(int i, int j, int k, COM x) {
components[D*(D*i + j)+ k] = x;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::Set(int i,int j, int k,int l,COM x) {
components[D*(D*(D*i +j) + k) + l] = x;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::Set(int i,int j, int k,int l, int m, COM x){
components[D*(D*(D*(D*i + j) + k) + l) + m] = x;
}
template <unsigned int N, unsigned int D>
Tensor<N,D> Tensor<N,D>::operator*(const double x){
Tensor<N,D> newT;
newT.components=components*COM(x,0);
return newT;
}
template <unsigned int N, unsigned int D>
Tensor<N,D> Tensor<N,D>::operator*(const COM x){
Tensor<N,D> newT;
newT.components=components*x;
return newT;
}
template <unsigned int N, unsigned int D>
Tensor<N,D> Tensor<N,D>::operator/(const double x){
Tensor<N,D> newT;
newT.components=components/COM(x,0);
return newT;
}
template <unsigned int N, unsigned int D>
Tensor<N,D> Tensor<N,D>::operator/(const COM x){
Tensor<N,D> newT;
newT.components=components/x;
return newT;
}
template <unsigned int N, unsigned int D>
Tensor<N,D> Tensor<N,D>::operator+(const Tensor<N,D> T2){
Tensor<N,D> newT;
newT.components=components+T2.components;
return newT;
}
template <unsigned int N, unsigned int D>
Tensor<N,D> Tensor<N,D>::operator-(const Tensor<N,D> T2){
Tensor<N,D> newT;
newT.components=components-T2.components;
return newT;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::operator+=(const Tensor<N,D> T2){
components = components+T2.components;
}
template <unsigned int N, unsigned int D>
void Tensor<N,D>::operator-=(const Tensor<N,D> T2){
components=components-T2.components;
}
template <unsigned int N, unsigned int D>
Tensor<N+1,D> Tensor<N,D>::rightprod(const Tensor<1,D> T2){
Tensor<N+1,D> newT;
for(int i=0; i<size;i++){
for(unsigned int j=0;j<D;j++){
newT.components[i*D+j]=components[i]*T2.components[j];
}
}
return newT;
}
template <unsigned int N, unsigned int D>
Tensor<N+1,D> Tensor<N,D>::leftprod(const Tensor<1,D> T2){
Tensor<N+1,D> newT;
for(unsigned int j=0;j<D;j++){
for(int i=0; i<size;i++){
newT.components[j*size+i]=components[i]*T2.components[j];
}
}
return newT;
}
template <unsigned int N, unsigned int D>
Tensor<N-1,D> Tensor<N,D>::contract(const Tensor<1,D> T2, int k){
Tensor<N-1,D> newT;
for(int j=0; j<newT.len(); j++){
COM temp;
int itemp = pow(D,(N-k));
for (unsigned int i=0; i<D; i++){
int index = D*itemp*floor(j/itemp) + itemp*i +j%(itemp);
temp+=components[index]*T2.components[i]*sign(i);
}
newT.components[j]=temp;
}
return newT;
}
+template <unsigned int N, unsigned int D>
+COM Tensor<N,D>::sign(unsigned int i){
+ if(i==0)
+ return 1.;
+ else
+ return -1.;
+}
+
+
/**
* \brief Returns +--- Metric
* @returns Metric (+,-,-,-) {(1,0,0,0),(0,-1,0,0),(0,0,-1,0),(0,0,0,-1)}
*/
Tensor<2,4> Metric();
/**
* \brief Calculates current <p1|mu|p2>
* @param p1 Momentum of Particle 1
* @param h1 Helicity of Particle 1 (Boolean, False = -h, True = +h)
* @param p2 Momentum of Particle 2
* @param h2 Helicity of Particle 2 (Boolean, False = -h, True = +h)
* @returns Tensor T^mu = <p1|mu|p2> (in/out configuration considered in calc)
*/
Tensor<1,4> TCurrent(CLHEP::HepLorentzVector p1, bool h1,
CLHEP::HepLorentzVector p2, bool h2);
/**
* \brief Calculates current <p1|mu nu rho|p2>
* @param p1 Momentum of Particle 1
* @param h1 Helicity of Particle 1 (Boolean, False = -h, True = +h)
* @param p2 Momentum of Particle 2
* @param h2 Helicity of Particle 2 (Boolean, False = -h, True = +h)
* @returns Tensor T^mu^nu^rho = <p1|mu nu rho|p2> (in/out configuration considered in calc)
*/
Tensor<3,4> T3Current(CLHEP::HepLorentzVector p1, bool h1,
CLHEP::HepLorentzVector p2, bool h2);
/**
* \brief Calculates current <p1|mu nu rho tau sigma|p2>
* @param p1 Momentum of Particle 1
* @param h1 Helicity of Particle 1 (Boolean, False = -h, True = +h)
* @param p2 Momentum of Particle 2
* @param h2 Helicity of Particle 2 (Boolean, False = -h, True = +h)
* @returns Tensor T^mu^nu^rho = <p1|mu nu rho tau sigma|p2> (in/out configuration considered in calc)
*/
Tensor<5,4> T5Current(CLHEP::HepLorentzVector p1, bool h1,
CLHEP::HepLorentzVector p2, bool h2);
/**
* \brief Convert from CCurrent class
* @param j Current in CCurrent format
* @returns Current in Tensor Format
*/
Tensor<1,4> Construct1Tensor(CCurrent j);
/**
* \brief Convert from HLV class
* @param p Current in HLV format
* @returns Current in Tensor Format
*/
Tensor<1,4> Construct1Tensor(CLHEP::HepLorentzVector p);
/**
* \brief Construct Epsilon (Polarisation) Tensor
* @param k Momentum of incoming/outgoing boson
* @param ref Reference momentum for calculation
* @param pol Polarisation of boson
* @returns Polarisation Tensor E^mu
*/
Tensor<1,4> eps(CLHEP::HepLorentzVector k, CLHEP::HepLorentzVector ref, bool pol);
bool init_sigma_index();
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Dec 21, 4:41 PM (22 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4023489
Default Alt Text
(10 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment