diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-19 13:39:01 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-07-19 13:39:01 -0400 |
commit | ffa58d427cd0e8b4e6ebd5538a83bec63a85ab27 (patch) | |
tree | 932d9f0bb71ee2ba3edda2fb8b7572b6e82da142 /lib/measure.h | |
parent | 07bfd781266868ee6bac8e2b58f9675b3536354d (diff) | |
download | c++-ffa58d427cd0e8b4e6ebd5538a83bec63a85ab27.tar.gz c++-ffa58d427cd0e8b4e6ebd5538a83bec63a85ab27.tar.bz2 c++-ffa58d427cd0e8b4e6ebd5538a83bec63a85ab27.zip |
new mesaurement flag system, fftw only initialized once, all O(n) models now built from one file with different compiler flag settings
Diffstat (limited to 'lib/measure.h')
-rw-r--r-- | lib/measure.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/measure.h b/lib/measure.h new file mode 100644 index 0000000..3474684 --- /dev/null +++ b/lib/measure.h @@ -0,0 +1,48 @@ + +#pragma once + +#define POSSIBLE_MEASUREMENTS 4 +const unsigned char measurement_energy = 1 << 0; +const unsigned char measurement_clusterSize = 1 << 1; +const unsigned char measurement_magnetization = 1 << 2; +const unsigned char measurement_fourierZero = 1 << 3; + +#ifdef __cplusplus + +#include "state.h" +#include "correlation.h" +#include <functional> + +template <class R_t, class X_t> +std::function <void(const state_t <R_t, X_t> *)> measurement_energy_file(FILE *file) { + return [=](const state_t <R_t, X_t> *s) { + float smaller_E = (float)s->E; + fwrite(&smaller_E, sizeof(float), 1, file); + }; +} + +template <class R_t, class X_t> +std::function <void(const state_t <R_t, X_t> *)> measurement_cluster_file(FILE *file) { + return [=](const state_t <R_t, X_t> *s) { + fwrite(&(s->last_cluster_size), sizeof(uint32_t), 1, file); + }; +} + +template <class R_t, class X_t> +std::function <void(const state_t <R_t, X_t> *)> measurement_magnetization_file(FILE *file) { + return [=](const state_t <R_t, X_t> *s) { + write_magnetization(s->M, file); + }; +} + +template <class R_t, class X_t> +std::function <void(const state_t <R_t, X_t> *)> measurement_fourier_file(FILE *file, fftw_plan plan, double *fftw_in, double *fftw_out) { + return [=](const state_t <R_t, X_t> *s) { + float smaller_X = (float)correlation_length(s, plan, fftw_in, fftw_out); + fwrite(&smaller_X, sizeof(float), 1, file); + }; +} + +#endif + + |