diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-10-10 21:45:32 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2018-10-10 21:45:32 -0400 |
commit | a43ff1f98e9b9814f858bccb11c174b418458491 (patch) | |
tree | ae7e094d914eddb8a1ae9548420ba8c2f329ffae /lib/torus.h | |
parent | 6e264d243f0b29d90e90b605b6cdeab8227129c9 (diff) | |
download | c++-a43ff1f98e9b9814f858bccb11c174b418458491.tar.gz c++-a43ff1f98e9b9814f858bccb11c174b418458491.tar.bz2 c++-a43ff1f98e9b9814f858bccb11c174b418458491.zip |
big rearrangement of files to make libraries and example (research) files clearer, and changed to c++ std lib random numbers
Diffstat (limited to 'lib/torus.h')
-rw-r--r-- | lib/torus.h | 64 |
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/torus.h b/lib/torus.h deleted file mode 100644 index 2aead52..0000000 --- a/lib/torus.h +++ /dev/null @@ -1,64 +0,0 @@ - -#pragma once - -#include <cmath> -#include <array> -#include "types.h" - -template <q_t n> -class torus_t : public std::array<double, n> { - public: - typedef std::array<double, n> M_t; - typedef std::array<double, n> F_t; - - torus_t() { - this->fill(0); - } - - inline torus_t<n> operator*(v_t a) const { - torus_t<n> x; - for (q_t i = 0; i < n; i++) { - x[i] = a * (*this)[i]; - } - - return x; - } - - inline torus_t<n> operator*(double a) const { - torus_t<n> x; - for (q_t i = 0; i < n; i++) { - x[i] = a * (*this)[i]; - } - - return x; - } - - inline torus_t<n>& operator+=(const torus_t<n>& x) { - for (q_t i = 0; i < n; i++) { - (*this)[i] += x[i]; - } - } - - inline torus_t<n>& operator-=(const torus_t<n>& x) { - for (q_t i = 0; i < n; i++) { - (*this)[i] -= x[i]; - } - } -}; - -template <q_t n> -double norm_squared(const torus_t<n>& x) { - double tmp = 0; - for (const double& xi : x) { - tmp += pow(xi, 2); - } - return tmp; -} - -void write_magnetization(const torus_t<n>& x, FILE *outfile) { - for (const double& xi : x) { - float tmp_xi = (float)xi; - fwrite(&tmp_xi, sizeof(float), 1, outfile); - } -} - |