diff options
Diffstat (limited to 'lib/state.h')
-rw-r--r-- | lib/state.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/state.h b/lib/state.h index b40b85c..76d3e5a 100644 --- a/lib/state.h +++ b/lib/state.h @@ -23,6 +23,9 @@ class state_t { v_t last_cluster_size; typename X_t::F_t *ReF; 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::function <double(X_t, X_t)> J; std::function <double(X_t)> H; @@ -47,6 +50,12 @@ class state_t { ReF[i] = scalar_multiple(0, spins[0]); ImF[i] = scalar_multiple(0, spins[0]); } + precomputed_cos = (double *)malloc(L * sizeof(double)); + precomputed_sin = (double *)malloc(L * sizeof(double)); + 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); + } } ~state_t() { @@ -63,6 +72,8 @@ class state_t { } free(ReF); free(ImF); + free(precomputed_sin); + free(precomputed_cos); } }; |