00001 #include "cs.h" 00002 /* solve Ux=b where x and b are dense. x=b on input, solution on output. */ 00003 int cs_usolve (const cs *U, double *x) 00004 { 00005 int p, j, n, *Up, *Ui ; 00006 double *Ux ; 00007 if (!CS_CSC (U) || !x) return (0) ; /* check inputs */ 00008 n = U->n ; Up = U->p ; Ui = U->i ; Ux = U->x ; 00009 for (j = n-1 ; j >= 0 ; j--) 00010 { 00011 x [j] /= Ux [Up [j+1]-1] ; 00012 for (p = Up [j] ; p < Up [j+1]-1 ; p++) 00013 { 00014 x [Ui [p]] -= Ux [p] * x [j] ; 00015 } 00016 } 00017 return (1) ; 00018 }