blob: 45058fb4bb737019c8394b529e7ed0e407be734e (
plain)
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
|
#pragma once
#include <cmath>
#include <stdio.h>
#include "types.h"
class ising_t {
public:
bool x;
typedef int M_t;
typedef double F_t;
ising_t() : x(false) {}
ising_t(bool x) : x(x) {}
ising_t(int x) : x((bool)x) {}
inline int operator*(v_t a) const {
if (x) {
return -(int)a;
} else {
return (int)a;
}
}
inline double operator*(double a) const {
if (x) {
return -a;
} else {
return a;
}
}
inline int operator-(const ising_t &s) const {
if (x == s.x) {
return 0;
} else {
if (x) {
return -2;
} else {
return 2;
}
}
}
};
double norm_squared(double s) {
return pow(s, 2);
}
void write_magnetization(int M, FILE *outfile) {
fwrite(&M, sizeof(int), 1, outfile);
}
#define N_STATES 2
const ising_t states[2] = {ising_t(0), ising_t(1)};
q_t state_to_ind(ising_t state) { return (q_t)state.x; }
|