-
Notifications
You must be signed in to change notification settings - Fork 1
/
su3.h
78 lines (68 loc) · 2.08 KB
/
su3.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
#ifndef _SU3_H
#define _SU3_H
/* Adapted from su3.h in MILC version 7 */
/* generic precision complex number definition */
/* specific for float complex */
template <typename T> struct alignas(sizeof(T) * 2) complex {
T real;
T imag;
};
using fcomplex = complex<float>;
using dcomplex = complex<double>;
// typedef struct {
// float real;
// float imag;
// } fcomplex;
//
// /* specific for double complex */
// typedef struct {
// double real;
// double imag;
// } dcomplex;
typedef struct {
double device_to_host_time;
double kernel_time;
double host_to_device_time;
} Profile;
typedef struct {
fcomplex e[3][3];
} fsu3_matrix;
typedef struct {
fcomplex c[3];
} fsu3_vector;
typedef struct {
dcomplex e[3][3];
} dsu3_matrix;
typedef struct {
dcomplex c[3];
} dsu3_vector;
#if (PRECISION == 1)
#define su3_matrix fsu3_matrix
#define su3_vector fsu3_vector
#define Real float
#define Complx fcomplex
#else
#define su3_matrix dsu3_matrix
#define su3_vector dsu3_vector
#define Real double
#define Complx dcomplex
#endif /* PRECISION */
/* c += a * b */
#define CMULSUM(a, b, c) \
{ \
(c).real += (a).real * (b).real - (a).imag * (b).imag; \
(c).imag += (a).real * (b).imag + (a).imag * (b).real; \
}
/* c = a * b */
#define CMUL(a, b, c) \
{ \
(c).real = (a).real * (b).real - (a).imag * (b).imag; \
(c).imag = (a).real * (b).imag + (a).imag * (b).real; \
}
/* a += b */
#define CSUM(a, b) \
{ \
(a).real += (b).real; \
(a).imag += (b).imag; \
}
#endif /* _SU3_H */