diff --git a/z_spm_2dense.c b/z_spm_2dense.c index 03f06c3d21b8043a7b259a0bd1cfc7863883ebe8..ad9933ff579283a6c00978abc52c36163bac547a 100644 --- a/z_spm_2dense.c +++ b/z_spm_2dense.c @@ -117,8 +117,14 @@ z_spmCSC2dense( const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - A[ (col + jj) * lda + (row + ii) ] = *valptr; - A[ (row + ii) * lda + (col + jj) ] = conj(*valptr); + if( col+jj == row+ii ) { + /* Make sure the matrix is hermitian */ + A[ (col + jj) * lda + (row + ii) ] = creal(*valptr) + I * 0.; + } + else { + A[ (col + jj) * lda + (row + ii) ] = *valptr; + A[ (row + ii) * lda + (col + jj) ] = conj(*valptr); + } } } } @@ -268,8 +274,14 @@ z_spmCSR2dense( const pastix_spm_t *spm ) { for(ii=0; ii<dofi; ii++, valptr++) { - A[ (col + jj) * lda + (row + ii) ] = *valptr; - A[ (row + ii) * lda + (col + jj) ] = conj(*valptr); + if( col+jj == row+ii ) { + /* Make sure the matrix is hermitian */ + A[ (col + jj) * lda + (row + ii) ] = creal(*valptr) + I * 0.; + } + else { + A[ (col + jj) * lda + (row + ii) ] = *valptr; + A[ (row + ii) * lda + (col + jj) ] = conj(*valptr); + } } } } diff --git a/z_spm_convert_to_csc.c b/z_spm_convert_to_csc.c index bd76019cc490bee69ae093d8693344a48c6ab963..ed0db67d1273ad56123b12db08a20257bc8026f3 100644 --- a/z_spm_convert_to_csc.c +++ b/z_spm_convert_to_csc.c @@ -161,7 +161,9 @@ z_spmConvertCSR2CSC( pastix_spm_t *spm ) pastix_int_t i; for(i=0; i<spm->nnz; i++, valptr++){ - *valptr = conj( *valptr ); + if (spm->rowptr[i] != spm->colptr[i]) { + *valptr = conj( *valptr ); + } } } #endif diff --git a/z_spm_convert_to_csr.c b/z_spm_convert_to_csr.c index c1d0d4582f0d2edd50c74a231cb6a1419dbfcd50..026df2624bcb6aa91365d983a22d3ced06a3773a 100644 --- a/z_spm_convert_to_csr.c +++ b/z_spm_convert_to_csr.c @@ -53,7 +53,9 @@ z_spmConvertCSC2CSR( pastix_spm_t *spm ) pastix_int_t i; for(i=0; i<spm->nnz; i++, valptr++){ - *valptr = conj( *valptr ); + if (spm->rowptr[i] != spm->colptr[i]) { + *valptr = conj( *valptr ); + } } } #endif