diff options
author | Jaron <jaron@kent-dobias.com> | 2017-06-22 22:40:47 -0400 |
---|---|---|
committer | Jaron <jaron@kent-dobias.com> | 2017-06-22 22:40:47 -0400 |
commit | d59fc339a40a47405bfef8c1313e324adca70479 (patch) | |
tree | addf46044c3a1507bd4069797c6218c457b67e5f /lib/gen_voltcurmat.c | |
parent | f4a50f1332ff323c42aa9664292910fd78933c15 (diff) | |
parent | 4764d5d407347d4dd5990411b243b3ec4bd75bff (diff) | |
download | fuse_networks-d59fc339a40a47405bfef8c1313e324adca70479.tar.gz fuse_networks-d59fc339a40a47405bfef8c1313e324adca70479.tar.bz2 fuse_networks-d59fc339a40a47405bfef8c1313e324adca70479.zip |
lots of changes for merge
Diffstat (limited to 'lib/gen_voltcurmat.c')
-rw-r--r-- | lib/gen_voltcurmat.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/gen_voltcurmat.c b/lib/gen_voltcurmat.c new file mode 100644 index 0000000..e870140 --- /dev/null +++ b/lib/gen_voltcurmat.c @@ -0,0 +1,36 @@ + +#include "fracture.h" + +cholmod_sparse *gen_voltcurmat(unsigned int num_edges, unsigned int num_verts, + unsigned int *edges_to_verts, + cholmod_common *c) { + + cholmod_triplet *t_m = CHOL_F(allocate_triplet)( + num_edges, num_verts, num_edges * 2, 0, CHOLMOD_REAL, c); + assert(t_m != NULL); + + int_t *rowind = (int_t *)t_m->i; + int_t *colind = (int_t *)t_m->j; + double *acoo = (double *)t_m->x; + + for (unsigned int i = 0; i < num_edges; i++) { + unsigned int v1 = edges_to_verts[2 * i]; + unsigned int v2 = edges_to_verts[2 * i + 1]; + rowind[2 * i] = i; + rowind[2 * i + 1] = i; + colind[2 * i] = v1; + colind[2 * i + 1] = v2; + acoo[2 * i] = 1; + acoo[2 * i + 1] = -1; + } + + t_m->nnz = num_edges * 2; + + assert(CHOL_F(check_triplet)(t_m, c)); + + cholmod_sparse *m = CHOL_F(triplet_to_sparse)(t_m, num_edges * 2, c); + + CHOL_F(free_triplet)(&t_m, c); + + return m; +} |