diff options
Diffstat (limited to 'hadamard_time.cpp')
-rw-r--r-- | hadamard_time.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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 <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; +} |