summaryrefslogtreecommitdiff
path: root/hadamard_time.cpp
blob: c9dd961a9f20eadf0e83ce3d2af1a811540ed07d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "hadamard_mcmc.hpp"
#include <iostream>

class MeasureEnergy : public Measurement {
  private:
    unsigned N;
    double totalE;

  public:
    MeasureEnergy() {
      N = 0;
      totalE = 0;
    }

    void after_sweep(double, double E, const Orthogonal&) override {
      totalE += E;
      N++;
    }

    double energy() const {
      return totalE / N;
    }
};

int main() {
  MeasureEnergy A;
  MCMC sim(20, 6.0, A);
  sim.tune(1e4, 0.01);
  sim.run(1e4);

  std::cout << "The average energy was " << A.energy() << ".";

  return 0;
}