diff options
author | pants <jaron@kent-dobias.com> | 2016-09-08 12:28:07 -0400 |
---|---|---|
committer | pants <jaron@kent-dobias.com> | 2016-09-08 12:28:07 -0400 |
commit | 0b6e6a4337e8e9b6728f3604bb61a59365be3446 (patch) | |
tree | 389798c8a4638506a236a276e6847d65648f6640 /src | |
parent | cf272339a3b72cf192ba986d37e50de16a4cbe49 (diff) | |
download | fuse_networks-0b6e6a4337e8e9b6728f3604bb61a59365be3446.tar.gz fuse_networks-0b6e6a4337e8e9b6728f3604bb61a59365be3446.tar.bz2 fuse_networks-0b6e6a4337e8e9b6728f3604bb61a59365be3446.zip |
src/bound_set.c
Diffstat (limited to 'src')
-rw-r--r-- | src/corr_test.c | 1 | ||||
-rw-r--r-- | src/correlations.c | 4 | ||||
-rw-r--r-- | src/fortune/defs.h | 2 | ||||
-rw-r--r-- | src/fortune/main.c | 4 | ||||
-rw-r--r-- | src/fortune/memory.c | 2 | ||||
-rw-r--r-- | src/fracture.h | 2 | ||||
-rw-r--r-- | src/gen_laplacian.c | 2 | ||||
-rw-r--r-- | src/get_current.c | 4 | ||||
-rw-r--r-- | src/graph_components.c | 38 | ||||
-rw-r--r-- | src/graph_create.c | 8 | ||||
-rw-r--r-- | src/net_notch.c | 3 | ||||
-rw-r--r-- | src/randfuncs.c | 4 |
12 files changed, 33 insertions, 41 deletions
diff --git a/src/corr_test.c b/src/corr_test.c index a8eaff5..4805fb0 100644 --- a/src/corr_test.c +++ b/src/corr_test.c @@ -6,7 +6,6 @@ int main() { CHOL_F(start)(&c); unsigned int width = 64; - unsigned int n = pow(width / 2 + 1, 2) + pow((width + 1) / 2, 2); graph_t *network = ini_square_network(width, true, false, &c); net_t *instance = net_create(network, 1e-14, 0.001, 0, true, &c); diff --git a/src/correlations.c b/src/correlations.c index 7fedfbf..3e7749c 100644 --- a/src/correlations.c +++ b/src/correlations.c @@ -197,7 +197,7 @@ void fib_decreasekey(fibh *heap, unsigned int value, } } -unsigned int *dijkstra(graph_t *network, unsigned int source) { +unsigned int *dijkstra(const graph_t *network, unsigned int source) { unsigned int nv = network->dnv; unsigned int *vei = network->dvei; unsigned int *ve = network->dve; @@ -236,7 +236,7 @@ unsigned int *dijkstra(graph_t *network, unsigned int source) { return dist; } -unsigned int **get_dists(graph_t *network) { +unsigned int **get_dists(const graph_t *network) { unsigned int nv = network->dnv; unsigned int **dists = (unsigned int **)malloc(nv * sizeof(unsigned int *)); diff --git a/src/fortune/defs.h b/src/fortune/defs.h index b186581..9f1b1db 100644 --- a/src/fortune/defs.h +++ b/src/fortune/defs.h @@ -39,7 +39,7 @@ extern int nvertices; extern struct Freelist sfl; extern struct Site *bottomsite; -char **alloclist; +void **alloclist; int allocnum; struct Edge { diff --git a/src/fortune/main.c b/src/fortune/main.c index a1a4372..b6b4476 100644 --- a/src/fortune/main.c +++ b/src/fortune/main.c @@ -86,7 +86,7 @@ intptr_t *run_voronoi(unsigned int num, double *lattice, bool periodic, double x plot = 0; debug = 0; - alloclist = (char **)malloc(9 * num * sizeof(char *)); + alloclist = (void **)malloc(9 * num * sizeof(void *)); allocnum = 0; freeinit(&sfl, sizeof *sites); @@ -160,7 +160,6 @@ intptr_t *run_voronoi(unsigned int num, double *lattice, bool periodic, double x unsigned int real_vert_count = vert_count; unsigned int real_edge_count = edge_count; - unsigned int real_dual_count = dual_count; double *real_vert_list = vert_list; unsigned int *real_edge_list = edge_list; unsigned int *real_dual_list = dual_list; @@ -168,7 +167,6 @@ intptr_t *run_voronoi(unsigned int num, double *lattice, bool periodic, double x if (periodic) { real_vert_count = 0; real_edge_count = 0; - real_dual_count = 0; real_vert_list = (double *)malloc(2 * vert_count * sizeof(double)); real_edge_list = (unsigned int *)malloc(2 * edge_count * sizeof(unsigned int)); real_dual_list = (unsigned int *)malloc(3 * dual_count * sizeof(unsigned int)); diff --git a/src/fortune/memory.c b/src/fortune/memory.c index 807d1b0..3d62a92 100644 --- a/src/fortune/memory.c +++ b/src/fortune/memory.c @@ -13,7 +13,7 @@ char *getfree(fl) struct Freelist *fl; struct Freenode *t; if (fl->head == (struct Freenode *)NULL) { t = (struct Freenode *)myalloc(sqrt_nsites * fl->nodesize); - alloclist[allocnum] = t; + alloclist[allocnum] = (void *)t; allocnum++; for (i = 0; i < sqrt_nsites; i += 1) makefree((struct Freenode *)((char *)t + i * fl->nodesize), fl); diff --git a/src/fracture.h b/src/fracture.h index bea4bc7..19b1e71 100644 --- a/src/fracture.h +++ b/src/fracture.h @@ -185,3 +185,5 @@ double get_conductivity(net_t *inst, double *current, cholmod_common *c); graph_t *graph_create(lattice_t lattice, bound_t bound, uint_t L, bool dual, cholmod_common *c); uint_t find_cycles(uint_t num_edges, const bool *fuses, const uint_t *ev, const uint_t *vei, const uint_t *ve, int **cycles); + +bool set_connected(const cholmod_sparse *laplacian, uint_t *marks, int vertex, int label, int stop_at, int exclude); diff --git a/src/gen_laplacian.c b/src/gen_laplacian.c index 4196937..16054e3 100644 --- a/src/gen_laplacian.c +++ b/src/gen_laplacian.c @@ -94,7 +94,6 @@ cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c, bool symmetric) { const graph_t *network = instance->graph; unsigned int num_verts = network->nv_break; - double *vert_coords = network->vx; unsigned int num_bounds = network->num_bounds; double inf = instance->inf; bool voltage_bound = instance->voltage_bound; @@ -129,7 +128,6 @@ cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c, cholmod_sparse *adjacency = gen_adjacency(instance, false, true, (int)num_gverts - (int)num_verts, c); int_t *ia = (int_t *)adjacency->p; - int_t *ja = (int_t *)adjacency->i; double *aa = (double *)adjacency->x; for (unsigned int i = 0; i < num_verts; i++) { diff --git a/src/get_current.c b/src/get_current.c index 8493370..a83c399 100644 --- a/src/get_current.c +++ b/src/get_current.c @@ -27,9 +27,7 @@ double *get_voltage(const net_t *instance, cholmod_common *c) { double *get_current(const net_t *instance, cholmod_common *c) { unsigned int num_edges = instance->graph->ne; - unsigned int num_verts = instance->graph->nv_break; unsigned int num_gverts = instance->graph->break_dim; - unsigned int num_bounds = instance->graph->num_bounds; cholmod_sparse *voltcurmat = instance->graph->voltcurmat; double *voltages = get_voltage(instance, c); @@ -68,9 +66,7 @@ double *get_current(const net_t *instance, cholmod_common *c) { double *get_current_v(const net_t *instance, double *voltages, cholmod_common *c) { unsigned int num_edges = instance->graph->ne; - unsigned int num_verts = instance->graph->nv_break; unsigned int num_gverts = instance->graph->break_dim; - unsigned int num_bounds = instance->graph->num_bounds; cholmod_sparse *voltcurmat = instance->graph->voltcurmat; cholmod_dense *x = CHOL_F(allocate_dense)( diff --git a/src/graph_components.c b/src/graph_components.c index c4e894d..9680675 100644 --- a/src/graph_components.c +++ b/src/graph_components.c @@ -1,7 +1,7 @@ #include "fracture.h" -bool set_connected(const cholmod_sparse *laplacian, unsigned int *marks, +bool set_connected(const cholmod_sparse *laplacian, uint_t *marks, int vertex, int label, int stop_at, int exclude) { unsigned int num_verts = (int_t)laplacian->nrow; @@ -90,17 +90,17 @@ unsigned int *find_components(const cholmod_sparse *laplacian, unsigned int skip return marks; } -unsigned int find_cycles(unsigned int num_edges, const bool *fuses, const unsigned int *ev, const unsigned - int *vei, const unsigned int *ve, int **cycles) { - unsigned int num_cycles = 0; - unsigned int *elist = (unsigned int *)malloc(num_edges * sizeof(unsigned int)); - unsigned int *side = (unsigned int *)calloc(num_edges, sizeof(unsigned int)); - unsigned int *num = (unsigned int *)malloc(num_edges * sizeof(unsigned int)); - for (unsigned int i = 0; i < num_edges; i++) { +uint_t find_cycles(uint_t num_edges, const bool *fuses, const uint_t *ev, const unsigned + int *vei, const uint_t *ve, int **cycles) { + uint_t num_cycles = 0; + uint_t *elist = (uint_t *)malloc(num_edges * sizeof(uint_t)); + uint_t *side = (uint_t *)calloc(num_edges, sizeof(uint_t)); + uint_t *num = (uint_t *)malloc(num_edges * sizeof(uint_t)); + for (uint_t i = 0; i < num_edges; i++) { if (fuses[i]) { bool in_cycle = false; - for (unsigned int j = 0; j < num_cycles; j++) { - unsigned int k = 0; + for (uint_t j = 0; j < num_cycles; j++) { + uint_t k = 0; int e; while ((e = cycles[j][k]) >= 0) { if (e == i) { @@ -114,17 +114,17 @@ unsigned int find_cycles(unsigned int num_edges, const bool *fuses, const unsign } } if (!in_cycle) { - unsigned int pos = 0; - unsigned int cur_e = i; + uint_t pos = 0; + uint_t cur_e = i; bool *included = (bool *)calloc(num_edges, sizeof(bool)); included[cur_e] = true; elist[0] = cur_e; side[0] = 1; num[0] = 0; while (true) { - unsigned int cv = ev[2 * cur_e + side[pos]]; - unsigned int new_e = cur_e; - unsigned int j; + uint_t cv = ev[2 * cur_e + side[pos]]; + uint_t new_e = cur_e; + uint_t j; for (j = num[pos]; j < vei[cv+1] - vei[cv]; j++) { new_e = ve[vei[cv] + j]; if (new_e != cur_e && fuses[new_e]) break; @@ -134,7 +134,7 @@ unsigned int find_cycles(unsigned int num_edges, const bool *fuses, const unsign pos++; cycles[2*num_cycles] = (int *)malloc((pos + 1) * sizeof(int)); cycles[2*num_cycles+1] = (int *)malloc((pos + 1) * sizeof(int)); - for (unsigned int i = 0; i < pos; i++) { + for (uint_t i = 0; i < pos; i++) { cycles[2*num_cycles][i] = elist[i]; cycles[2*num_cycles+1][i] = side[i]; } @@ -156,9 +156,9 @@ unsigned int find_cycles(unsigned int num_edges, const bool *fuses, const unsign pos++; elist[pos] = new_e; included[new_e] = true; - unsigned int nv1 = ev[2 * new_e]; - unsigned int nv2 = ev[2 * new_e + 1]; - unsigned int v = nv1 == cv ? nv2 : nv1; + uint_t nv1 = ev[2 * new_e]; + uint_t nv2 = ev[2 * new_e + 1]; + uint_t v = nv1 == cv ? nv2 : nv1; side[pos] = v == nv1 ? 0 : 1; num[pos] = 0; cur_e = new_e; diff --git a/src/graph_create.c b/src/graph_create.c index 7348142..874a85c 100644 --- a/src/graph_create.c +++ b/src/graph_create.c @@ -482,7 +482,7 @@ graph_t *ini_voro_graph(uint_t L, bound_t boundary, bool use_dual, bound_b = (bool *)calloc(num_verts, sizeof(bool)); for (uint_t i = 0; i < tmp_num_edges; i++) { uint_t v1, v2; - double v1x, v1y, v2x, v2y, dx, dy; + double v1y, v2y, dy; v1 = tmp_edges[2 * i]; v2 = tmp_edges[2 * i + 1]; v1y = vert_coords[2 * v1 + 1]; v2y = vert_coords[2 * v2 + 1]; dy = v1y - v2y; @@ -549,10 +549,10 @@ graph_t *ini_voro_graph(uint_t L, bound_t boundary, bool use_dual, uint_t num_t = 0; for (uint_t i = 0; i < num_edges; i++) { uint_t v1, v2; - double v1x, v1y, v2x, v2y, dx, dy; + double v1y, v2y, dy; v1 = edges[2 * i]; v2 = edges[2 * i + 1]; - v1x = tmp_vert_coords[2 * v1]; v1y = tmp_vert_coords[2 * v1 + 1]; - v2x = tmp_vert_coords[2 * v2]; v2y = tmp_vert_coords[2 * v2 + 1]; + v1y = tmp_vert_coords[2 * v1 + 1]; + v2y = tmp_vert_coords[2 * v2 + 1]; dy = v1y - v2y; if (fabs(dy) > 0.5) { if (dy > 0) { diff --git a/src/net_notch.c b/src/net_notch.c index 48dce1e..ccbb387 100644 --- a/src/net_notch.c +++ b/src/net_notch.c @@ -4,7 +4,7 @@ void net_notch(net_t *net, double notch_len, cholmod_common *c) { for (uint_t i = 0; i < net->graph->ne; i++) { uint_t v1, v2; - double v1x, v1y, v2x, v2y, dx, dy; + double v1x, v1y, v2x, v2y, dy; bool crosses_center, not_wrapping, correct_length; v1 = net->graph->ev[2 * i]; @@ -15,7 +15,6 @@ void net_notch(net_t *net, double notch_len, cholmod_common *c) { v2x = net->graph->vx[2 * v2]; v2y = net->graph->vx[2 * v2 + 1]; - dx = v1x - v2x; dy = v1y - v2y; crosses_center = (v1y >= 0.5 && v2y <= 0.5) || (v1y <= 0.5 && v2y >= 0.5); diff --git a/src/randfuncs.c b/src/randfuncs.c index 830e078..137c7ff 100644 --- a/src/randfuncs.c +++ b/src/randfuncs.c @@ -57,10 +57,10 @@ double *genfunc_hyperuniform(unsigned int L, bound_t boundary, gsl_rng *r, unsig ds[2] = pow(x-lattice[2*j] - 1,2)+pow(y-lattice[2*j+1],2); ds[3] = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1] + 1,2); ds[4] = pow(x-lattice[2*j],2)+pow(y-lattice[2*j+1] - 1,2); - unsigned int min_pos = 0; double min_val = 100; + double min_val = 100; for (unsigned int k = 0; k < 5; k++) { if (min_val > ds[k]) { - min_pos = k; min_val = ds[k]; + min_val = ds[k]; } } if (1-gsl_sf_exp(-M_PI * rho * min_val) < gsl_ran_flat(r, 0, 1)) { |