summaryrefslogtreecommitdiff
path: root/lib/state.h
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-25 18:14:55 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2018-07-25 18:14:55 -0400
commit9be622f7703193cde9955b9663cea1259ac48efc (patch)
treeacd44702cfd8e52306c0a524cce8885c7a78eb80 /lib/state.h
parenta3162d7baf9096df1e5d88edfd9dcd79cf81dff0 (diff)
downloadc++-9be622f7703193cde9955b9663cea1259ac48efc.tar.gz
c++-9be622f7703193cde9955b9663cea1259ac48efc.tar.bz2
c++-9be622f7703193cde9955b9663cea1259ac48efc.zip
trying some new c++ things, starting with graph
Diffstat (limited to 'lib/state.h')
-rw-r--r--lib/state.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/state.h b/lib/state.h
index 3c6cafa..3cef157 100644
--- a/lib/state.h
+++ b/lib/state.h
@@ -13,7 +13,7 @@ class state_t {
L_t L;
v_t nv;
v_t ne;
- graph_t *g;
+ graph_t g;
double T;
X_t *spins;
R_t R;
@@ -29,12 +29,10 @@ class state_t {
std::function <double(X_t, X_t)> J;
std::function <double(X_t)> H;
- state_t(D_t D, L_t L, double T, std::function <double(X_t, X_t)> J, std::function <double(X_t)> H) : D(D), L(L), T(T), J(J), H(H) {
- graph_t *h = graph_create_square(D, L);
- nv = h->nv;
- ne = h->ne;
- g = graph_add_ext(h);
- graph_free(h);
+ state_t(D_t D, L_t L, double T, std::function <double(X_t, X_t)> J, std::function <double(X_t)> H) : D(D), L(L), T(T), J(J), H(H), g(D, L) {
+ nv = g.nv;
+ ne = g.ne;
+ g.add_ext();
spins = (X_t *)malloc(nv * sizeof(X_t));
for (v_t i = 0; i < nv; i++) {
init (&(spins[i]));
@@ -58,7 +56,6 @@ class state_t {
}
~state_t() {
- graph_free(g);
for (v_t i = 0; i < nv; i++) {
free_spin(spins[i]);
}