20 #include "klu2_internal.h"
21 #include "klu2_memory.hpp"
29 template <
typename Entry,
typename Int>
30 static void sort (Int n, Int *Xip, Int *Xlen, Unit *LU, Int *Tp, Int *Tj,
35 Int p, i, j, len, nz, tp, xlen, pend ;
37 ASSERT (KLU_valid_LU (n, FALSE, Xip, Xlen, LU)) ;
40 for (i = 0 ; i < n ; i++)
44 for (j = 0 ; j < n ; j++)
46 GET_POINTER (LU, Xip, Xlen, Xi, Xx, j, len) ;
47 for (p = 0 ; p < len ; p++)
55 for (i = 0 ; i < n ; i++)
61 for (i = 0 ; i < n ; i++)
67 for (j = 0 ; j < n ; j++)
69 GET_POINTER (LU, Xip, Xlen, Xi, Xx, j, len) ;
70 for (p = 0 ; p < len ; p++)
79 for (j = 0 ; j < n ; j++)
83 for (i = 0 ; i < n ; i++)
86 for (p = Tp [i] ; p < pend ; p++)
89 GET_POINTER (LU, Xip, Xlen, Xi, Xx, j, len) ;
96 ASSERT (KLU_valid_LU (n, FALSE, Xip, Xlen, LU)) ;
104 template <
typename Entry,
typename Int>
107 KLU_symbolic<Entry, Int> *Symbolic,
108 KLU_numeric<Entry, Int> *Numeric,
109 KLU_common<Entry, Int> *Common
112 Int *R, *W, *Tp, *Ti, *Lip, *Uip, *Llen, *Ulen ;
115 Int n, nk, nz, block, nblocks, maxblock, k1 ;
122 Common->status = KLU_OK ;
126 nblocks = Symbolic->nblocks ;
127 maxblock = Symbolic->maxblock ;
130 Llen = Numeric->Llen ;
132 Ulen = Numeric->Ulen ;
133 LUbx = (Unit **) Numeric->LUbx ;
135 m1 = ((
size_t) maxblock) + 1 ;
138 nz = MAX (Numeric->max_lnz_block, Numeric->max_unz_block) ;
139 W = (Int *) KLU_malloc (maxblock,
sizeof (Int), Common) ;
140 Tp = (Int *) KLU_malloc (m1,
sizeof (Int), Common) ;
141 Ti = (Int *) KLU_malloc (nz,
sizeof (Int), Common) ;
142 Tx = (Entry *) KLU_malloc (nz,
sizeof (Entry), Common) ;
144 PRINTF ((
"\n======================= Start sort:\n")) ;
146 if (Common->status == KLU_OK)
149 for (block = 0 ; block < nblocks ; block++)
152 nk = R [block+1] - k1 ;
155 PRINTF ((
"\n-------------------block: %d nk %d\n", block, nk)) ;
156 sort (nk, Lip + k1, Llen + k1, LUbx [block], Tp, Ti, Tx, W) ;
157 sort (nk, Uip + k1, Ulen + k1, LUbx [block], Tp, Ti, Tx, W) ;
162 PRINTF ((
"\n======================= sort done.\n")) ;
165 KLU_free (W, maxblock,
sizeof (Int), Common) ;
166 KLU_free (Tp, m1,
sizeof (Int), Common) ;
167 KLU_free (Ti, nz,
sizeof (Int), Common) ;
168 KLU_free (Tx, nz,
sizeof (Entry), Common) ;
169 return (Common->status == KLU_OK) ;