summaryrefslogtreecommitdiff
path: root/lib/z2.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/z2.h')
-rw-r--r--lib/z2.h60
1 files changed, 24 insertions, 36 deletions
diff --git a/lib/z2.h b/lib/z2.h
index dae1eb7..fd4722e 100644
--- a/lib/z2.h
+++ b/lib/z2.h
@@ -17,49 +17,37 @@
*
*/
-struct z2_t { bool x; };
+class z2_t {
+ public:
+ bool x;
-void init(z2_t *p) {
- p->x = false;
-}
+ z2_t() : x(false) {}
-void free_spin(z2_t p) {
- // do nothing!
-}
+ z2_t(bool x) : x(x) {}
-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;
+ ising_t act(const ising_t& s) {
+ if (x) {
+ return ising_t(!s.x);
+ } else {
+ return ising_t(s.x);
+ }
}
-}
-z2_t act(z2_t r1, z2_t r2) {
- z2_t r3;
+ z2_t act(const z2_t& r) {
+ if (x) {
+ return z2_t(!r.x);
+ } else {
+ return z2_t(r.x);
+ }
+ }
- if (r1.x) {
- r3.x = !r2.x;
- return r3;
- } else {
- r3.x = r2.x;
- return r3;
+ ising_t act_inverse(const ising_t& s) {
+ return this->act(s);
}
-}
-ising_t act_inverse(z2_t r, ising_t s) {
- return act(r, s);
-}
+ z2_t act_inverse(const z2_t& r) {
+ return this->act(r);
+ }
+};
-z2_t act_inverse(z2_t r1, z2_t r2) {
- return act(r1, r2);
-}