From a43ff1f98e9b9814f858bccb11c174b418458491 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 10 Oct 2018 21:45:32 -0400 Subject: big rearrangement of files to make libraries and example (research) files clearer, and changed to c++ std lib random numbers --- lib/measure.h | 63 ----------------------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 lib/measure.h (limited to 'lib/measure.h') diff --git a/lib/measure.h b/lib/measure.h deleted file mode 100644 index 2c5ffb7..0000000 --- a/lib/measure.h +++ /dev/null @@ -1,63 +0,0 @@ - -#pragma once - -#include "state.h" -#include "correlation.h" -#include - -#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; - -char const *measurement_labels[] = {"E", "S", "M", "F"}; - -FILE **measure_setup_files(unsigned char flags, unsigned long timestamp) { - FILE **files = (FILE **)calloc(POSSIBLE_MEASUREMENTS, sizeof(FILE *)); - - for (uint8_t i = 0; i < POSSIBLE_MEASUREMENTS; i++) { - if (flags & (1 << i)) { - char *filename = (char *)malloc(255 * sizeof(char)); - sprintf(filename, "wolff_%lu_%s.dat", timestamp, measurement_labels[i]); - files[i] = fopen(filename, "wb"); - free(filename); - } - } - - return files; -} - -template -std::function &)> measure_function_write_files(unsigned char flags, FILE **files, std::function &)> other_f) { - return [=] (const state_t & s) { - if (flags & measurement_energy) { - float smaller_E = (float)s.E; - fwrite(&smaller_E, sizeof(float), 1, files[0]); - } - if (flags & measurement_clusterSize) { - fwrite(&(s.last_cluster_size), sizeof(uint32_t), 1, files[1]); - } - if (flags & measurement_magnetization) { - write_magnetization(s.M, files[2]); - } - if (flags & measurement_fourierZero) { - float smaller_X = (float)correlation_length(s); - fwrite(&smaller_X, sizeof(float), 1, files[3]); - } - - other_f(s); - }; -} - -void measure_free_files(unsigned char flags, FILE **files) { - for (uint8_t i = 0; i < POSSIBLE_MEASUREMENTS; i++) { - if (flags & (1 << i)) { - fclose(files[i]); - } - } - - free(files); -} - - -- cgit v1.2.3-70-g09d2