From a43ff1f98e9b9814f858bccb11c174b418458491 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 10 Oct 2018 21:45:32 -0400 Subject: big rearrangement of files to make libraries and example (research) files clearer, and changed to c++ std lib random numbers --- lib/vector.h | 118 ----------------------------------------------------------- 1 file changed, 118 deletions(-) delete mode 100644 lib/vector.h (limited to 'lib/vector.h') diff --git a/lib/vector.h b/lib/vector.h deleted file mode 100644 index 7d0ee36..0000000 --- a/lib/vector.h +++ /dev/null @@ -1,118 +0,0 @@ - -#pragma once - -#include -#include -#include - -#include "types.h" - -template -class vector_t : public std::array { - public: - - // M_t needs to hold the sum of nv spins - typedef vector_t M_t; - - // F_t needs to hold the double-weighted sum of spins - typedef vector_t F_t; - - vector_t() { - this->fill((T)0); - (*this)[1] = (T)1; - } - - vector_t(const T *x) { - for (q_t i = 0; i < q; i++) { - (*this)[i] = x[i]; - } - } - - template - inline vector_t& operator+=(const vector_t &v) { - for (q_t i = 0; i < q; i++) { - (*this)[i] += (U)v[i]; - } - return *this; - } - - template - inline vector_t& operator-=(const vector_t &v) { - for (q_t i = 0; i < q; i++) { - (*this)[i] -= (U)v[i]; - } - return *this; - } - - inline vector_t operator*(v_t x) const { - vector_t result; - for (q_t i = 0; i < q; i++) { - result[i] = x * (*this)[i]; - } - - return result; - } - - inline vector_t operator*(double x) const { - vector_t result; - for (q_t i = 0; i < q; i++) { - result[i] = x * (*this)[i]; - } - - return result; - } - - inline vector_t operator-(const vector_t& v) const { - vector_t diff = *this; - diff -= v; - return diff; - } -}; - - -template -double norm_squared(vector_t v) { - double tmp = 0; - for (T &x : v) { - tmp += pow(x, 2); - } - - return tmp; -} - -template -void write_magnetization(vector_t M, FILE *outfile) { - for (q_t i = 0; i < q; i++) { - fwrite(&(M[i]), sizeof(T), q, outfile); - } -} - -// below functions and definitions are unnecessary for wolff.h but useful. - -template // save some space and don't write whole doubles -void write_magnetization(vector_t M, FILE *outfile) { - for (q_t i = 0; i < q; i++) { - float M_tmp = (float)M[i]; - fwrite(&M_tmp, sizeof(float), 1, outfile); - } -} - -template -T dot(const vector_t & v1, const vector_t & v2) { - T prod = 0; - - for (q_t i = 0; i < q; i++) { - prod += v1[i] * v2[i]; - } - - return prod; -} - -template -double H_vector(const vector_t & v1, T *H) { - vector_t H_vec(H); - return (double)(dot (v1, H_vec)); -} - -char const *ON_strings[] = {"TRIVIAL", "ISING", "PLANAR", "HEISENBERG"}; - -- cgit v1.2.3-70-g09d2