diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-20 23:21:39 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-20 23:21:39 -0400 |
commit | b5998a15cdbab21f03a65d9885dbde39615dc087 (patch) | |
tree | c0b40609e022ec72cf2d3a158c41d5120083cc1d /lib/state.h | |
parent | 5ffaf0a1bb0f0b47d57d0f24ee1134659775dacb (diff) | |
download | c++-b5998a15cdbab21f03a65d9885dbde39615dc087.tar.gz c++-b5998a15cdbab21f03a65d9885dbde39615dc087.tar.bz2 c++-b5998a15cdbab21f03a65d9885dbde39615dc087.zip |
cos and sin calls for computing fourier term now precomputed
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); } }; |