From 4c4ebb87ead363d6d6e11a8b95b07a0f93af5c88 Mon Sep 17 00:00:00 2001 From: pants Date: Tue, 6 Sep 2016 15:05:27 -0400 Subject: finished implementing embedded systems, refactored a bunch --- src/gen_laplacian.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src/gen_laplacian.c') diff --git a/src/gen_laplacian.c b/src/gen_laplacian.c index 97a2c9d..6034a82 100644 --- a/src/gen_laplacian.c +++ b/src/gen_laplacian.c @@ -1,15 +1,15 @@ #include "fracture.h" -cholmod_sparse *gen_adjacency(const finst *instance, bool dual, bool breakv, +cholmod_sparse *gen_adjacency(const net_t *instance, bool dual, bool breakv, unsigned int pad, cholmod_common *c) { unsigned int ne; if (dual) - ne = ((int)instance->network->num_edges); + ne = ((int)instance->graph->ne); else { ne = instance->num_remaining_edges; - if (!breakv && instance->network->boundary != TORUS_BOUND) { - ne += instance->network->bound_inds[2]; + if (!breakv && instance->graph->boundary != TORUS_BOUND) { + ne += instance->graph->bound_inds[2]; } } @@ -17,11 +17,11 @@ cholmod_sparse *gen_adjacency(const finst *instance, bool dual, bool breakv, unsigned int nv; if (dual) - nv = instance->network->num_dual_verts; + nv = instance->graph->dnv; else { - if (breakv) nv = instance->network->num_verts_break; - else nv = instance->network->num_verts; - if (instance->network->boundary != TORUS_BOUND && !breakv) { + if (breakv) nv = instance->graph->nv_break; + else nv = instance->graph->nv; + if (instance->graph->boundary != TORUS_BOUND && !breakv) { nv += 2; } } @@ -36,15 +36,15 @@ cholmod_sparse *gen_adjacency(const finst *instance, bool dual, bool breakv, unsigned int *etv; if (dual) - etv = instance->network->dual_edges_to_verts; + etv = instance->graph->dev; else { - if (breakv) etv = instance->network->edges_to_verts_break; - else etv = instance->network->edges_to_verts; + if (breakv) etv = instance->graph->ev_break; + else etv = instance->graph->ev; } unsigned int count = 0; - for (unsigned int i = 0; i < instance->network->num_edges; i++) { + for (unsigned int i = 0; i < instance->graph->ne; i++) { if ((instance->fuses[i] && dual) || (!instance->fuses[i] && !dual)) { unsigned int v1 = etv[2 * i]; unsigned int v2 = etv[2 * i + 1]; @@ -74,14 +74,14 @@ cholmod_sparse *gen_adjacency(const finst *instance, bool dual, bool breakv, } } - if (!breakv && instance->network->boundary != TORUS_BOUND && !dual) { + if (!breakv && instance->graph->boundary != TORUS_BOUND && !dual) { for (unsigned int i = 0; i < 2; i++) { - for (unsigned int j = 0; j < instance->network->bound_inds[i+1] - instance->network->bound_inds[i]; j++) { - ri[2*count] = instance->network->num_verts + i; - ci[2*count] = instance->network->bound_verts[instance->network->bound_inds[i] + j]; + for (unsigned int j = 0; j < instance->graph->bound_inds[i+1] - instance->graph->bound_inds[i]; j++) { + ri[2*count] = instance->graph->nv + i; + ci[2*count] = instance->graph->bound_verts[instance->graph->bound_inds[i] + j]; ai[2*count] = 1; - ri[2*count+1] = instance->network->bound_verts[instance->network->bound_inds[i] + j]; - ci[2*count+1] = instance->network->num_verts + i; + ri[2*count+1] = instance->graph->bound_verts[instance->graph->bound_inds[i] + j]; + ci[2*count+1] = instance->graph->nv + i; ai[2*count+1] = 1; count++; } @@ -95,10 +95,10 @@ cholmod_sparse *gen_adjacency(const finst *instance, bool dual, bool breakv, return s; } -cholmod_sparse *gen_laplacian(const finst *instance, cholmod_common *c, +cholmod_sparse *gen_laplacian(const net_t *instance, cholmod_common *c, bool symmetric) { - const fnet *network = instance->network; - unsigned int num_verts = network->num_verts_break; + const graph_t *network = instance->graph; + unsigned int num_verts = network->nv_break; double *vert_coords = network->vert_coords; unsigned int num_bounds = network->num_bounds; double inf = instance->inf; @@ -147,13 +147,13 @@ cholmod_sparse *gen_laplacian(const finst *instance, cholmod_common *c, for (unsigned int i = 0; i < network->bound_inds[1]; i++) { unsigned int vv = network->bound_verts[i]; rowind[num_gverts + 2*i] = vv; - colind[num_gverts + 2*i] = network->num_verts + i; + colind[num_gverts + 2*i] = network->nv + i; acoo[num_gverts + 2*i] = -1; - rowind[num_gverts + 2*i+1] = network->num_verts + i; + rowind[num_gverts + 2*i+1] = network->nv + i; colind[num_gverts + 2*i+1] = vv; acoo[num_gverts + 2*i+1] = -1; acoo[vv]++; - acoo[network->num_verts + i]++; + acoo[network->nv + i]++; } acoo[bound_verts[0]]++; } -- cgit v1.2.3-70-g09d2