summaryrefslogtreecommitdiff
path: root/lib/correlation.h
blob: b3b7d865a17aa5898f704c7676d0711f0336ea0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#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, fftw_plan plan, double *in, double *out) {
  for (v_t i = 0; i < s->nv; i++) {
    in[i] = correlation_component(s->spins[i]);
  }

  fftw_execute(plan);

  double length = pow(out[0], 2);

  return length;
}