9 CS_INT *Lp, *Li, *Up, *Ui, *pinv, *xi, *q, n, ipiv, k, top, p, i, col, lnz,unz;
10 if (!
CS_CSC (A) || !S)
return (NULL) ;
12 q = S->q ; lnz = S->lnz ; unz = S->unz ;
16 if (!x || !xi || !N)
return (
cs_ndone (N, NULL, xi, x, 0)) ;
20 if (!L || !U || !pinv)
return (
cs_ndone (N, NULL, xi, x, 0)) ;
21 Lp = L->p ; Up = U->p ;
22 for (i = 0 ; i < n ; i++) x [i] = 0 ;
23 for (i = 0 ; i < n ; i++) pinv [i] = -1 ;
24 for (k = 0 ; k <= n ; k++) Lp [k] = 0 ;
26 for (k = 0 ; k < n ; k++)
31 if ((lnz + n > L->nzmax && !
cs_sprealloc (L, 2*L->nzmax + n)) ||
32 (unz + n > U->nzmax && !
cs_sprealloc (U, 2*U->nzmax + n)))
34 return (
cs_ndone (N, NULL, xi, x, 0)) ;
36 Li = L->i ; Lx = L->x ; Ui = U->i ; Ux = U->x ;
37 col = q ? (q [k]) : k ;
42 for (p = top ; p < n ; p++)
47 if ((t =
CS_ABS (x [i])) > a)
59 if (ipiv == -1 || a <= 0)
return (
cs_ndone (N, NULL, xi, x, 0)) ;
60 if (pinv [col] < 0 &&
CS_ABS (x [col]) >= a*tol) ipiv = col ;
68 for (p = top ; p < n ; p++)
74 Lx [lnz++] = x [i] / pivot ;
83 for (p = 0 ; p < lnz ; p++) Li [p] = pinv [Li [p]] ;
86 return (
cs_ndone (N, NULL, xi, x, 1)) ;
csn * cs_ndone(csn *N, cs *C, void *w, void *x, CS_INT ok)
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_spsolve(cs *G, const cs *B, CS_INT k, CS_INT *xi, CS_ENTRY *x, const CS_INT *pinv, CS_INT lo)
CS_INT cs_sprealloc(cs *A, CS_INT nzmax)
void * cs_malloc(CS_INT n, size_t size)
csn * cs_lu(const cs *A, const css *S, double tol)