diff options
author | Jaron Kent-Dobias <jkentdobias@g.hmc.edu> | 2016-08-22 10:11:14 -0400 |
---|---|---|
committer | Jaron Kent-Dobias <jkentdobias@g.hmc.edu> | 2016-08-22 10:11:14 -0400 |
commit | 2bb0740b68fdb62d45adc00204b3990ca42ade77 (patch) | |
tree | a52975e3460da781467ddb70aaa8d76840d01bb4 /src/update_factor.c | |
download | fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.tar.gz fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.tar.bz2 fuse_networks-2bb0740b68fdb62d45adc00204b3990ca42ade77.zip |
started repo again without all the data files gunking the works
Diffstat (limited to 'src/update_factor.c')
-rw-r--r-- | src/update_factor.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/update_factor.c b/src/update_factor.c new file mode 100644 index 0000000..6b8e05e --- /dev/null +++ b/src/update_factor.c @@ -0,0 +1,44 @@ + +#include "fracture.h" + +bool update_factor(cholmod_factor *factor, unsigned int v1, unsigned int v2, + cholmod_common *c) { + int n = factor->n; + assert(v1 < n); + assert(v2 < n); + + cholmod_sparse *update_mat = + CHOL_F(allocate_sparse)(n, n, 2, true, true, 0, CHOLMOD_REAL, c); + + unsigned int v3, v4; + v3 = v1 < v2 ? v1 : v2; + v4 = v1 > v2 ? v1 : v2; + + for (int i = 0; i < n; i++) { + if (i <= v3) + ((CHOL_INT *)update_mat->p)[i] = 0; + else + ((CHOL_INT *)update_mat->p)[i] = 2; + } + ((CHOL_INT *)update_mat->p)[n] = 2; + ((CHOL_INT *)update_mat->i)[0] = v3; + ((CHOL_INT *)update_mat->i)[1] = v4; + ((double *)update_mat->x)[0] = 1; + ((double *)update_mat->x)[1] = -1; + + // assert(CHOL_F(check_sparse)(update_mat, c)); + + cholmod_sparse *perm_update_mat = CHOL_F(submatrix)( + update_mat, factor->Perm, factor->n, NULL, -1, true, true, c); + + // assert(CHOL_F(check_sparse)(perm_update_mat, c)); + + CHOL_F(updown)(false, perm_update_mat, factor, c); + + // assert(CHOL_F(check_factor)(factor, c)); + + CHOL_F(free_sparse)(&perm_update_mat, c); + CHOL_F(free_sparse)(&update_mat, c); + + return true; +} |