summaryrefslogtreecommitdiff
path: root/lib/z2.h
blob: 599a6a5560f9ff392aa2eb6f708d713474ea6d3a (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
60
61
62
63
64

#pragma once

#include <gsl/gsl_rng.h>
#include "types.h"
#include "ising.h"
#include "state.h"

struct z2_t { bool x; };

void init(z2_t *p) {
  p->x = false;
}

void free_spin(z2_t p) {
  // do nothing!
}

z2_t copy(z2_t x) {
  return x;
}

ising_t act(z2_t r, ising_t s) {
  ising_t rs;

  if (r.x) {
    rs.x = !s.x;
    return rs;
  } else {
    rs.x = s.x;
    return rs;
  }
}

z2_t act(z2_t r1, z2_t r2) {
  z2_t r3;

  if (r1.x) {
    r3.x = !r2.x;
    return r3;
  } else {
    r3.x = r2.x;
    return r3;
  }
}

ising_t act_inverse(z2_t r, ising_t s) {
  return act(r, s);
}

z2_t act_inverse(z2_t r1, z2_t r2) {
  return act(r1, r2);
}

// these are all functions necessary for wolff.h

z2_t generate_ising_rotation(gsl_rng *r, const state_t <z2_t, ising_t> *s) {
  z2_t rot;
  rot.x = true;
  return rot;
}