diff --git a/SRC/cgsisx.c b/SRC/cgsisx.c index ad98d743..71b25584 100644 --- a/SRC/cgsisx.c +++ b/SRC/cgsisx.c @@ -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 */ @@ -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]); } @@ -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]); } @@ -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; @@ -559,13 +557,13 @@ 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]); } } @@ -573,8 +571,8 @@ cgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, } /* 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]]; } @@ -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); @@ -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_(); @@ -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]); } } diff --git a/SRC/cgsitrf.c b/SRC/cgsitrf.c index 80de236e..d3be7bdc 100644 --- a/SRC/cgsitrf.c +++ b/SRC/cgsitrf.c @@ -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 */ @@ -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 /* @@ -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) @@ -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) { @@ -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 } @@ -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; @@ -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); @@ -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) @@ -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); @@ -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 */ @@ -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; diff --git a/SRC/colamd.c b/SRC/colamd.c index 6cfb9fca..58f66354 100644 --- a/SRC/colamd.c +++ b/SRC/colamd.c @@ -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++ ; } diff --git a/SRC/dgsisx.c b/SRC/dgsisx.c index d59d567c..1f27326a 100644 --- a/SRC/dgsisx.c +++ b/SRC/dgsisx.c @@ -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 */ @@ -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]); } @@ -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]); } @@ -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; @@ -559,13 +557,13 @@ 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]; } } @@ -573,8 +571,8 @@ dgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, } /* 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]]; } @@ -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); @@ -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_(); @@ -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]; } } diff --git a/SRC/dgsitrf.c b/SRC/dgsitrf.c index fdac3ce6..077d2d59 100644 --- a/SRC/dgsitrf.c +++ b/SRC/dgsitrf.c @@ -236,7 +236,7 @@ dgsitrf(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 */ @@ -325,10 +325,12 @@ dgsitrf(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", i); +#else + (void)relaxed_supernodes; // to suppress unused variable warning #endif /* @@ -353,9 +355,8 @@ dgsitrf(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) @@ -366,7 +367,7 @@ dgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, fill_tol = pow(fill_ini, 1.0 - 0.5 * (first + last) / min_mn); /* Drop small rows */ - i = ilu_ddrop_row(options, first, last, tol_L, quota, &nnzLj, + drop_row = ilu_ddrop_row(options, first, last, tol_L, quota, &nnzLj, &fill_tol, Glu, tempv, dwork2, 0); /* Reset the parameters */ if (drop_rule & DROP_DYNAMIC) { @@ -378,7 +379,9 @@ dgsitrf(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 } @@ -482,7 +485,6 @@ dgsitrf(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; @@ -501,11 +503,14 @@ dgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, ((double *) 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); @@ -575,9 +580,8 @@ dgsitrf(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) @@ -589,7 +593,7 @@ dgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, (double)min_mn); /* Drop small rows */ - i = ilu_ddrop_row(options, first, last, tol_L, quota, + drop_row = ilu_ddrop_row(options, first, last, tol_L, quota, &nnzLj, &fill_tol, Glu, tempv, dwork2, 1); @@ -603,7 +607,7 @@ dgsitrf(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 */ @@ -619,7 +623,7 @@ dgsitrf(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; diff --git a/SRC/heap_relax_snode.c b/SRC/heap_relax_snode.c index 7ce4f6c2..c4f273e8 100644 --- a/SRC/heap_relax_snode.c +++ b/SRC/heap_relax_snode.c @@ -123,7 +123,8 @@ heap_relax_snode ( } j++; /* Search for a new leaf */ - while ( descendants[j] != 0 && j < n ) j++; + while (j < n && descendants[j] != 0) + j++; } #if ( PRNTlevel>=1 ) diff --git a/SRC/ilu_cdrop_row.c b/SRC/ilu_cdrop_row.c index 68feb64c..125cac1e 100644 --- a/SRC/ilu_cdrop_row.c +++ b/SRC/ilu_cdrop_row.c @@ -71,7 +71,7 @@ int ilu_cdrop_row( * if lastc == 1, there is one more column after * the working supernode. */ ) { - register int i, j, k, m1; + register int i, k, m1; register int nzlc; /* number of nonzeros in column last+1 */ int_t xlusup_first, xlsub_first; int m, n; /* m x n is the size of the supernode */ @@ -144,7 +144,7 @@ int ilu_cdrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m].r += c_abs1(&lusup[xlusup_first + i + j * m]); break; @@ -160,7 +160,7 @@ int ilu_cdrop_row( cswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m].r = c_abs1(&lusup[xlusup_first + m1 + j * m]); lusup[xlusup_first + m1 + j * m].i = 0.0; @@ -211,7 +211,6 @@ int ilu_cdrop_row( { if (temp[i] <= tol) { - register int j; r++; /* drop the current row and move the last undropped row here */ if (r > 1) /* add to last row */ @@ -225,7 +224,7 @@ int ilu_cdrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m].r += c_abs1(&lusup[xlusup_first + i + j * m]); break; @@ -241,7 +240,7 @@ int ilu_cdrop_row( cswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m].r = c_abs1(&lusup[xlusup_first + m1 + j * m]); lusup[xlusup_first + m1 + j * m].i = 0.0; @@ -270,10 +269,9 @@ int ilu_cdrop_row( /* add dropped entries to the diagonal */ if (milu != SILU) { - register int j; singlecomplex t; float omega; - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) { t = lusup[xlusup_first + (m - 1) + j * m]; if (t.r == 0.0 && t.i == 0.0) continue; @@ -323,7 +321,7 @@ int ilu_cdrop_row( /* Remove dropped entries from the memory and fix the pointers. */ m1 = m - r; - for (j = 1; j < n; j++) + for (int j = 1; j < n; j++) { register int tmp1, tmp2; tmp1 = xlusup_first + j * m1; diff --git a/SRC/ilu_ddrop_row.c b/SRC/ilu_ddrop_row.c index 74f665a8..41e9db51 100644 --- a/SRC/ilu_ddrop_row.c +++ b/SRC/ilu_ddrop_row.c @@ -70,7 +70,7 @@ int ilu_ddrop_row( * if lastc == 1, there is one more column after * the working supernode. */ ) { - register int i, j, k, m1; + register int i, k, m1; register int nzlc; /* number of nonzeros in column last+1 */ int_t xlusup_first, xlsub_first; int m, n; /* m x n is the size of the supernode */ @@ -144,7 +144,7 @@ int ilu_ddrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m] += fabs(lusup[xlusup_first + i + j * m]); break; @@ -160,7 +160,7 @@ int ilu_ddrop_row( dswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m] = fabs(lusup[xlusup_first + m1 + j * m]); } @@ -210,7 +210,6 @@ int ilu_ddrop_row( { if (temp[i] <= tol) { - register int j; r++; /* drop the current row and move the last undropped row here */ if (r > 1) /* add to last row */ @@ -224,7 +223,7 @@ int ilu_ddrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m] += fabs(lusup[xlusup_first + i + j * m]); break; @@ -240,7 +239,7 @@ int ilu_ddrop_row( dswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m] = fabs(lusup[xlusup_first + m1 + j * m]); } @@ -268,10 +267,9 @@ int ilu_ddrop_row( /* add dropped entries to the diagonal */ if (milu != SILU) { - register int j; double t; double omega; - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) { t = lusup[xlusup_first + (m - 1) + j * m]; if (t == zero) continue; @@ -313,7 +311,7 @@ int ilu_ddrop_row( /* Remove dropped entries from the memory and fix the pointers. */ m1 = m - r; - for (j = 1; j < n; j++) + for (int j = 1; j < n; j++) { register int tmp1, tmp2; tmp1 = xlusup_first + j * m1; diff --git a/SRC/ilu_heap_relax_snode.c b/SRC/ilu_heap_relax_snode.c index fce350c1..319716c3 100644 --- a/SRC/ilu_heap_relax_snode.c +++ b/SRC/ilu_heap_relax_snode.c @@ -120,7 +120,8 @@ ilu_heap_relax_snode ( } j++; /* Search for a new leaf */ - while ( descendants[j] != 0 && j < n ) j++; + while (j < n && descendants[j] != 0) + j++; } #if ( PRNTlevel>=1 ) diff --git a/SRC/ilu_relax_snode.c b/SRC/ilu_relax_snode.c index 595aa802..28883d63 100644 --- a/SRC/ilu_relax_snode.c +++ b/SRC/ilu_relax_snode.c @@ -75,6 +75,7 @@ ilu_relax_snode ( j++; relax_fsupc[f++] = snode_start; /* Search for a new leaf */ - while ( descendants[j] != 0 && j < n ) j++; + while (j < n && descendants[j] != 0) + j++; } } diff --git a/SRC/ilu_sdrop_row.c b/SRC/ilu_sdrop_row.c index f4acd501..749cb00a 100644 --- a/SRC/ilu_sdrop_row.c +++ b/SRC/ilu_sdrop_row.c @@ -70,7 +70,7 @@ int ilu_sdrop_row( * if lastc == 1, there is one more column after * the working supernode. */ ) { - register int i, j, k, m1; + register int i, k, m1; register int nzlc; /* number of nonzeros in column last+1 */ int_t xlusup_first, xlsub_first; int m, n; /* m x n is the size of the supernode */ @@ -144,7 +144,7 @@ int ilu_sdrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m] += fabs(lusup[xlusup_first + i + j * m]); break; @@ -160,7 +160,7 @@ int ilu_sdrop_row( sswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m] = fabs(lusup[xlusup_first + m1 + j * m]); } @@ -210,7 +210,6 @@ int ilu_sdrop_row( { if (temp[i] <= tol) { - register int j; r++; /* drop the current row and move the last undropped row here */ if (r > 1) /* add to last row */ @@ -224,7 +223,7 @@ int ilu_sdrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m] += fabs(lusup[xlusup_first + i + j * m]); break; @@ -240,7 +239,7 @@ int ilu_sdrop_row( sswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m] = fabs(lusup[xlusup_first + m1 + j * m]); } @@ -268,10 +267,9 @@ int ilu_sdrop_row( /* add dropped entries to the diagonal */ if (milu != SILU) { - register int j; float t; float omega; - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) { t = lusup[xlusup_first + (m - 1) + j * m]; if (t == zero) continue; @@ -313,7 +311,7 @@ int ilu_sdrop_row( /* Remove dropped entries from the memory and fix the pointers. */ m1 = m - r; - for (j = 1; j < n; j++) + for (int j = 1; j < n; j++) { register int tmp1, tmp2; tmp1 = xlusup_first + j * m1; diff --git a/SRC/ilu_zdrop_row.c b/SRC/ilu_zdrop_row.c index edc12f5c..cdf08258 100644 --- a/SRC/ilu_zdrop_row.c +++ b/SRC/ilu_zdrop_row.c @@ -71,7 +71,7 @@ int ilu_zdrop_row( * if lastc == 1, there is one more column after * the working supernode. */ ) { - register int i, j, k, m1; + register int i, k, m1; register int nzlc; /* number of nonzeros in column last+1 */ int_t xlusup_first, xlsub_first; int m, n; /* m x n is the size of the supernode */ @@ -144,7 +144,7 @@ int ilu_zdrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m].r += z_abs1(&lusup[xlusup_first + i + j * m]); break; @@ -160,7 +160,7 @@ int ilu_zdrop_row( zswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m].r = z_abs1(&lusup[xlusup_first + m1 + j * m]); lusup[xlusup_first + m1 + j * m].i = 0.0; @@ -211,7 +211,6 @@ int ilu_zdrop_row( { if (temp[i] <= tol) { - register int j; r++; /* drop the current row and move the last undropped row here */ if (r > 1) /* add to last row */ @@ -225,7 +224,7 @@ int ilu_zdrop_row( &lusup[xlusup_first + m - 1], &m); break; case SMILU_3: - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) lusup[xlusup_first + (m - 1) + j * m].r += z_abs1(&lusup[xlusup_first + i + j * m]); break; @@ -241,7 +240,7 @@ int ilu_zdrop_row( zswap_(&n, &lusup[xlusup_first + m1], &m, &lusup[xlusup_first + i], &m); if (milu == SMILU_3) - for (j = 0; j < n; j++) { + for (int j = 0; j < n; j++) { lusup[xlusup_first + m1 + j * m].r = z_abs1(&lusup[xlusup_first + m1 + j * m]); lusup[xlusup_first + m1 + j * m].i = 0.0; @@ -270,10 +269,9 @@ int ilu_zdrop_row( /* add dropped entries to the diagonal */ if (milu != SILU) { - register int j; doublecomplex t; double omega; - for (j = 0; j < n; j++) + for (int j = 0; j < n; j++) { t = lusup[xlusup_first + (m - 1) + j * m]; if (t.r == 0.0 && t.i == 0.0) continue; @@ -323,7 +321,7 @@ int ilu_zdrop_row( /* Remove dropped entries from the memory and fix the pointers. */ m1 = m - r; - for (j = 1; j < n; j++) + for (int j = 1; j < n; j++) { register int tmp1, tmp2; tmp1 = xlusup_first + j * m1; diff --git a/SRC/qselect.c b/SRC/qselect.c index 1525d5a7..254ad590 100644 --- a/SRC/qselect.c +++ b/SRC/qselect.c @@ -34,9 +34,9 @@ double dqselect(int n, double A[], int k) p = j; val = A[p]; while (i < j) { - for (; A[i] >= val && i < p; i++); + for (; i < p && A[i] >= val; i++); if (A[i] < val) { A[p] = A[i]; p = i; } - for (; A[j] <= val && j > p; j--); + for (; j > p && A[j] <= val; j--); if (A[j] > val) { A[p] = A[j]; p = j; } } A[p] = val; @@ -65,9 +65,9 @@ float sqselect(int n, float A[], int k) p = j; val = A[p]; while (i < j) { - for (; A[i] >= val && i < p; i++); + for (; i < p && A[i] >= val; i++); if (A[i] < val) { A[p] = A[i]; p = i; } - for (; A[j] <= val && j > p; j--); + for (; j > p && A[j] <= val; j--); if (A[j] > val) { A[p] = A[j]; p = j; } } A[p] = val; diff --git a/SRC/relax_snode.c b/SRC/relax_snode.c index 1301989e..9f1e7133 100644 --- a/SRC/relax_snode.c +++ b/SRC/relax_snode.c @@ -78,7 +78,8 @@ relax_snode ( relax_end[snode_start] = j; /* Last column is recorded */ j++; /* Search for a new leaf */ - while ( descendants[j] != 0 && j < n ) j++; + while (j < n && descendants[j] != 0) + j++; } /*printf("No of relaxed snodes: %d; relaxed columns: %d\n", diff --git a/SRC/sgsisx.c b/SRC/sgsisx.c index 421fcad0..0a3dfd07 100644 --- a/SRC/sgsisx.c +++ b/SRC/sgsisx.c @@ -417,7 +417,6 @@ sgsisx(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 */ @@ -472,7 +471,7 @@ sgsisx(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]); } @@ -484,7 +483,7 @@ sgsisx(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]); } @@ -538,7 +537,6 @@ sgsisx(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; @@ -559,13 +557,13 @@ sgsisx(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]; } } @@ -573,8 +571,8 @@ sgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, } /* 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]]; } @@ -637,14 +635,14 @@ sgsisx(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); @@ -677,20 +675,20 @@ sgsisx(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_(); @@ -701,15 +699,15 @@ sgsisx(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]; } } diff --git a/SRC/sgsitrf.c b/SRC/sgsitrf.c index f2b7c867..44d4bf2c 100644 --- a/SRC/sgsitrf.c +++ b/SRC/sgsitrf.c @@ -236,7 +236,7 @@ sgsitrf(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 */ @@ -325,10 +325,12 @@ sgsitrf(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 /* @@ -353,9 +355,8 @@ sgsitrf(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) @@ -366,7 +367,7 @@ sgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, fill_tol = pow(fill_ini, 1.0 - 0.5 * (first + last) / min_mn); /* Drop small rows */ - i = ilu_sdrop_row(options, first, last, tol_L, quota, &nnzLj, + drop_row = ilu_sdrop_row(options, first, last, tol_L, quota, &nnzLj, &fill_tol, Glu, tempv, swork2, 0); /* Reset the parameters */ if (drop_rule & DROP_DYNAMIC) { @@ -378,7 +379,9 @@ sgsitrf(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 } @@ -482,7 +485,6 @@ sgsitrf(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; @@ -501,11 +503,14 @@ sgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, ((float *) 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); @@ -575,9 +580,8 @@ sgsitrf(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) @@ -589,7 +593,7 @@ sgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, (double)min_mn); /* Drop small rows */ - i = ilu_sdrop_row(options, first, last, tol_L, quota, + drop_row = ilu_sdrop_row(options, first, last, tol_L, quota, &nnzLj, &fill_tol, Glu, tempv, swork2, 1); @@ -603,7 +607,7 @@ sgsitrf(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 */ @@ -619,7 +623,7 @@ sgsitrf(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; diff --git a/SRC/zgsisx.c b/SRC/zgsisx.c index e8a33f71..e7da141f 100644 --- a/SRC/zgsisx.c +++ b/SRC/zgsisx.c @@ -417,7 +417,6 @@ zgsisx(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 */ @@ -472,7 +471,7 @@ zgsisx(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]); } @@ -484,7 +483,7 @@ zgsisx(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]); } @@ -538,7 +537,6 @@ zgsisx(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; @@ -559,13 +557,13 @@ zgsisx(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++) { zd_mult(&nzval[i], &nzval[i], R[rowind[i]] * C[j]); } } @@ -573,8 +571,8 @@ zgsisx(superlu_options_t *options, SuperMatrix *A, int *perm_c, int *perm_r, } /* 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]]; } @@ -637,14 +635,14 @@ zgsisx(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); @@ -677,20 +675,20 @@ zgsisx(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) zd_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) { zd_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_(); @@ -701,15 +699,15 @@ zgsisx(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) { zd_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) { zd_mult(&Xmat[i+j*ldx], &Xmat[i+j*ldx], R[i]); } } diff --git a/SRC/zgsitrf.c b/SRC/zgsitrf.c index 2f28d8e2..d2faa849 100644 --- a/SRC/zgsitrf.c +++ b/SRC/zgsitrf.c @@ -237,7 +237,7 @@ zgsitrf(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 */ @@ -326,10 +326,12 @@ zgsitrf(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 /* @@ -354,9 +356,8 @@ zgsitrf(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) @@ -368,7 +369,7 @@ zgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, /* Drop small rows */ dtempv = (double *) tempv; - i = ilu_zdrop_row(options, first, last, tol_L, quota, &nnzLj, + drop_row = ilu_zdrop_row(options, first, last, tol_L, quota, &nnzLj, &fill_tol, Glu, dtempv, dwork2, 0); /* Reset the parameters */ if (drop_rule & DROP_DYNAMIC) { @@ -380,7 +381,9 @@ zgsitrf(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 } @@ -484,7 +487,6 @@ zgsitrf(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; @@ -503,11 +505,14 @@ zgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, ((doublecomplex *) 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); @@ -572,9 +577,8 @@ zgsitrf(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) @@ -587,7 +591,7 @@ zgsitrf(superlu_options_t *options, SuperMatrix *A, int relax, int panel_size, /* Drop small rows */ dtempv = (double *) tempv; - i = ilu_zdrop_row(options, first, last, tol_L, quota, + drop_row = ilu_zdrop_row(options, first, last, tol_L, quota, &nnzLj, &fill_tol, Glu, dtempv, dwork2, 1); @@ -601,7 +605,7 @@ zgsitrf(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 */ @@ -617,7 +621,7 @@ zgsitrf(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; diff --git a/TESTING/MATGEN/clarnd.c b/TESTING/MATGEN/clarnd.c index e1328665..9d29a907 100644 --- a/TESTING/MATGEN/clarnd.c +++ b/TESTING/MATGEN/clarnd.c @@ -112,7 +112,7 @@ else { int argument = 0; input_error("clarnd", &argument); - ret_val = 0; + ret_val->r = 0.f, ret_val->i = 0.f; } /* End of CLARND */ diff --git a/TESTING/MATGEN/zlarnd.c b/TESTING/MATGEN/zlarnd.c index 725ff3e2..d6c168ff 100644 --- a/TESTING/MATGEN/zlarnd.c +++ b/TESTING/MATGEN/zlarnd.c @@ -113,7 +113,7 @@ else { int argument = 0; input_error("zlarnd", &argument); - ret_val = 0; + ret_val->r = 0., ret_val->i = 0.; } /* End of ZLARND */