summaryrefslogtreecommitdiff
path: root/src/factor_update.c
blob: f27971b943d6e8f5bebee52b6a2c00c0b884f34b (plain)
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

#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);
}