From 870555f569bc63fecdc7c0b16e72e4e002f21c13 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Thu, 26 Jul 2018 13:06:54 -0400 Subject: all the R_t have been objectified --- lib/z2.h | 60 ++++++++++++++++++++++++------------------------------------ 1 file changed, 24 insertions(+), 36 deletions(-) (limited to 'lib/z2.h') 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); -} -- cgit v1.2.3-70-g09d2