diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-30 09:08:09 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-30 09:08:09 -0400 |
commit | 1d30b115d31df05530b20eb7dd348e21bc1a7711 (patch) | |
tree | 5a6acf70302a0310fc370e2aea811376c6a80985 /lib | |
parent | 95b4257a4df36516e192d72b12da8673f6af3081 (diff) | |
download | c++-1d30b115d31df05530b20eb7dd348e21bc1a7711.tar.gz c++-1d30b115d31df05530b20eb7dd348e21bc1a7711.tar.bz2 c++-1d30b115d31df05530b20eb7dd348e21bc1a7711.zip |
removed some unnessecary code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ising.h | 48 | ||||
-rw-r--r-- | lib/potts.h | 35 | ||||
-rw-r--r-- | lib/state.h | 3 |
3 files changed, 4 insertions, 82 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; } diff --git a/lib/potts.h b/lib/potts.h index 771c8dc..1764e53 100644 --- a/lib/potts.h +++ b/lib/potts.h @@ -6,26 +6,6 @@ #include "types.h" #include "vector.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); - * - */ - template <q_t q> class potts_t { public: @@ -35,7 +15,6 @@ class potts_t { typedef vector_t<q, double> F_t; potts_t() : x(0) {} - potts_t(q_t x) : x(x) {} inline vector_t<q, int> operator*(v_t a) const { @@ -65,20 +44,6 @@ class potts_t { } }; -template <q_t q> -inline vector_t<q, int>& operator+=(vector_t<q, int>& M, const potts_t<q> &s) { - M[s.x]++; - - return M; -} - -template <q_t q> -inline vector_t<q, int>& operator-=(vector_t<q, int>& M, const potts_t<q> &s) { - M[s.x]--; - - return M; -} - // we could inherit norm_squared from vector.h, but convention dictates that // potts norms be changed by a constant factor template <q_t q> diff --git a/lib/state.h b/lib/state.h index 550d100..3bbed39 100644 --- a/lib/state.h +++ b/lib/state.h @@ -58,8 +58,7 @@ class state_t { } void update_magnetization(const X_t& s_old, const X_t& s_new) { - M -= s_old; - M += s_new; + M += s_new - s_old; } void update_energy(const double& dE) { |