diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 13:06:54 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 13:06:54 -0400 |
commit | 870555f569bc63fecdc7c0b16e72e4e002f21c13 (patch) | |
tree | 704fc4669fa3c69af8882b10eff0e89321b3be83 /lib/z2.h | |
parent | 215c40813a35c4fdc0bb5f1b8fdea125b9e9d2e4 (diff) | |
download | c++-870555f569bc63fecdc7c0b16e72e4e002f21c13.tar.gz c++-870555f569bc63fecdc7c0b16e72e4e002f21c13.tar.bz2 c++-870555f569bc63fecdc7c0b16e72e4e002f21c13.zip |
all the R_t have been objectified
Diffstat (limited to 'lib/z2.h')
-rw-r--r-- | lib/z2.h | 60 |
1 files changed, 24 insertions, 36 deletions
@@ -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); -} |