5 double *Rx, *Vx, *Ax, *x, *
Beta ;
6 int i, k, p, n, vnz, p1, top, m2, len,
col, rnz, *s, *leftmost, *Ap, *Ai,
7 *parent, *Rp, *Ri, *Vp, *Vi, *w, *pinv, *q ;
10 if (!
CS_CSC (A) || !S)
return (NULL) ;
11 n = A->
n ; Ap = A->
p ; Ai = A->
i ; Ax = A->
x ;
14 w = (
int*)
cs_malloc (m2+n,
sizeof (
int)) ;
15 x = (
double*)
cs_malloc (m2,
sizeof (
double)) ;
17 if (!w || !x || !N)
return (
cs_ndone (N, NULL, w, x, 0)) ;
19 for (k = 0 ; k < m2 ; k++) x [k] = 0 ;
22 N->
B = Beta = (
double*)
cs_malloc (n,
sizeof (
double)) ;
23 if (!R || !V || !Beta)
return (
cs_ndone (N, NULL, w, x, 0)) ;
24 Rp = R->
p ; Ri = R->
i ; Rx = R->
x ;
25 Vp = V->
p ; Vi = V->
i ; Vx = V->
x ;
26 for (i = 0 ; i < m2 ; i++) w [i] = -1 ;
28 for (k = 0 ; k < n ; k++)
36 for (p = Ap [col] ; p < Ap [col+1] ; p++)
38 i = leftmost [Ai [p]] ;
39 for (len = 0 ; w [i] != k ; i = parent [i])
44 while (len > 0) s [--top] = s [--len] ;
47 if (i > k && w [i] < k)
53 for (p = top ; p < n ; p++)
60 if (parent [i] == k) vnz =
cs_scatter (V, i, 0, w, NULL, k, V, vnz);
62 for (p = p1 ; p < vnz ; p++)
68 Rx [rnz++] =
cs_house (Vx+p1, Beta+k, vnz-p1) ;
72 return (
cs_ndone (N, NULL, w, x, 1)) ;
cs * cs_spalloc(int m, int n, int nzmax, int values, int triplet)
double cs_house(double *x, double *beta, int n)
int cs_happly(const cs *V, int i, double beta, double *x)
int cs_scatter(const cs *A, int j, double beta, int *w, double *x, int mark, cs *C, int nz)
void * cs_calloc(int n, size_t size)
void * cs_malloc(int n, size_t size)
csn * cs_ndone(csn *N, cs *C, void *w, void *x, int ok)
csn * cs_qr(const cs *A, const css *S)