Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 20 additions & 22 deletions SRC/cgsisx.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
int colequ, equil, nofact, notran, rowequ, permc_spec, mc64;
trans_t trant;
char norm[1];
int_t i, j;
float amax, anorm, bignum, smlnum, colcnd, rowcnd, rcmax, rcmin;
int relax, panel_size, info1;
double t0; /* temporary time */
Expand Down Expand Up @@ -472,7 +471,7 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
if (rowequ) {
rcmin = bignum;
rcmax = 0.;
for (j = 0; j < A->nrow; ++j) {
for (int j = 0; j < A->nrow; ++j) {
rcmin = SUPERLU_MIN(rcmin, R[j]);
rcmax = SUPERLU_MAX(rcmax, R[j]);
}
Expand All @@ -484,7 +483,7 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
if (colequ && *info == 0) {
rcmin = bignum;
rcmax = 0.;
for (j = 0; j < A->nrow; ++j) {
for (int j = 0; j < A->nrow; ++j) {
rcmin = SUPERLU_MIN(rcmin, C[j]);
rcmax = SUPERLU_MAX(rcmax, C[j]);
}
Expand Down Expand Up @@ -538,7 +537,6 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
}

if ( nofact ) {
register int i, j;
NCformat *Astore = AA->Store;
int_t nnz = Astore->nnz;
int_t *colptr = Astore->colptr;
Expand All @@ -559,22 +557,22 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
} else {
if ( equil ) {
rowequ = colequ = 1;
for (i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
R[i] = exp(R[i]);
C[i] = exp(C[i]);
}
/* scale the matrix */
for (j = 0; j < n; j++) {
for (i = colptr[j]; i < colptr[j + 1]; i++) {
for (int j = 0; j < n; j++) {
for (int i = colptr[j]; i < colptr[j + 1]; i++) {
cs_mult(&nzval[i], &nzval[i], R[rowind[i]] * C[j]);
}
}
*equed = 'B';
}

/* permute the matrix */
for (j = 0; j < n; j++) {
for (i = colptr[j]; i < colptr[j + 1]; i++) {
for (int j = 0; j < n; j++) {
for (int i = colptr[j]; i < colptr[j + 1]; i++) {
/*nzval[i] *= R[rowind[i]] * C[j];*/
rowind[i] = perm[rowind[i]];
}
Expand Down Expand Up @@ -637,14 +635,14 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
if ((perm_tmp = int32Malloc(2*n)) == NULL)
ABORT("SUPERLU_MALLOC fails for perm_tmp[]");
iperm = perm_tmp + n;
for (i = 0; i < n; ++i) perm_tmp[i] = perm_r[perm[i]];
for (i = 0; i < n; ++i) {
for (int i = 0; i < n; ++i) perm_tmp[i] = perm_r[perm[i]];
for (int i = 0; i < n; ++i) {
perm_r[i] = perm_tmp[i];
iperm[perm[i]] = i;
}

/* Restore A's original row indices. */
for (i = 0; i < nnz; ++i) rowind[i] = iperm[rowind[i]];
for (int i = 0; i < nnz; ++i) rowind[i] = iperm[rowind[i]];

SUPERLU_FREE(perm); /* MC64 permutation */
SUPERLU_FREE(perm_tmp);
Expand Down Expand Up @@ -677,20 +675,20 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
and permutation from MC64 were performed. */
if ( notran ) {
if ( rowequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < n; ++i)
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < n; ++i)
cs_mult(&Bmat[i+j*ldb], &Bmat[i+j*ldb], R[i]);
}
} else if ( colequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < n; ++i) {
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < n; ++i) {
cs_mult(&Bmat[i+j*ldb], &Bmat[i+j*ldb], C[i]);
}
}

/* Compute the solution matrix X. */
for (j = 0; j < nrhs; j++) /* Save a copy of the right hand sides */
for (i = 0; i < B->nrow; i++)
for (int j = 0; j < nrhs; j++) /* Save a copy of the right hand sides */
for (int i = 0; i < B->nrow; i++)
Xmat[i + j*ldx] = Bmat[i + j*ldb];

t0 = SuperLU_timer_();
Expand All @@ -701,15 +699,15 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
system. */
if ( notran ) {
if ( colequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < n; ++i) {
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < n; ++i) {
cs_mult(&Xmat[i+j*ldx], &Xmat[i+j*ldx], C[i]);
}
}
} else { /* transposed system */
if ( rowequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < A->nrow; ++i) {
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < A->nrow; ++i) {
cs_mult(&Xmat[i+j*ldx], &Xmat[i+j*ldx], R[i]);
}
}
Expand Down
40 changes: 22 additions & 18 deletions SRC/cgsitrf.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
register int jcol, jj;
register int kcol; /* end column of a relaxed snode */
register int icol;
int_t i, k, iinfo;
int_t drop_row, k, iinfo;
int m, n, min_mn, jsupno, fsupc;
int_t new_next, nextlu, nextu;
int w_def; /* upper bound on panel width */
Expand Down Expand Up @@ -326,10 +326,12 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,

/* Mark the rows used by relaxed supernodes */
ifill (marker_relax, m, SLU_EMPTY);
i = mark_relax(m, relax_end, relax_fsupc, xa_begin, xa_end,
int relaxed_supernodes = mark_relax(m, relax_end, relax_fsupc, xa_begin, xa_end,
asub, marker_relax);
#if ( PRNTlevel >= 1)
printf("%d relaxed supernodes.\n", (int)i);
printf("%d relaxed supernodes.\n", relaxed_supernodes);
#else
(void)relaxed_supernodes; // to suppress unused variable warning
#endif

/*
Expand All @@ -354,9 +356,8 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
quota = gamma * Astore->nnz / m * (m - first) / m
* (last - first + 1);
else if (drop_rule & DROP_COLUMN) {
int i;
quota = 0;
for (i = first; i <= last; i++)
for (int i = first; i <= last; i++)
quota += xa_end[i] - xa_begin[i];
quota = gamma * quota * (m - first) / m;
} else if (drop_rule & DROP_AREA)
Expand All @@ -368,7 +369,7 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,

/* Drop small rows */
stempv = (float *) tempv;
i = ilu_cdrop_row(options, first, last, tol_L, quota, &nnzLj,
drop_row = ilu_cdrop_row(options, first, last, tol_L, quota, &nnzLj,
&fill_tol, Glu, stempv, swork2, 0);
/* Reset the parameters */
if (drop_rule & DROP_DYNAMIC) {
Expand All @@ -380,7 +381,9 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
}
if (fill_tol < 0) iinfo -= (int)fill_tol;
#ifdef DEBUG
num_drop_L += i * (last - first + 1);
num_drop_L += drop_row * (last - first + 1);
#else
(void)drop_row; // to suppress unused variable warning
#endif
}

Expand Down Expand Up @@ -484,7 +487,6 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,

/* Make a fill-in position if the column is entirely zero */
if (xlsub[jj + 1] == xlsub[jj]) {
register int i, row;
int_t nextl;
int_t nzlmax = Glu->nzlmax;
int_t *lsub = Glu->lsub;
Expand All @@ -503,11 +505,14 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
((singlecomplex *) Glu->lusup)[xlusup[jj]] = zero;

/* Choose a row index (pivrow) for fill-in */
for (i = jj; i < n; i++)
if (marker_relax[swap[i]] <= jj) break;
row = swap[i];
marker2[row] = jj;
lsub[xlsub[jj]] = row;
for (int i = jj; i < n; i++) {
if (marker_relax[swap[i]] <= jj) {
int row = swap[i];
marker2[row] = jj;
lsub[xlsub[jj]] = row;
break;
}
}
#ifdef DEBUG
printf("Fill col %d.\n", (int)jj);
fflush(stdout);
Expand Down Expand Up @@ -572,9 +577,8 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
quota = gamma * Astore->nnz / m * (m - first) / m
* (last - first + 1);
else if (drop_rule & DROP_COLUMN) {
int i;
quota = 0;
for (i = first; i <= last; i++)
for (int i = first; i <= last; i++)
quota += xa_end[i] - xa_begin[i];
quota = gamma * quota * (m - first) / m;
} else if (drop_rule & DROP_AREA)
Expand All @@ -587,7 +591,7 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,

/* Drop small rows */
stempv = (float *) tempv;
i = ilu_cdrop_row(options, first, last, tol_L, quota,
drop_row = ilu_cdrop_row(options, first, last, tol_L, quota,
&nnzLj, &fill_tol, Glu, stempv, swork2,
1);

Expand All @@ -601,7 +605,7 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,
}
if (fill_tol < 0) iinfo -= (int)fill_tol;
#ifdef DEBUG
num_drop_L += i * (last - first + 1);
num_drop_L += drop_row * (last - first + 1);
#endif
} /* if start a new supernode */

Expand All @@ -617,7 +621,7 @@ cgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size,

if ( m > n ) {
k = 0;
for (i = 0; i < m; ++i)
for (int i = 0; i < m; ++i)
if ( perm_r[i] == SLU_EMPTY ) {
perm_r[i] = n + k;
++k;
Expand Down
2 changes: 1 addition & 1 deletion SRC/colamd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2273,7 +2273,7 @@ PRIVATE Int find_ordering /* return the number of garbage collections */
#endif /* NDEBUG */

/* get pivot column from head of minimum degree list */
while (head [min_score] == COLAMD_EMPTY && min_score < n_col)
while (min_score < n_col && head [min_score] == COLAMD_EMPTY)
{
min_score++ ;
}
Expand Down
42 changes: 20 additions & 22 deletions SRC/dgsisx.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
int colequ, equil, nofact, notran, rowequ, permc_spec, mc64;
trans_t trant;
char norm[1];
int_t i, j;
double amax, anorm, bignum, smlnum, colcnd, rowcnd, rcmax, rcmin;
int relax, panel_size, info1;
double t0; /* temporary time */
Expand Down Expand Up @@ -472,7 +471,7 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
if (rowequ) {
rcmin = bignum;
rcmax = 0.;
for (j = 0; j < A->nrow; ++j) {
for (int j = 0; j < A->nrow; ++j) {
rcmin = SUPERLU_MIN(rcmin, R[j]);
rcmax = SUPERLU_MAX(rcmax, R[j]);
}
Expand All @@ -484,7 +483,7 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
if (colequ && *info == 0) {
rcmin = bignum;
rcmax = 0.;
for (j = 0; j < A->nrow; ++j) {
for (int j = 0; j < A->nrow; ++j) {
rcmin = SUPERLU_MIN(rcmin, C[j]);
rcmax = SUPERLU_MAX(rcmax, C[j]);
}
Expand Down Expand Up @@ -538,7 +537,6 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
}

if ( nofact ) {
register int i, j;
NCformat *Astore = AA->Store;
int_t nnz = Astore->nnz;
int_t *colptr = Astore->colptr;
Expand All @@ -559,22 +557,22 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
} else {
if ( equil ) {
rowequ = colequ = 1;
for (i = 0; i < n; i++) {
for (int i = 0; i < n; i++) {
R[i] = exp(R[i]);
C[i] = exp(C[i]);
}
/* scale the matrix */
for (j = 0; j < n; j++) {
for (i = colptr[j]; i < colptr[j + 1]; i++) {
for (int j = 0; j < n; j++) {
for (int i = colptr[j]; i < colptr[j + 1]; i++) {
nzval[i] *= R[rowind[i]] * C[j];
}
}
*equed = 'B';
}

/* permute the matrix */
for (j = 0; j < n; j++) {
for (i = colptr[j]; i < colptr[j + 1]; i++) {
for (int j = 0; j < n; j++) {
for (int i = colptr[j]; i < colptr[j + 1]; i++) {
/*nzval[i] *= R[rowind[i]] * C[j];*/
rowind[i] = perm[rowind[i]];
}
Expand Down Expand Up @@ -637,14 +635,14 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
if ((perm_tmp = int32Malloc(2*n)) == NULL)
ABORT("SUPERLU_MALLOC fails for perm_tmp[]");
iperm = perm_tmp + n;
for (i = 0; i < n; ++i) perm_tmp[i] = perm_r[perm[i]];
for (i = 0; i < n; ++i) {
for (int i = 0; i < n; ++i) perm_tmp[i] = perm_r[perm[i]];
for (int i = 0; i < n; ++i) {
perm_r[i] = perm_tmp[i];
iperm[perm[i]] = i;
}

/* Restore A's original row indices. */
for (i = 0; i < nnz; ++i) rowind[i] = iperm[rowind[i]];
for (int i = 0; i < nnz; ++i) rowind[i] = iperm[rowind[i]];

SUPERLU_FREE(perm); /* MC64 permutation */
SUPERLU_FREE(perm_tmp);
Expand Down Expand Up @@ -677,20 +675,20 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
and permutation from MC64 were performed. */
if ( notran ) {
if ( rowequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < n; ++i)
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < n; ++i)
Bmat[i + j*ldb] *= R[i];
}
} else if ( colequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < n; ++i) {
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < n; ++i) {
Bmat[i + j*ldb] *= C[i];
}
}

/* Compute the solution matrix X. */
for (j = 0; j < nrhs; j++) /* Save a copy of the right hand sides */
for (i = 0; i < B->nrow; i++)
for (int j = 0; j < nrhs; j++) /* Save a copy of the right hand sides */
for (int i = 0; i < B->nrow; i++)
Xmat[i + j*ldx] = Bmat[i + j*ldb];

t0 = SuperLU_timer_();
Expand All @@ -701,15 +699,15 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r,
system. */
if ( notran ) {
if ( colequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < n; ++i) {
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < n; ++i) {
Xmat[i + j*ldx] *= C[i];
}
}
} else { /* transposed system */
if ( rowequ ) {
for (j = 0; j < nrhs; ++j)
for (i = 0; i < A->nrow; ++i) {
for (int j = 0; j < nrhs; ++j)
for (int i = 0; i < A->nrow; ++i) {
Xmat[i + j*ldx] *= R[i];
}
}
Expand Down
Loading