Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// File for Matrix/Tensor class usage. -*- C++ -*-
/* Copyright 2008 Mike Williams (mwill@jlab.org)
*
* This file is part of qft++.
*
* qft++ is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* qft++ is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with qft++. If not, see <http://www.gnu.org/licenses/>.
*/
// Author: Mike Williams
#ifndef _MatrixOfTensors_H
#define _MatrixOfTensors_H
//_____________________________________________________________________________
#include "qft++/topincludes/matrix.hh"
#include "qft++/topincludes/tensor.hh"
using namespace std;
//_____________________________________________________________________________
/** @file MatrixOfTensors.h
* @brief Defines functions for Matrix/Tensor class interactions.
*/
//_____________________________________________________________________________
//
// Functions for using Matrix<Tensor<T> >
//_____________________________________________________________________________
/// Set the rank of the Tensor elements of the Matrix
template<typename T> void SetRank(Matrix<Tensor<T> > &__matrix,int __rank){
for(int i = 0; i < __matrix.NumRows(); i++){
for(int j = 0; j < __matrix.NumCols(); j++) __matrix(i,j).SetRank(__rank);
}
}
//_____________________________________________________________________________
/** Returns the \f$ M^{ij}_{\mu\nu\rho\ldots} \f$
*
* From a Matrix of Tensors, it returns the Matrix of just the element of
* each Tensor returned by T(index).
*/
template<typename T>
Matrix<T> TensorElement(const Matrix<Tensor<T> > &__matrix,
const TensorIndex &__index){
int rows = __matrix.NumRows();
int cols = __matrix.NumCols();
Matrix<T> ret(rows,cols);
for(int i = 0; i < rows; i++){
for(int j = 0; j < cols; j++) ret(i,j) = __matrix(i,j).Element(__index);
}
return ret;
}
//_____________________________________________________________________________
/// Sets \f$ M^{ij}_{\mu\nu\rho\ldots} = mval^{ij} \f$
template <typename T>
void SetTensorElement(Matrix<Tensor<T> > &__matrix,
const TensorIndex &__index,
const Matrix<Tensor<T> > &__mval){
int rows = __matrix.NumRows();
int cols = __matrix.NumCols();
for(int i = 0; i < rows; i++){
for(int j = 0; j < cols; j++)
__matrix(i,j).Element(__index) = __mval(i,j).Element();
}
}
//_____________________________________________________________________________
/// Boost a Matrix of Tensors by boost vector (bx,by,bz)
template <typename T>
Matrix<Tensor<T> > BoostMatrix(const Matrix<Tensor<T> > &__matrix,
double __bx,double __by,double __bz){
int rows = __matrix.NumRows();
int cols = __matrix.NumCols();
Matrix<Tensor<T> > ret(__matrix);
for(int i = 0; i < rows; i++){
for(int j = 0; j < cols; j++) ret(i,j).Boost(__bx,__by,__bz);
}
return ret;
}
//_____________________________________________________________________________
#endif /* _MatrixOfTensors_H */