summaryrefslogtreecommitdiff
path: root/lib/ising.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ising.h')
-rw-r--r--lib/ising.h48
1 files changed, 3 insertions, 45 deletions
diff --git a/lib/ising.h b/lib/ising.h
index aaa0c52..45058fb 100644
--- a/lib/ising.h
+++ b/lib/ising.h
@@ -5,26 +5,6 @@
#include "types.h"
-/* The following is the minimum definition of a spin class.
- *
- * The class must contain an M_t and an F_t for holding the sum of an
- * integer number of spins and a double-weighted number of spins,
- * respectively.
- *
- * void init(X_t *p);
- * void free_spin(X_t p);
- * void free_spin(M_t p);
- * void free_spin(F_t p);
- * X_t copy(X_t x);
- * void add(M_t *x1, int factor, X_t x2);
- * void add(F_t *x1, double factor, X_t x2);
- * M_t scalar_multiple(int factor, X_t x);
- * F_t scalar_multiple(double factor, X_t x);
- * double norm_squared(F_t x);
- * void write_magnetization(M_t M, FILE *outfile);
- *
- */
-
class ising_t {
public:
bool x;
@@ -32,11 +12,9 @@ class ising_t {
typedef int M_t;
typedef double F_t;
- ising_t() {
- x = false;
- }
-
+ ising_t() : x(false) {}
ising_t(bool x) : x(x) {}
+ ising_t(int x) : x((bool)x) {}
inline int operator*(v_t a) const {
if (x) {
@@ -67,26 +45,6 @@ class ising_t {
}
};
-inline int& operator+=(int& M, const ising_t &s) {
- if (s.x) {
- M--;
- } else {
- M++;
- }
-
- return M;
-}
-
-inline int& operator-=(int& M, const ising_t &s) {
- if (s.x) {
- M++;
- } else {
- M--;
- }
-
- return M;
-}
-
double norm_squared(double s) {
return pow(s, 2);
}
@@ -96,6 +54,6 @@ void write_magnetization(int M, FILE *outfile) {
}
#define N_STATES 2
-const ising_t states[2] = {{(bool)0}, {(bool)1}};
+const ising_t states[2] = {ising_t(0), ising_t(1)};
q_t state_to_ind(ising_t state) { return (q_t)state.x; }