7 CS_INT i, k, p, n, vnz, p1, top, m2, len, col, rnz, *s, *leftmost, *Ap, *Ai,
8 *parent, *Rp, *Ri, *Vp, *Vi, *w, *pinv, *q ;
11 if (!
CS_CSC (A) || !S)
return (NULL) ;
13 n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
14 q = S->q ; parent = S->parent ; pinv = S->pinv ; m2 = S->m2 ;
15 vnz = S->lnz ; rnz = S->unz ; leftmost = S->leftmost ;
19 if (!w || !x || !N)
return (
cs_ndone (N, NULL, w, x, 0)) ;
21 for (k = 0 ; k < m2 ; k++) x [k] = 0 ;
24 N->B = Beta =
cs_malloc (n,
sizeof (
double)) ;
25 if (!R || !V || !Beta)
return (
cs_ndone (N, NULL, w, x, 0)) ;
26 Rp = R->p ; Ri = R->i ; Rx = R->x ;
27 Vp = V->p ; Vi = V->i ; Vx = V->x ;
28 for (i = 0 ; i < m2 ; i++) w [i] = -1 ;
30 for (k = 0 ; k < n ; k++)
38 for (p = Ap [col] ; p < Ap [col+1] ; p++)
40 i = leftmost [Ai [p]] ;
41 for (len = 0 ; w [i] != k ; i = parent [i])
46 while (len > 0) s [--top] = s [--len] ;
49 if (i > k && w [i] < k)
55 for (p = top ; p < n ; p++)
62 if (parent [i] == k) vnz =
cs_scatter (V, i, 0, w, NULL, k, V, vnz);
64 for (p = p1 ; p < vnz ; p++)
70 Rx [rnz++] =
cs_house (Vx+p1, Beta+k, vnz-p1) ;
74 return (
cs_ndone (N, NULL, w, x, 1)) ;
csn * cs_ndone(csn *N, cs *C, void *w, void *x, CS_INT ok)
CS_ENTRY cs_house(CS_ENTRY *x, double *beta, CS_INT n)
CS_INT cs_happly(const cs *V, CS_INT i, double beta, CS_ENTRY *x)
cs * cs_spalloc(CS_INT m, CS_INT n, CS_INT nzmax, CS_INT values, CS_INT triplet)
void * cs_calloc(CS_INT n, size_t size)
CS_INT cs_scatter(const cs *A, CS_INT j, CS_ENTRY beta, CS_INT *w, CS_ENTRY *x, CS_INT mark, cs *C, CS_INT nz)
void * cs_malloc(CS_INT n, size_t size)
csn * cs_qr(const cs *A, const css *S)