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

#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 total = 0;

  for (D_t j = 0; j < s.D; j++) {
    total += norm_squared(s.ReF[j]) + norm_squared(s.ImF[j]);
  }

  return total / s.D;
}