diff --git a/z_spm_norm.c b/z_spm_norm.c index 422ace0b4cb31e7eeb46a987f731ebdb3f340622..be0ed77f32a85b67c49486cfb7824f2baac7deba 100644 --- a/z_spm_norm.c +++ b/z_spm_norm.c @@ -174,10 +174,10 @@ z_spmInfNorm( const pastix_spm_t *spm ) pastix_int_t col, row, i, baseval; pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values; double norm = 0.; - double *sumcol; + double *sumrow; - MALLOC_INTERN( sumcol, spm->gN, double ); - memset( sumcol, 0, spm->gN * sizeof(double) ); + MALLOC_INTERN( sumrow, spm->gN, double ); + memset( sumrow, 0, spm->gN * sizeof(double) ); baseval = spmFindBase( spm ); switch( spm->fmttype ){ @@ -186,7 +186,8 @@ z_spmInfNorm( const pastix_spm_t *spm ) { for( i=spm->colptr[col]-baseval; i<spm->colptr[col+1]-baseval; i++ ) { - sumcol[spm->rowptr[i]-baseval] += cabs( valptr[i] ); + row = spm->rowptr[i] - baseval; + sumrow[row] += cabs( valptr[i] ); } } @@ -198,7 +199,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) { for( i=spm->colptr[col]-baseval+1; i<spm->colptr[col+1]-baseval; i++ ) { - sumcol[col] += cabs( valptr[i] ); + sumrow[col] += cabs( valptr[i] ); } } } @@ -209,7 +210,7 @@ z_spmInfNorm( const pastix_spm_t *spm ) { for( i=spm->rowptr[row]-baseval; i<spm->rowptr[row+1]-baseval; i++ ) { - sumcol[spm->colptr[i]-baseval] += cabs( valptr[i] ); + sumrow[row] += cabs( valptr[i] ); } } @@ -221,7 +222,8 @@ z_spmInfNorm( const pastix_spm_t *spm ) { for( i=spm->rowptr[row]-baseval+1; i<spm->rowptr[row+1]-baseval; i++ ) { - sumcol[row] += cabs( valptr[i] ); + col = spm->colptr[i] - baseval; + sumrow[col] += cabs( valptr[i] ); } } } @@ -230,7 +232,8 @@ z_spmInfNorm( const pastix_spm_t *spm ) case PastixIJV: for(i=0; i < spm->nnz; i++) { - sumcol[spm->colptr[i]-baseval] += cabs( valptr[i] ); + row = spm->rowptr[i]-baseval; + sumrow[row] += cabs( valptr[i] ); } /* Add the symmetric/hermitian part */ @@ -239,25 +242,28 @@ z_spmInfNorm( const pastix_spm_t *spm ) { for(i=0; i < spm->nnz; i++) { - if(spm->rowptr[i] != spm->colptr[i]) - sumcol[spm->rowptr[i]-baseval] += cabs( valptr[i] ); + row = spm->rowptr[i]-baseval; + col = spm->colptr[i]-baseval; + if( row != col ) { + sumrow[col] += cabs( valptr[i] ); + } } } break; default: - memFree_null( sumcol ); + memFree_null( sumrow ); return PASTIX_ERR_BADPARAMETER; } for( i=0; i<spm->gN; i++) { - if(norm < sumcol[i]) + if(norm < sumrow[i]) { - norm = sumcol[i]; + norm = sumrow[i]; } } - memFree_null( sumcol ); + memFree_null( sumrow ); return norm; } @@ -289,10 +295,10 @@ z_spmOneNorm( const pastix_spm_t *spm ) pastix_int_t col, row, i, baseval; pastix_complex64_t *valptr = (pastix_complex64_t*)spm->values; double norm = 0.; - double *sumrow; + double *sumcol; - MALLOC_INTERN( sumrow, spm->gN, double ); - memset( sumrow, 0, spm->gN * sizeof(double) ); + MALLOC_INTERN( sumcol, spm->gN, double ); + memset( sumcol, 0, spm->gN * sizeof(double) ); baseval = spmFindBase( spm ); switch( spm->fmttype ){ @@ -301,7 +307,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) { for( i=spm->colptr[col]-baseval; i<spm->colptr[col+1]-baseval; i++ ) { - sumrow[col] += cabs( valptr[i] ); + sumcol[col] += cabs( valptr[i] ); } } @@ -313,7 +319,8 @@ z_spmOneNorm( const pastix_spm_t *spm ) { for( i=spm->colptr[col]-baseval+1; i<spm->colptr[col+1]-baseval; i++ ) { - sumrow[spm->rowptr[i]-baseval] += cabs( valptr[i] ); + row = spm->rowptr[i] - baseval; + sumcol[row] += cabs( valptr[i] ); } } } @@ -324,7 +331,8 @@ z_spmOneNorm( const pastix_spm_t *spm ) { for( i=spm->rowptr[row]-baseval; i<spm->rowptr[row+1]-baseval; i++ ) { - sumrow[row] += cabs( valptr[i] ); + col = spm->colptr[i] - baseval; + sumcol[col] += cabs( valptr[i] ); } } @@ -336,7 +344,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) { for( i=spm->rowptr[row]-baseval+1; i<spm->rowptr[row+1]-baseval; i++ ) { - sumrow[spm->colptr[i]-baseval] += cabs( valptr[i] ); + sumcol[row] += cabs( valptr[i] ); } } } @@ -345,7 +353,7 @@ z_spmOneNorm( const pastix_spm_t *spm ) case PastixIJV: for(i=0; i < spm->nnz; i++) { - sumrow[spm->rowptr[i]-baseval] += cabs( valptr[i] ); + sumcol[spm->colptr[i]-baseval] += cabs( valptr[i] ); } /* Add the symmetric/hermitian part */ @@ -355,24 +363,24 @@ z_spmOneNorm( const pastix_spm_t *spm ) for(i=0; i < spm->nnz; i++) { if(spm->rowptr[i] != spm->colptr[i]) - sumrow[spm->colptr[i]-baseval] += cabs( valptr[i] ); + sumcol[spm->rowptr[i]-baseval] += cabs( valptr[i] ); } } break; default: - memFree_null( sumrow ); + memFree_null( sumcol ); return PASTIX_ERR_BADPARAMETER; } for( i=0; i<spm->gN; i++) { - if(norm < sumrow[i]) + if(norm < sumcol[i]) { - norm = sumrow[i]; + norm = sumcol[i]; } } - memFree_null( sumrow ); + memFree_null( sumcol ); return norm; }