diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 01:17:53 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-26 01:17:53 -0400 |
commit | 94f7d887981f0626f166f5645fa98115d4f9a478 (patch) | |
tree | b5653f58f288a9619dc82d3ac5867dfd5c89ad45 /lib/state.h | |
parent | d3b3e39a525d0c3aa9663f824ba96e0c429a8313 (diff) | |
download | c++-94f7d887981f0626f166f5645fa98115d4f9a478.tar.gz c++-94f7d887981f0626f166f5645fa98115d4f9a478.tar.bz2 c++-94f7d887981f0626f166f5645fa98115d4f9a478.zip |
everything compiles now, and fixed a major bug in the graph code
Diffstat (limited to 'lib/state.h')
-rw-r--r-- | lib/state.h | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/lib/state.h b/lib/state.h index 360e8f8..b57a9e2 100644 --- a/lib/state.h +++ b/lib/state.h @@ -21,11 +21,11 @@ class state_t { double E; typename X_t::M_t M; // the "sum" of the spins, like the total magnetization v_t last_cluster_size; - typename X_t::F_t *ReF; - typename X_t::F_t *ImF; + std::vector<typename X_t::F_t> ReF; + std::vector<typename X_t::F_t> ImF; // updating fourier terms F requires many cos and sin calls, faster to do it beforehand. - double *precomputed_cos; - double *precomputed_sin; + std::vector<double> precomputed_cos; + std::vector<double> precomputed_sin; std::function <double(X_t, X_t)> J; std::function <double(X_t)> H; @@ -39,14 +39,14 @@ class state_t { E = - (double)ne * J(spins[0], spins[0]) - (double)nv * H(spins[0]); M = spins[0] * nv; last_cluster_size = 0; - ReF = (typename X_t::F_t *)malloc(D * sizeof(typename X_t::F_t)); - ImF = (typename X_t::F_t *)malloc(D * sizeof(typename X_t::F_t)); + ReF.resize(D); + ImF.resize(D); for (D_t i = 0; i < D; i++) { ReF[i] = spins[0] * 0.0; ImF[i] = spins[0] * 0.0; } - precomputed_cos = (double *)malloc(L * sizeof(double)); - precomputed_sin = (double *)malloc(L * sizeof(double)); + precomputed_cos.resize(L); + precomputed_sin.resize(L); for (L_t i = 0; i < L; i++) { precomputed_cos[i] = cos(2 * M_PI * (double)i / (double)L); precomputed_sin[i] = sin(2 * M_PI * (double)i / (double)L); @@ -55,10 +55,6 @@ class state_t { ~state_t() { free_spin(R); - free(ReF); - free(ImF); - free(precomputed_sin); - free(precomputed_cos); } }; |