summaryrefslogtreecommitdiff
path: root/lib/factor_update.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:19:46 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2017-02-10 12:19:46 -0500
commit0ef0c0ce1d904be2b4e1f4da62dc029d8572c983 (patch)
tree12978013d870186240c08d1fdd6a7ce8781bca93 /lib/factor_update.c
parent9a93a3b88a604672f557950e6c7f3fe815bcf163 (diff)
parent901b9f16494f37890be17ef4bb66e6efc6873340 (diff)
downloadfuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.gz
fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.tar.bz2
fuse_networks-0ef0c0ce1d904be2b4e1f4da62dc029d8572c983.zip
Merge branch 'tmp'
Diffstat (limited to 'lib/factor_update.c')
-rw-r--r--lib/factor_update.c68
1 files changed, 68 insertions, 0 deletions
diff --git a/lib/factor_update.c b/lib/factor_update.c
new file mode 100644
index 0000000..a51705a
--- /dev/null
+++ b/lib/factor_update.c
@@ -0,0 +1,68 @@
+
+#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);
+}
+
+void factor_update2(cholmod_factor *factor, uint_t v, cholmod_common *c) {
+ uint_t n = factor->n;
+
+ cholmod_sparse *update_mat =
+ CHOL_F(allocate_sparse)(n, n, 1, true, true, 0, CHOLMOD_REAL, c);
+
+ 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 <= v; i++) {
+ pp[i] = 0;
+ }
+
+ for (uint_t i = v + 1; i <= n; i++) {
+ pp[i] = 1;
+ }
+
+ ii[0] = v;
+ xx[0] = 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);
+}