7 double pivot, *Lx, *Ux, *x, a, t ;
8 int *Lp, *Li, *Up, *Ui, *pinv, *xi, *q, n, ipiv, k, top, p, i,
col, lnz,unz;
9 if (!
CS_CSC (A) || !S)
return (NULL) ;
11 q = S->
q ; lnz = (int)S->
lnz ; unz = (
int)S->
unz ;
12 x = (
double*)
cs_malloc (n,
sizeof (
double)) ;
13 xi = (
int*)
cs_malloc (2*n,
sizeof (
int)) ;
15 if (!x || !xi || !N)
return (
cs_ndone (N, NULL, xi, x, 0)) ;
19 if (!L || !U || !pinv)
return (
cs_ndone (N, NULL, xi, x, 0)) ;
20 Lp = L->
p ; Up = U->
p ;
21 for (i = 0 ; i < n ; i++) x [i] = 0 ;
22 for (i = 0 ; i < n ; i++) pinv [i] = -1 ;
23 for (k = 0 ; k <= n ; k++) Lp [k] = 0 ;
25 for (k = 0 ; k < n ; k++)
33 return (
cs_ndone (N, NULL, xi, x, 0)) ;
35 Li = L->
i ; Lx = L->
x ; Ui = U->
i ; Ux = U->
x ;
36 col = q ? (q [k]) : k ;
41 for (p = top ; p < n ; p++)
46 if ((t = fabs (x [i])) > a)
58 if (ipiv == -1 || a <= 0)
return (
cs_ndone (N, NULL, xi, x, 0)) ;
59 if (pinv [col] < 0 && fabs (x [col]) >= a*tol) ipiv =
col ;
67 for (p = top ; p < n ; p++)
73 Lx [lnz++] = x [i] / pivot ;
82 for (p = 0 ; p < lnz ; p++) Li [p] = pinv [Li [p]] ;
85 return (
cs_ndone (N, NULL, xi, x, 1)) ;
cs * cs_spalloc(int m, int n, int nzmax, int values, int triplet)
int cs_sprealloc(cs *A, int nzmax)
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)
int cs_spsolve(cs *G, const cs *B, int k, int *xi, double *x, const int *pinv, int lo)
csn * cs_lu(const cs *A, const css *S, double tol)