summaryrefslogtreecommitdiff
path: root/src/net_create.c
diff options
context:
space:
mode:
authorpants <jaron@kent-dobias.com>2016-09-09 14:33:56 -0400
committerpants <jaron@kent-dobias.com>2016-09-09 14:33:56 -0400
commit03de79b8c5ebcc206e3450dfbc701211d9c254b0 (patch)
treeea1882e66605bbfcf257692c53f45bf1c4d0d2db /src/net_create.c
parentbf525955316995a56b9fd1e66b9345cdf4ba3561 (diff)
downloadfuse_networks-03de79b8c5ebcc206e3450dfbc701211d9c254b0.tar.gz
fuse_networks-03de79b8c5ebcc206e3450dfbc701211d9c254b0.tar.bz2
fuse_networks-03de79b8c5ebcc206e3450dfbc701211d9c254b0.zip
more refactoring
Diffstat (limited to 'src/net_create.c')
-rw-r--r--src/net_create.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/src/net_create.c b/src/net_create.c
deleted file mode 100644
index fedcb3a..0000000
--- a/src/net_create.c
+++ /dev/null
@@ -1,69 +0,0 @@
-
-#include "fracture.h"
-
-double *get_thres(uint_t ne, double beta) {
- assert(beta > 0);
-
- double *thres = (double *)malloc(ne * sizeof(double));
- assert(thres != NULL);
-
- gsl_set_error_handler_off();
-
- gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937);
- {
- FILE *rf = fopen("/dev/urandom", "r");
- unsigned long int seed;
- fread(&seed, sizeof(unsigned long int), 1, rf);
- fclose(rf);
- gsl_rng_set(r, seed);
- }
-
- for (uint_t i = 0; i < ne; i++) {
- while ((thres[i] = exp(log(gsl_ran_flat(r, 0, 1)) / beta)) == 0.0);
- }
-
- gsl_rng_free(r);
-
- return thres;
-}
-
-net_t *net_create(const graph_t *g, double inf, double beta, double notch_len, bool vb, cholmod_common *c) {
- net_t *net = (net_t *)calloc(1, sizeof(net_t));
- assert(net != NULL);
-
- net->graph = g;
- net->fuses = (bool *)calloc(g->ne, sizeof(bool));
- assert(net->fuses != NULL);
- net->thres = get_thres(g->ne, beta);
- net->inf = inf;
-
- net->voltage_bound = vb;
- net->boundary_cond = bound_set(g, vb, notch_len, c);
-
- if (g->boundary != TORUS_BOUND) net->adjacency = gen_adjacency(net, false, false, 0, c);
- else net->adjacency = gen_adjacency(net, true, false, 0, c);
-
- net->marks = (uint_t *)malloc((net->graph->break_dim) * sizeof(uint_t));
- net->dual_marks = (uint_t *)malloc((net->graph->dnv) * sizeof(uint_t));
- assert(net->marks != NULL);
-
- for (uint_t i = 0; i < (net->graph->break_dim); i++) {
- net->marks[i] = 1;
- }
- for (uint_t i = 0; i < (net->graph->dnv); i++) {
- net->dual_marks[i] = i+1;
- }
- net->num_components = 1;
-
- net_notch(net, notch_len, c);
-
- {
- cholmod_sparse *laplacian = gen_laplacian(net, c, true);
- net->factor = CHOL_F(analyze)(laplacian, c);
- CHOL_F(factorize)(laplacian, net->factor, c);
- CHOL_F(free_sparse)(&laplacian, c);
- }
-
- return net;
-}
-