forked from etmc/tmLQCD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstruct_accessors.h
193 lines (184 loc) · 6.17 KB
/
struct_accessors.h
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/***********************************************************************
*
* Copyright (C) 2017 Bartosz Kostrzewa
*
* This file is part of tmLQCD.
*
* tmLQCD 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.
*
* tmLQCD 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 tmLQCD. If not, see <http://www.gnu.org/licenses/>.
*
***********************************************************************/
#ifndef STRUCT_ACCESSORS_H
#define STRUCT_ACCESSORS_H
#include "su3.h"
#include <stdlib.h>
static inline double su3_get_elem_linear(const su3* const matrix, int cc, int reim){
switch(cc){
case 0:
if(reim==0) return( ((double*)(&matrix->c00))[0] );
else return( ((double*)(&matrix->c00))[1] );
break;
case 1:
if(reim==0) return( ((double*)(&matrix->c01))[0] );
else return( ((double*)(&matrix->c01))[1] );
break;
case 2:
if(reim==0) return( ((double*)(&matrix->c02))[0] );
else return( ((double*)(&matrix->c02))[1] );
break;
case 3:
if(reim==0) return( ((double*)(&matrix->c10))[0] );
else return( ((double*)(&matrix->c10))[1] );
break;
case 4:
if(reim==0) return( ((double*)(&matrix->c11))[0] );
else return( ((double*)(&matrix->c11))[1] );
break;
case 5:
if(reim==0) return( ((double*)(&matrix->c12))[0] );
else return( ((double*)(&matrix->c12))[1] );
break;
case 6:
if(reim==0) return( ((double*)(&matrix->c20))[0] );
else return( ((double*)(&matrix->c20))[1] );
break;
case 7:
if(reim==0) return( ((double*)(&matrix->c21))[0] );
else return( ((double*)(&matrix->c21))[1] );
break;
case 8:
if(reim==0) return( ((double*)(&matrix->c22))[0] );
else return( ((double*)(&matrix->c22))[1] );
break;
default:
exit(-222);
}
}
static inline double su3_get_elem(const su3* const matrix, int c0, int c1, int reim){
return su3_get_elem_linear(matrix, 3*c0+c1, reim);
}
static inline double spinor_get_elem_linear(const spinor* const matrix, int sc, int reim){
switch(sc){
case 0:
if(reim==0) return( ((double*)(&matrix->s0.c0))[0] );
else return( ((double*)(&matrix->s0.c0))[1] );
break;
case 1:
if(reim==0) return( ((double*)(&matrix->s0.c1))[0] );
else return( ((double*)(&matrix->s0.c1))[1] );
break;
case 2:
if(reim==0) return( ((double*)(&matrix->s0.c2))[0] );
else return( ((double*)(&matrix->s0.c2))[1] );
break;
case 3:
if(reim==0) return( ((double*)(&matrix->s1.c0))[0] );
else return( ((double*)(&matrix->s1.c0))[1] );
break;
case 4:
if(reim==0) return( ((double*)(&matrix->s1.c1))[0] );
else return( ((double*)(&matrix->s1.c1))[1] );
break;
case 5:
if(reim==0) return( ((double*)(&matrix->s1.c2))[0] );
else return( ((double*)(&matrix->s1.c2))[1] );
break;
case 6:
if(reim==0) return( ((double*)(&matrix->s2.c0))[0] );
else return( ((double*)(&matrix->s2.c0))[1] );
break;
case 7:
if(reim==0) return( ((double*)(&matrix->s2.c1))[0] );
else return( ((double*)(&matrix->s2.c1))[1] );
break;
case 8:
if(reim==0) return( ((double*)(&matrix->s2.c2))[0] );
else return( ((double*)(&matrix->s2.c2))[1] );
break;
case 9:
if(reim==0) return( ((double*)(&matrix->s3.c0))[0] );
else return( ((double*)(&matrix->s3.c0))[1] );
break;
case 10:
if(reim==0) return( ((double*)(&matrix->s3.c1))[0] );
else return( ((double*)(&matrix->s3.c1))[1] );
break;
case 11:
if(reim==0) return( ((double*)(&matrix->s3.c2))[0] );
else return( ((double*)(&matrix->s3.c2))[1] );
break;
default:
exit(-223);
}
}
static inline double spinor_get_elem(const spinor* const matrix, int s, int c, int reim){
return spinor_get_elem_linear(matrix, 3*s+c, reim);
}
static inline void spinor_set_elem_linear(spinor* const matrix, int sc, const double rein, const double imin){
switch(sc){
case 0:
*(((double*const)(&(matrix->s0.c0))) ) = rein;
*(((double*const)(&(matrix->s0.c0)))+1) = imin;
break;
case 1:
*(((double*const)(&(matrix->s0.c1))) ) = rein;
*(((double*const)(&(matrix->s0.c1)))+1) = imin;
break;
case 2:
*(((double*const)(&(matrix->s0.c2))) ) = rein;
*(((double*const)(&(matrix->s0.c2)))+1) = imin;
break;
case 3:
*(((double*const)(&(matrix->s1.c0))) ) = rein;
*(((double*const)(&(matrix->s1.c0)))+1) = imin;
break;
case 4:
*(((double*const)(&(matrix->s1.c1))) ) = rein;
*(((double*const)(&(matrix->s1.c1)))+1) = imin;
break;
case 5:
*(((double*const)(&(matrix->s1.c2))) ) = rein;
*(((double*const)(&(matrix->s1.c2)))+1) = imin;
break;
case 6:
*(((double*const)(&(matrix->s2.c0))) ) = rein;
*(((double*const)(&(matrix->s2.c0)))+1) = imin;
break;
case 7:
*(((double*const)(&(matrix->s2.c1))) ) = rein;
*(((double*const)(&(matrix->s2.c1)))+1) = imin;
break;
case 8:
*(((double*const)(&(matrix->s2.c2))) ) = rein;
*(((double*const)(&(matrix->s2.c2)))+1) = imin;
break;
case 9:
*(((double*const)(&(matrix->s3.c0))) ) = rein;
*(((double*const)(&(matrix->s3.c0)))+1) = imin;
break;
case 10:
*(((double*const)(&(matrix->s3.c1))) ) = rein;
*(((double*const)(&(matrix->s3.c1)))+1) = imin;
break;
case 11:
*(((double*const)(&(matrix->s3.c2))) ) = rein;
*(((double*const)(&(matrix->s3.c2)))+1) = imin;
break;
default:
exit(-224);
}
}
static inline void spinor_set_elem(spinor* const matrix, int s, int c, const double rein, const double imin){
spinor_set_elem_linear(matrix, 3*s+c, rein, imin);
}
#endif