summaryrefslogtreecommitdiff
path: root/lib/potts.h
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-22 01:20:29 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-22 01:20:29 -0400
commitdd2c47db3512658858685c83dd772603203aaab1 (patch)
treee029032fb62317237482844af9f1bbd3b5545c45 /lib/potts.h
parente74305e932e45c0d2e69fd1c0a7313662fc47375 (diff)
downloadc++-dd2c47db3512658858685c83dd772603203aaab1.tar.gz
c++-dd2c47db3512658858685c83dd772603203aaab1.tar.bz2
c++-dd2c47db3512658858685c83dd772603203aaab1.zip
potts now fully functional
Diffstat (limited to 'lib/potts.h')
-rw-r--r--lib/potts.h22
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/potts.h b/lib/potts.h
index e7f0899..e411ddb 100644
--- a/lib/potts.h
+++ b/lib/potts.h
@@ -44,13 +44,11 @@ void free_spin(potts_t <q> s) {
// do nothing!
}
-template <q_t q>
-void free_spin(typename potts_t<q>::M_t s) {
+void free_spin(int *s) {
free(s);
}
-template <q_t q>
-void free_spin(typename potts_t<q>::F_t s) {
+void free_spin(double *s) {
free(s);
}
@@ -60,13 +58,13 @@ potts_t <q> copy(potts_t <q> s) {
}
template <q_t q>
-void add(typename potts_t<q>::M_t s1, int a, potts_t <q> s2) {
- s1[s2.x] += a;
+void add(typename potts_t<q>::M_t *s1, int a, potts_t <q> s2) {
+ (*s1)[s2.x] += a;
}
template <q_t q>
-void add(typename potts_t<q>::F_t s1, double a, potts_t <q> s2) {
- s1[s2.x] += a;
+void add(typename potts_t<q>::F_t *s1, double a, potts_t <q> s2) {
+ (*s1)[s2.x] += a;
}
template <q_t q>
@@ -78,13 +76,13 @@ typename potts_t<q>::M_t scalar_multiple(int factor, potts_t <q> s) {
template <q_t q>
typename potts_t<q>::F_t scalar_multiple(double factor, potts_t <q> s) {
- int *F = (double *)calloc(q, sizeof(double));
- M[s.x] += factor;
- return M;
+ double *F = (double *)calloc(q, sizeof(double));
+ F[s.x] += factor;
+ return F;
}
template <q_t q>
-double norm_squared(typename potts<q>::F_t s) {
+double norm_squared(typename potts_t<q>::F_t s) {
double total = 0;
for (q_t i = 0; i < q; i++) {
total += pow(s[i], 2);