1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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)
((int_t *)update_mat->p)[i] = 0;
else
((int_t *)update_mat->p)[i] = 2;
}
((int_t *)update_mat->p)[n] = 2;
((int_t *)update_mat->i)[0] = v3;
((int_t *)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;
}
|