diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-01-14 15:47:59 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-01-14 15:47:59 -0500 |
commit | 49ac78a6c04e215950bc9c0f97368605e63da15b (patch) | |
tree | 64b770c543a0c90bc7dcbc06ceaaa31e96e541ce /lib/wolff_models/potts.hpp | |
parent | 994cbf1a3b611ff4c94ced3b1630e51fd249d7ed (diff) | |
download | c++-49ac78a6c04e215950bc9c0f97368605e63da15b.tar.gz c++-49ac78a6c04e215950bc9c0f97368605e63da15b.tar.bz2 c++-49ac78a6c04e215950bc9c0f97368605e63da15b.zip |
Large refactoring around changes in the graph class.
- Graphs now use lists of references instead of vectors of indicies.
- Vertices and edges have associated classes that can be given arbitrary properties via template specification.
- All essential library headers have been combined into one, wolff.hpp.
Diffstat (limited to 'lib/wolff_models/potts.hpp')
-rw-r--r-- | lib/wolff_models/potts.hpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/wolff_models/potts.hpp b/lib/wolff_models/potts.hpp new file mode 100644 index 0000000..dd56134 --- /dev/null +++ b/lib/wolff_models/potts.hpp @@ -0,0 +1,66 @@ + +#ifndef WOLFF_MODELS_POTTS_H +#define WOLFF_MODELS_POTTS_H + +#include <cmath> + +#include "vector.hpp" + +namespace wolff { + + template <unsigned q> + class potts_t { + public: + unsigned x; + + potts_t() : x(0) {} + potts_t(unsigned x) : x(x) {} + + typedef vector_t<q, int> M_t; + typedef vector_t<q, double> F_t; + + inline vector_t<q, int> operator*(unsigned a) const { + vector_t<q, int> result; + result.fill(0); + result[x] = (int)a; + + return result; + } + + inline vector_t<q, double> operator*(double a) const { + vector_t<q, double> result; + result.fill(0.0); + result[x] = a; + + return result; + } + + inline vector_t<q, int> operator-(const potts_t<q> &s) const { + vector_t<q, int> result; + result.fill(0); + + result[x]++; + result[s.x]--; + + return result; + } + + unsigned enumerate() const { + return x; + } + }; + + template<unsigned q> + inline typename potts_t<q>::M_t operator*(unsigned a, const potts_t<q>& s) { + return s * a; + } + + template<unsigned q> + inline typename potts_t<q>::F_t operator*(double a, const potts_t<q>& s) { + return s * a; + } + +} + +#endif + |