summaryrefslogtreecommitdiff
path: root/hadamard_time.cpp
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-10-14 20:31:35 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-10-14 20:31:35 -0400
commit84edbcb1b0dd1c5ac5c1626e7dc8cf22bbf10139 (patch)
tree30fa058977072953901d3cfe516c83dd1d709b37 /hadamard_time.cpp
downloadcode-84edbcb1b0dd1c5ac5c1626e7dc8cf22bbf10139.tar.gz
code-84edbcb1b0dd1c5ac5c1626e7dc8cf22bbf10139.tar.bz2
code-84edbcb1b0dd1c5ac5c1626e7dc8cf22bbf10139.zip
initialized repo
Diffstat (limited to 'hadamard_time.cpp')
-rw-r--r--hadamard_time.cpp34
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;
+}