diff --git a/z_spm_print.c b/z_spm_print.c index a51561c9295c828d3fe3fb0a731626261d2dd97b..5c4b3888334e8d7b0ccbce30572f57c84b671246 100644 --- a/z_spm_print.c +++ b/z_spm_print.c @@ -32,14 +32,21 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) pastix_complex64_t *valptr; pastix_int_t *colptr, *rowptr, *dofs; - assert( spm->fmttype == PastixCSC ); + assert( (spm->fmttype == PastixCSC) || (spm->fmttype == PastixCSR) ); assert( spm->flttype == PastixComplex64 ); baseval = spmFindBase( spm ); i = 0; j = 0; - colptr = spm->colptr; - rowptr = spm->rowptr; + if ( spm->fmttype == PastixCSC ) { + colptr = spm->colptr; + rowptr = spm->rowptr; + } + else { + colptr = spm->rowptr; + rowptr = spm->colptr; + } + valptr = (pastix_complex64_t*)(spm->values); dofs = spm->dofs; @@ -54,7 +61,7 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) for(k=colptr[0]; k<colptr[1]; k++, rowptr++) { i = (*rowptr - baseval); - dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; + dofi = ( spm->dof > 0 ) ? spm->dof : dofs[i+1] - dofs[i]; row = ( spm->dof > 0 ) ? spm->dof * i : dofs[i] - baseval; if ( spm->layout == PastixColMajor ) { @@ -62,12 +69,18 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } } @@ -76,12 +89,18 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) { for(jj=0; jj<dofj; jj++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } } @@ -106,12 +125,18 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, *valptr ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } } @@ -120,12 +145,18 @@ z_spmCSCPrint( FILE *f, const pastix_spm_t *spm ) { for(jj=0; jj<dofj; jj++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, *valptr ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } } @@ -207,12 +238,18 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - if (row+ii <= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii < col+jj) { - z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } } @@ -221,12 +258,18 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) { for(jj=0; jj<dofj; jj++, valptr++) { - if (row+ii <= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii < col+jj) { - z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } } @@ -251,12 +294,18 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - if (row+ii <= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii < col+jj) { - z_spmPrintElt( f, col + jj, row + ii, *valptr ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } } @@ -265,12 +314,18 @@ z_spmCSRPrint( FILE *f, const pastix_spm_t *spm ) { for(jj=0; jj<dofj; jj++, valptr++) { - if (row+ii <= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii < col+jj) { - z_spmPrintElt( f, col + jj, row + ii, *valptr ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } } @@ -359,12 +414,18 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } } @@ -373,12 +434,18 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) { for(jj=0; jj<dofj; jj++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, conj(*valptr) ); + } } } } @@ -409,12 +476,18 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, *valptr ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } } @@ -423,12 +496,18 @@ z_spmIJVPrint( FILE *f, const pastix_spm_t *spm ) { for(jj=0; jj<dofj; jj++, valptr++) { - if (row+ii >= col+jj) { - z_spmPrintElt( f, row + ii, col + jj, *valptr ); - if (row+ii > col+jj) { - z_spmPrintElt( f, col + jj, row + ii, *valptr ); + if ( row == col ) { + if (row+ii >= col+jj) { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + if (row+ii > col+jj) { + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } + else { + z_spmPrintElt( f, row + ii, col + jj, *valptr ); + z_spmPrintElt( f, col + jj, row + ii, *valptr ); + } } } }