Skip to content

Commit c94fcf2

Browse files
committed
tensors.h: new header with implementation of 3 and 4 index Euclidean Levi-Civita
1 parent dc75903 commit c94fcf2

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

tensors.h

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/***********************************************************************
2+
*
3+
* Copyright (C) 2018 Bartosz Kostrzewa
4+
*
5+
* This file is part of tmLQCD.
6+
*
7+
* tmLQCD is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* tmLQCD is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with tmLQCD. If not, see <http://www.gnu.org/licenses/>.
19+
*
20+
************************************************************************/
21+
22+
#ifndef TENSORS_H
23+
#define TENSORS_H
24+
25+
typedef struct epsilon4_t {
26+
int N;
27+
double eps_val[24];
28+
int eps_idx[24][4];
29+
} epsilon4_t;
30+
31+
typedef struct epsilon3_t {
32+
int N;
33+
double eps_val[6];
34+
int eps_idx[6][3];
35+
} epsilon3_t;
36+
37+
static inline epsilon3_t new_epsilon3(void) {
38+
epsilon3_t ret;
39+
40+
ret.N = 6;
41+
42+
int i = 0;
43+
int p = 0;
44+
for( int i1 = 1; i1 <= 3; i1++ ){
45+
for( int i2 = 1; i2 <= 3; i2++ ){
46+
for( int i3 = 1; i3 <= 3; i3++ ){
47+
// for eps_123 we have: (1 - 2)(1 - 3)(2 - 3) = -2
48+
// -> minus sign
49+
p = -(i1 - i2)*(i1 - i3)*(i2 - i3);
50+
if( p != 0 ){
51+
ret.eps_val[i] = p > 0 ? 1 : -1;
52+
ret.eps_idx[i][0] = i1-1;
53+
ret.eps_idx[i][1] = i2-1;
54+
ret.eps_idx[i][2] = i3-1;
55+
i++;
56+
}
57+
}
58+
}
59+
}
60+
return(ret);
61+
}
62+
63+
// note that this is the Euclidean eps_ijkl, for which we have eps_1234 = 1,
64+
// whereas in Minkowski space we have eps_0123 = -1
65+
static inline epsilon4_t new_epsilon4(void) {
66+
epsilon4_t ret;
67+
68+
ret.N = 24;
69+
70+
int i = 0;
71+
int p = 0;
72+
for( int i1 = 1; i1 <= 4; i1++ ){
73+
for( int i2 = 1; i2 <= 4; i2++ ){
74+
for( int i3 = 1; i3 <= 4; i3++ ){
75+
for( int i4 = 1; i4 <= 4; i4++ ){
76+
// for eps_1234 we have: (1 - 2)(1 - 3)(1 - 4)(2 - 3)(2 - 4)(3 - 4) = 12
77+
// -> NO minus sign
78+
p = (i1 - i2)*(i1 - i3)*(i1 - i4)*(i2 - i3)*(i2 - i4)*(i3 - i4);
79+
if( p != 0 ){
80+
ret.eps_val[i] = p > 0 ? 1 : -1;
81+
ret.eps_idx[i][0] = i1-1;
82+
ret.eps_idx[i][1] = i2-1;
83+
ret.eps_idx[i][2] = i3-1;
84+
ret.eps_idx[i][3] = i4-1;
85+
i++;
86+
}
87+
}
88+
}
89+
}
90+
}
91+
return(ret);
92+
}
93+
94+
#endif
95+

0 commit comments

Comments
 (0)