-
Notifications
You must be signed in to change notification settings - Fork 0
/
spins.hpp
59 lines (52 loc) · 1.32 KB
/
spins.hpp
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
#ifndef SPINS_HPP
#define SPINS_HPP
#include <array>
#include <cassert>
#include <random>
namespace phys
{
class Spin
{
int x_;
int y_;
bool state_;
public:
Spin(int x = 1, int y = 1, bool st = false) : x_(x), y_(y), state_(st) {}
int const &get_x() const;
int const &get_y() const;
void set_x(int &a);
void set_y(int &c);
void set_state(bool &b);
int get_state() const;
void flip_state();
};
class Board
{
std::array<Spin, 250001> spins_;
public:
Board()
{
Spin *it = spins_.begin();
std::random_device ran;
for (int i = 0; i <= 249999; ++i)
{
int a = i / 500;
a += 1;
int b = i % 500;
b += 1;
it->set_x(a);
it->set_y(b);
std::uniform_int_distribution<int> ar(0, 1);
bool stt = ar(ran);
it->set_state(stt);
++it;
}
}
std::array<Spin, 250001> &spins();
std::array<Spin, 250001> const &spins_const() const;
auto get_spin(int a, int b);
Spin const &get_spin_const(int const &a, int const &b) const;
double magnetization();
};
}
#endif