From 84edbcb1b0dd1c5ac5c1626e7dc8cf22bbf10139 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 14 Oct 2019 20:31:35 -0400 Subject: initialized repo --- hadamard_time.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 hadamard_time.cpp (limited to 'hadamard_time.cpp') diff --git a/hadamard_time.cpp b/hadamard_time.cpp new file mode 100644 index 0000000..c9dd961 --- /dev/null +++ b/hadamard_time.cpp @@ -0,0 +1,34 @@ +#include "hadamard_mcmc.hpp" +#include + +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; +} -- cgit v1.2.3-70-g09d2