From b90b5a29bbc806bf4e569e485949599a2a51e71a Mon Sep 17 00:00:00 2001 From: Mathieu Faverge <mathieu.faverge@inria.fr> Date: Fri, 11 Nov 2016 13:30:09 +0100 Subject: [PATCH] Cleaned up the spm_2dense --- z_spm_2dense.c | 91 +++++++++++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/z_spm_2dense.c b/z_spm_2dense.c index 479951a7..16bc3374 100644 --- a/z_spm_2dense.c +++ b/z_spm_2dense.c @@ -104,14 +104,14 @@ z_spmCSC2dense( const pastix_spm_t *spm ) case PastixHermitian: for(j=0; j<spm->n; j++, colptr++) { - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j]; for(k=colptr[0]; k<colptr[1]; k++, rowptr++) { i = (*rowptr - baseval); - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i]; for(jj=0; jj<dofj; jj++) { @@ -128,14 +128,14 @@ z_spmCSC2dense( const pastix_spm_t *spm ) case PastixSymmetric: for(j=0; j<spm->n; j++, colptr++) { - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j]; for(k=colptr[0]; k<colptr[1]; k++, rowptr++) { i = (*rowptr - baseval); - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i]; for(jj=0; jj<dofj; jj++) { @@ -152,14 +152,14 @@ z_spmCSC2dense( const pastix_spm_t *spm ) default: for(j=0; j<spm->n; j++, colptr++) { - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j]; for(k=colptr[0]; k<colptr[1]; k++, rowptr++) { i = (*rowptr - baseval); - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i]; for(jj=0; jj<dofj; jj++) { @@ -255,14 +255,14 @@ z_spmCSR2dense( const pastix_spm_t *spm ) case PastixHermitian: for(i=0; i<spm->n; i++, rowptr++) { - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; + dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; + row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i]; for(k=rowptr[0]; k<rowptr[1]; k++, colptr++) { j = (*colptr - baseval); - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; + col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j]; for(jj=0; jj<dofj; jj++) { @@ -280,13 +280,13 @@ z_spmCSR2dense( const pastix_spm_t *spm ) for(i=0; i<spm->n; i++, rowptr++) { dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; + row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i]; for(k=rowptr[0]; k<rowptr[1]; k++, colptr++) { j = (*colptr - baseval); dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j]; for(jj=0; jj<dofj; jj++) { @@ -304,13 +304,13 @@ z_spmCSR2dense( const pastix_spm_t *spm ) for(i=0; i<spm->n; i++, rowptr++) { dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; + row = ( spm->dof > 1 ) ? (spm->dof * i) : dofs[i]; for(k=rowptr[0]; k<rowptr[1]; k++, colptr++) { j = (*colptr - baseval); dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + col = ( spm->dof > 1 ) ? (spm->dof * j) : dofs[j]; for(jj=0; jj<dofj; jj++) { @@ -406,11 +406,18 @@ z_spmIJV2dense( const pastix_spm_t *spm ) i = *rowptr - baseval; j = *colptr - baseval; - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; - - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + if ( spm->dof > 1 ) { + dofi = spm->dof; + row = spm->dof * i; + dofj = spm->dof; + col = spm->dof * j; + } + else { + dofi = dofs[i+1] - dofs[i]; + row = dofs[i]; + dofj = dofs[j+1] - dofs[j]; + col = dofs[j]; + } for(jj=0; jj<dofj; jj++) { @@ -435,11 +442,18 @@ z_spmIJV2dense( const pastix_spm_t *spm ) i = *rowptr - baseval; j = *colptr - baseval; - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; - - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + if ( spm->dof > 1 ) { + dofi = spm->dof; + row = spm->dof * i; + dofj = spm->dof; + col = spm->dof * j; + } + else { + dofi = dofs[i+1] - dofs[i]; + row = dofs[i]; + dofj = dofs[j+1] - dofs[j]; + col = dofs[j]; + } for(jj=0; jj<dofj; jj++) { @@ -459,11 +473,18 @@ z_spmIJV2dense( const pastix_spm_t *spm ) i = *rowptr - baseval; j = *colptr - baseval; - dofi = ( spm->dof > 1 ) ? spm->dof : dofs[i+1] - dofs[i]; - row = dofs[i]; - - dofj = ( spm->dof > 1 ) ? spm->dof : dofs[j+1] - dofs[j]; - col = dofs[j]; + if ( spm->dof > 1 ) { + dofi = spm->dof; + row = spm->dof * i; + dofj = spm->dof; + col = spm->dof * j; + } + else { + dofi = dofs[i+1] - dofs[i]; + row = dofs[i]; + dofj = dofs[j+1] - dofs[j]; + col = dofs[j]; + } for(jj=0; jj<dofj; jj++) { -- GitLab