summaryrefslogtreecommitdiff
path: root/src/factor_update.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/factor_update.c
parentbf525955316995a56b9fd1e66b9345cdf4ba3561 (diff)
downloadfuse_networks-03de79b8c5ebcc206e3450dfbc701211d9c254b0.tar.gz
fuse_networks-03de79b8c5ebcc206e3450dfbc701211d9c254b0.tar.bz2
fuse_networks-03de79b8c5ebcc206e3450dfbc701211d9c254b0.zip
more refactoring
Diffstat (limited to 'src/factor_update.c')
-rw-r--r--src/factor_update.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/factor_update.c b/src/factor_update.c
new file mode 100644
index 0000000..f27971b
--- /dev/null
+++ b/src/factor_update.c
@@ -0,0 +1,38 @@
+
+#include "fracture.h"
+
+void factor_update(cholmod_factor *factor, uint_t v1, uint_t v2, cholmod_common *c) {
+ uint_t n = factor->n;
+
+ cholmod_sparse *update_mat =
+ CHOL_F(allocate_sparse)(n, n, 2, true, true, 0, CHOLMOD_REAL, c);
+
+ uint_t s1, s2;
+ s1 = v1 < v2 ? v1 : v2;
+ s2 = v1 > v2 ? v1 : v2;
+
+ int_t *pp = (int_t *)update_mat->p;
+ int_t *ii = (int_t *)update_mat->i;
+ double *xx = (double *)update_mat->x;
+
+ for (uint_t i = 0; i <= s1; i++) {
+ pp[i] = 0;
+ }
+
+ for (uint_t i = s1 + 1; i <= n; i++) {
+ pp[i] = 2;
+ }
+
+ ii[0] = s1;
+ ii[1] = s2;
+ xx[0] = 1;
+ xx[1] = -1;
+
+ cholmod_sparse *perm_update_mat = CHOL_F(submatrix)(
+ update_mat, factor->Perm, factor->n, NULL, -1, true, true, c);
+
+ CHOL_F(updown)(false, perm_update_mat, factor, c);
+
+ CHOL_F(free_sparse)(&perm_update_mat, c);
+ CHOL_F(free_sparse)(&update_mat, c);
+}