32 Entry *Offx, *Lx, *Ux, *X, *Az, *Udiag ;
34 Int *
P, *Q, *R, *Pnum, *Offp, *Offi, *Ui, *Li, *Pinv, *Lip, *Uip, *Llen,
38 Int k1, k2, nk, k, block, oldcol, pend, oldrow,
n, p, newrow,
scale,
39 nblocks, poff, i, j, up, ulen, llen, maxblock, nzoff ;
58 Common->numerical_rank =
EMPTY ;
59 Common->singular_col =
EMPTY ;
71 nblocks = Symbolic->nblocks ;
72 maxblock = Symbolic->maxblock ;
78 Pnum = Numeric->Pnum ;
79 Offp = Numeric->Offp ;
80 Offi = Numeric->Offi ;
81 Offx = (
Entry *) Numeric->Offx ;
83 LUbx = (
Unit **) Numeric->LUbx ;
85 scale = Common->scale ;
89 if (Numeric->Rs ==
NULL)
91 Numeric->Rs =
KLU_malloc (n,
sizeof (
double), Common) ;
92 if (Common->status <
KLU_OK)
103 Numeric->Rs =
KLU_free (Numeric->Rs, n, sizeof (
double), Common) ;
107 Pinv = Numeric->Pinv ;
108 X = (
Entry *) Numeric->Xwork ;
109 Common->nrealloc = 0 ;
110 Udiag = Numeric->Udiag ;
111 nzoff = Symbolic->nzoff ;
131 for (k = 0 ; k < maxblock ; k++)
150 for (block = 0 ; block < nblocks ; block++)
169 pend = Ap [oldcol+1] ;
171 for (p = Ap [oldcol] ; p < pend ; p++)
173 newrow = Pinv [Ai [p]] - k1 ;
174 if (newrow < 0 && poff < nzoff)
177 Offx [poff] = Az [p] ;
196 Lip = Numeric->Lip + k1 ;
197 Llen = Numeric->Llen + k1 ;
198 Uip = Numeric->Uip + k1 ;
199 Ulen = Numeric->Ulen + k1 ;
202 for (k = 0 ; k < nk ; k++)
210 pend = Ap [oldcol+1] ;
211 for (p = Ap [oldcol] ; p < pend ; p++)
213 newrow = Pinv [Ai [p]] - k1 ;
214 if (newrow < 0 && poff < nzoff)
217 Offx [poff] = Az [p] ;
223 X [newrow] = Az [p] ;
232 for (up = 0 ; up < ulen ; up++)
240 for (p = 0 ; p < llen ; p++)
243 MULT_SUB (X [Li [p]], Lx [p], ujk) ;
255 if (Common->numerical_rank ==
EMPTY)
257 Common->numerical_rank = k+k1 ;
258 Common->singular_col = Q [k+k1] ;
260 if (Common->halt_if_singular)
269 for (p = 0 ; p < llen ; p++)
272 DIV (Lx [p], X [i], ukk) ;
288 for (block = 0 ; block < nblocks ; block++)
307 pend = Ap [oldcol+1] ;
309 for (p = Ap [oldcol] ; p < pend ; p++)
312 newrow = Pinv [oldrow] - k1 ;
313 if (newrow < 0 && poff < nzoff)
337 Lip = Numeric->Lip + k1 ;
338 Llen = Numeric->Llen + k1 ;
339 Uip = Numeric->Uip + k1 ;
340 Ulen = Numeric->Ulen + k1 ;
343 for (k = 0 ; k < nk ; k++)
351 pend = Ap [oldcol+1] ;
352 for (p = Ap [oldcol] ; p < pend ; p++)
355 newrow = Pinv [oldrow] - k1 ;
356 if (newrow < 0 && poff < nzoff)
376 for (up = 0 ; up < ulen ; up++)
384 for (p = 0 ; p < llen ; p++)
387 MULT_SUB (X [Li [p]], Lx [p], ujk) ;
399 if (Common->numerical_rank ==
EMPTY)
401 Common->numerical_rank = k+k1 ;
402 Common->singular_col = Q [k+k1] ;
404 if (Common->halt_if_singular)
413 for (p = 0 ; p < llen ; p++)
416 DIV (Lx [p], X [i], ukk) ;
430 for (k = 0 ; k < n ; k++)
432 REAL (X [k]) = Rs [Pnum [k]] ;
434 for (k = 0 ; k < n ; k++)
436 Rs [k] =
REAL (X [k]) ;
441 ASSERT (Offp [n] == poff) ;
442 ASSERT (Symbolic->nzoff == poff) ;
443 PRINTF ((
"\n------------------- Off diagonal entries, new:\n")) ;
445 if (Common->status ==
KLU_OK)
447 PRINTF ((
"\n ########### KLU_BTF_REFACTOR done, nblocks %d\n",nblocks));
448 for (block = 0 ; block < nblocks ; block++)
454 "\n================KLU_refactor output: k1 %d k2 %d nk %d\n",
463 Lip = Numeric->Lip + k1 ;
464 Llen = Numeric->Llen + k1 ;
465 LU = (
Unit *) Numeric->LUbx [block] ;
466 PRINTF ((
"\n---- L block %d\n", block)) ;
468 Uip = Numeric->Uip + k1 ;
469 Ulen = Numeric->Ulen + k1 ;
470 PRINTF ((
"\n---- U block %d\n", block)) ;
#define GET_POINTER(LU, Xip, Xlen, Xi, Xx, k, xlen)
Int KLU_refactor(Int Ap[], Int Ai[], double Ax[], KLU_symbolic *Symbolic, KLU_numeric *Numeric, KLU_common *Common)
#define KLU_OUT_OF_MEMORY
#define ASSERT(expression)
#define MULT_SUB(c, a, b)
#define SCALE_DIV_ASSIGN(a, c, s)