1 #ifndef ALREADY_dpivmacrev
2 #define ALREADY_dpivmacrev
14 GlobalLU_t<macrev_Z> *Glu
42 int pivptr, old_pivptr, diag, diagind;
43 macrev_Z pivmax, rtemp, thresh;
48 int isub, icol,
k, itemp;
52 extern SuperLUStat_t SuperLUStat;
53 flops_t *ops = SuperLUStat.ops;
60 fsupc = (Glu->xsup)[(Glu->supno)[jcol]];
63 nsupr = xlsub[fsupc+1] - lptr;
64 lu_sup_ptr = &lusup[xlusup[fsupc]];
65 lu_col_ptr = &lusup[xlusup[jcol]];
66 lsub_ptr = &lsub[lptr];
69 if ( jcol == MIN_COL ) {
70 printf(
"Before cdiv: col %d\n", jcol);
71 for (k = nsupc; k < nsupr; k++)
72 printf(
" lu[%d] %f\n", lsub_ptr[k], lu_col_ptr[k]);
78 if ( *usepr ) *pivrow = iperm_r[jcol];
79 diagind = iperm_c[jcol];
84 for (isub = nsupc; isub < nsupr; ++isub) {
85 rtemp = lu_col_ptr[isub];
92 if ( *usepr && lsub_ptr[isub] == *pivrow ) old_pivptr = isub;
93 if ( lsub_ptr[isub] == diagind ) diag = isub;
98 *pivrow = lsub_ptr[nsupc];
100 perm_r[*pivrow] = jcol;
110 rtemp = lu_col_ptr[old_pivptr];
112 if ( rtemp != (macrev_Z)0 )
120 rtemp = lu_col_ptr[diag];
121 if ( rtemp != (macrev_Z)0 ) pivptr = diag;
123 *pivrow = lsub_ptr[pivptr];
128 perm_r[*pivrow] = jcol;
131 if ( pivptr != nsupc ) {
132 itemp = lsub_ptr[pivptr];
133 lsub_ptr[pivptr] = lsub_ptr[nsupc];
134 lsub_ptr[nsupc] = itemp;
139 for (icol = 0; icol <= nsupc; icol++) {
140 itemp = pivptr + icol * nsupr;
141 temp = lu_sup_ptr[itemp];
142 lu_sup_ptr[itemp] = lu_sup_ptr[nsupc + icol*nsupr];
143 lu_sup_ptr[nsupc + icol*nsupr] = temp;
148 ops[FACT] += nsupr - nsupc;
149 temp = (macrev_Z)1 / lu_col_ptr[nsupc];
150 for (k = nsupc+1; k < nsupr; k++)
151 lu_col_ptr[k] *= temp;
158 macrev_Z **dense, macrev_Z **tempv)
162 int maxsuper = sp_ienv(3),
165 *tempv = *dense + panel_size*m;
166 for(i=0;i<m*panel_size;i++)
167 mpz_init((*dense)[i].rep);
168 for(i=0;i<NUM_TEMPV(m,panel_size,maxsuper,rowblk);i++)
169 mpz_init((*tempv)[
i].rep);
174 void dLUWorkFree(
int m,
int panel_size,
int *iwork, macrev_Z *dwork
175 , GlobalLU_t<macrev_Z > *Glu)
178 int maxsuper = sp_ienv(3),
180 if ( Glu->MemModel == SYSTEM ) {
181 SUPERLU_FREE (iwork);
182 for(i=0;i<m*panel_size+NUM_TEMPV(m,panel_size,maxsuper,rowblk);i++)
183 mpz_clear((dwork[i].rep));
184 SUPERLU_FREE (dwork);
186 stack.used -= (stack.size - stack.top2);
187 stack.top2 = stack.size;
191 SUPERLU_FREE (expanders);
200 GlobalLU_t<macrev_Z > *Glu
205 void *new_mem, *old_mem;
206 int new_len, tries, lword, extra, bytes_to_copy;
210 if ( no_expand == 0 || keep_prev )
213 new_len = (int)(alpha * *prev_len);
216 if ( type == LSUB || type == USUB ) lword =
sizeof(int);
217 else lword =
sizeof(macrev_Z);
219 if ( Glu->MemModel == SYSTEM ) {
220 new_mem = (
void *) SUPERLU_MALLOC(new_len * lword);
221 if(new_mem && lword==
sizeof(macrev_Z))
222 for(extra=0;extra<new_len;extra++)
223 mpz_init(((macrev_Z*)new_mem)[extra].rep);
225 if ( no_expand != 0 ) {
228 if ( !new_mem )
return (NULL);
232 if ( ++tries > 10 )
return (NULL);
233 alpha = Reduce(alpha);
234 new_len = (int)(alpha * *prev_len);
235 new_mem = (
void *) SUPERLU_MALLOC(new_len * lword);
238 if(tries && lword==
sizeof(macrev_Z))
239 for(
int extra=0;extra<new_len;extra++)
240 mpz_init(((macrev_Z*)new_mem)[extra].rep);
242 if ( type == LSUB || type == USUB ) {
243 copy_mem_int(len_to_copy, expanders[type].mem, new_mem);
245 copy_mem_double<macrev_Z >(len_to_copy,
246 expanders[
type].mem, new_mem);
248 for(
unsigned int i=0;
i<len_to_copy;
i++)
249 mpz_clear(((macrev_Z*)expanders[type].mem)[
i].rep);
252 SUPERLU_FREE (expanders[type].mem);
254 expanders[
type].mem = (
void *) new_mem;
257 if ( no_expand == 0 ) {
258 new_mem = duser_malloc(new_len * lword, HEAD);
259 if ( NotDoubleAlign(new_mem) &&
260 (type == LUSUP || type == UCOL) ) {
262 new_mem = (
void *)DoubleAlign(new_mem);
263 extra = (
char*)new_mem - (
char*)old_mem;
265 printf(
"expand(): not aligned, extra %d\n", extra);
270 expanders[
type].mem = (
void *) new_mem;
274 extra = (new_len - *prev_len) * lword;
276 if ( StackFull(extra) )
return (NULL);
278 while ( StackFull(extra) ) {
279 if ( ++tries > 10 )
return (NULL);
280 alpha = Reduce(alpha);
281 new_len = (int)(alpha * *prev_len);
282 extra = (new_len - *prev_len) * lword;
286 if ( type != USUB ) {
287 new_mem = (
void*)((
char*)expanders[type + 1].mem + extra);
288 bytes_to_copy = (
char*)stack.array + stack.top1
289 - (
char*)expanders[type + 1].mem;
290 user_bcopy((
char*)expanders[type+1].mem,
291 (
char*)new_mem, bytes_to_copy);
295 (expanders[USUB].mem =
296 (
void*)((
char*)expanders[USUB].mem + extra));
299 Glu->lsub =(
int*)(expanders[LSUB].mem =
300 (
void*)((
char*)expanders[LSUB].mem + extra));
303 Glu->ucol =(macrev_Z*)( expanders[UCOL].mem =
304 (
void*)((
char*)expanders[UCOL].mem + extra));
308 if ( type == UCOL ) {
318 expanders[
type].size = new_len;
320 if ( no_expand ) ++no_expand;
322 return (
void *) expanders[
type].mem;
327 harewell<macrev_Z >::harewell(
const int nrow,
const int ncol)
332 this->rowind=(
int*)
malloc(
sizeof(
int)*(this->ncol));
333 this->colptr=(
int*)
malloc(
sizeof(
int)*(1+this->ncol));
334 this->nzval=MAC_REV_MALLOC<macrev_Z >(
sizeof(macrev_Z)*(this->ncol));
335 this->nnz=this->ncol;
336 for(
int i=0;
i<this->ncol;
i++)
342 this->colptr[this->ncol]=this->nnz;
346 inline void harewell<macrev_Z >::destroystore()
353 MAC_REV_FREE<macrev_Z>(nzval,nnz*
sizeof(macrev_Z));
392 ,
const vector<int> &rowind,
const vector<int> &colptr
395 ((NCformat *)M.Store)->nnz=coeff;
398 M.Store=(
void *)
malloc(
sizeof(NCformat));
399 NCformat *Mstore=(NCformat *)M.Store;
400 Mstore->nnz=nzval.size();
401 Mstore->nzval=(
void *)
malloc(
sizeof(macrev_Z)*(nzval.size()));
402 Mstore->rowind=(
int*)
malloc(
sizeof(
int)*(nzval.size()));
403 Mstore->colptr=(
int*)
malloc(
sizeof(
int)*(colptr.size()));
404 for(
unsigned int i=0;
i<nzval.size();++
i)
406 Mstore->rowind[
i]=rowind[
i];
407 mpz_init(((macrev_Z*)(Mstore->nzval))[
i].rep);
408 ((macrev_Z*)(Mstore->nzval))[
i]=nzval[
i];
410 for(
unsigned int i=0;
i<colptr.size();++
i)
411 Mstore->colptr[
i]=colptr[
i];
416 #endif //ALREADY_dpivmacrev
void dLUWorkFree(int m, int panel_size, int *iwork, macrev_Z *dwork, GlobalLU_t< macrev_Z > *Glu)
Definition: dpivmacrev_z.hpp:174
void * dexpand(int *prev_len, MemType type, int len_to_copy, int keep_prev, GlobalLU_t< macrev_Z > *Glu)
Definition: dpivmacrev_z.hpp:194
void remiseformatNC(SuperMatrix< macrev_Z > &M, const vector< macrev_Z > &nzval, const vector< int > &rowind, const vector< int > &colptr, int coeff)
Definition: dpivmacrev_z.hpp:391
MSKint32t k
Definition: mosek.h:2713
MSKint64t MSKint32t MSKint64t MSKsymmattypee * type
Definition: mosek.h:4257
MSKint32t MSKint32t MSKint32t i
Definition: mosek.h:2278
void dSetRWork(int m, int panel_size, macrev_Z *dworkptr, macrev_Z **dense, macrev_Z **tempv)
Definition: dpivmacrev_z.hpp:157
int dpivotL(const int jcol, const macrev_Z u, int *usepr, int *perm_r, int *iperm_r, int *iperm_c, int *pivrow, GlobalLU_t< macrev_Z > *Glu)
Definition: dpivmacrev_z.hpp:6