From a264723b23d9ad6c3cb13450a6cf4b131f8d7338 Mon Sep 17 00:00:00 2001 From: pants Date: Thu, 8 Sep 2016 11:46:00 -0400 Subject: fixed some problems with square networks --- makefile_hal | 2 +- src/geometry.c | 4 ++-- src/graph_create.c | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/makefile_hal b/makefile_hal index be9bccc..84b9b3a 100644 --- a/makefile_hal +++ b/makefile_hal @@ -1,7 +1,7 @@ CC = clang CFLAGS = -g -Os -O3 -Wall -fno-strict-aliasing -Wstrict-overflow -Wno-missing-field-initializers -fPIC -flto #-fopenmp -LDFLAGS = -lc -lcblas -llapack -ldl -lpthread -lcholmod -lamd -lcolamd -lsuitesparseconfig -lcamd -lccolamd -lm -lrt -lmetis -lgsl -lprofiler -ltcmalloc +LDFLAGS = -lc -lcblas -llapack -ldl -lpthread -lcholmod -lamd -lcolamd -lsuitesparseconfig -lcamd -lccolamd -lm -lrt -lmetis -lgsl -lprofiler #-ltcmalloc OBJ = break_data bound_set bin_values correlations beta_scales randfuncs net get_dual_clusters coursegrain break_edge graph_components gen_laplacian geometry net_fracture get_current update_factor update_boundary get_file update_beta gen_voltcurmat graph_create free_network fortune/edgelist fortune/geometry fortune/heap fortune/main fortune/output fortune/voronoi fortune/memory get_conductivity net_notch BIN = corr_test voro_fracture fracture diff --git a/src/geometry.c b/src/geometry.c index 83ef0bf..ec788f1 100644 --- a/src/geometry.c +++ b/src/geometry.c @@ -43,9 +43,9 @@ double dual_vert_to_coord(unsigned int width, bool periodic, unsigned int vert, bool index) { if (periodic) { if (index) - return vert % (width / 2) + (vert / (width / 2)) % 2; + return (2 * vert) % width + (2 * vert / width) % 2; else - return vert / (width / 2); + return 2 * vert / width; } else { if (index) return (2 * vert) % (width + 1); diff --git a/src/graph_create.c b/src/graph_create.c index 5573064..7348142 100644 --- a/src/graph_create.c +++ b/src/graph_create.c @@ -246,10 +246,10 @@ graph_t *ini_square_network(uint_t width, bound_t boundary, bool side_bounds, network->dvx = (double *)malloc(2 * network->dnv * sizeof(double)); for (uint_t i = 0; i < network->dnv; i++) { - network->dvx[2 * i] = - 2*dual_vert_to_coord(width, periodic, i, 0); network->dvx[2 * i + 1] = - 2*dual_vert_to_coord(width, periodic, i, 1); + dual_vert_to_coord(width, periodic, i, 0) / width; + network->dvx[2 * i] = + dual_vert_to_coord(width, periodic, i, 1) / width; } network->voltcurmat = gen_voltcurmat(network->ne, @@ -665,7 +665,6 @@ graph_t *ini_voro_graph(uint_t L, bound_t boundary, bool use_dual, return g; } - graph_t *graph_create(lattice_t lattice, bound_t bound, uint_t L, bool dual, cholmod_common *c) { bool side_bounds; switch (lattice) { -- cgit v1.2.3-70-g09d2