summaryrefslogtreecommitdiff
path: root/lib/correlation.h
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-18 15:37:27 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-18 15:37:27 -0400
commitcd85d3696be4a7ee65b0cf6669fc62dc4841aef3 (patch)
tree6429963091115b7b1ff0a0684ff8f01274a32042 /lib/correlation.h
parent722bc71ed8d4e1ae5616c5c8284fbffe21c4ffa4 (diff)
downloadc++-cd85d3696be4a7ee65b0cf6669fc62dc4841aef3.tar.gz
c++-cd85d3696be4a7ee65b0cf6669fc62dc4841aef3.tar.bz2
c++-cd85d3696be4a7ee65b0cf6669fc62dc4841aef3.zip
- added support for computing spatial fourier transforms
- measurements now are functions passed to wolff in array
Diffstat (limited to 'lib/correlation.h')
-rw-r--r--lib/correlation.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/correlation.h b/lib/correlation.h
new file mode 100644
index 0000000..5722aab
--- /dev/null
+++ b/lib/correlation.h
@@ -0,0 +1,36 @@
+
+#pragma once
+
+#include "types.h"
+#include "state.h"
+
+#include <fftw3.h>
+
+template <class R_t, class X_t>
+double correlation_length(const state_t <R_t, X_t> *s) {
+ double *data = (double *)fftw_malloc(s->nv * sizeof(double));
+ int rank = s->D;
+ int *n = (int *)malloc(rank * sizeof(int));
+ fftw_r2r_kind *kind = (fftw_r2r_kind *)malloc(rank * sizeof(fftw_r2r_kind));
+ for (D_t i = 0; i < rank; i++) {
+ n[i] = s->L;
+ kind[i] = FFTW_R2HC;
+ }
+ fftw_plan plan = fftw_plan_r2r(rank, n, data, data, kind, 0);
+
+ for (v_t i = 0; i < s->nv; i++) {
+ data[i] = correlation_component(s->spins[i]);
+ }
+
+ fftw_execute(plan);
+
+ double length = pow(data[0], 2);
+
+ fftw_destroy_plan(plan);
+ fftw_free(data);
+ free(n);
+ free(kind);
+
+ return length;
+}
+