[petsc-users] Precision of MatView

Mark Adams mfadams at lbl.gov
Wed May 15 08:59:43 CDT 2019


You are seeing half precision (like 7 digits) in 10-20% of the entries and
full in the rest.

Someone will probably chime in who knows about this but I can see where a
serial matrix is printed in ASCII Matlab in MatView_SeqAIJ_ASCII
in  src/mat/impls/aij/seq/aij.c.

I think this line is operative and is should clearly work:

        ierr = PetscViewerASCIIPrintf(viewer,"%D %D
%18.16e\n",i+1,a->j[j]+1,(double)a->a[j]);CHKERRQ(ierr);

Could you run in serial (this code could very well be used for MPI Mats
also) with Matlab/ASCII to verify that you have this problem. And you could
modify this print statement and remake PETSc, if that's easy, to verify
that this code is operative.

I think %18.16e should print 16 digits even if they are 0s ...


On Tue, May 14, 2019 at 8:34 PM Sanjay Govindjee <s_g at berkeley.edu> wrote:

> I'm seeing half precision on at least 10 to 20% of the entries :(
> Knowing I should see full precision, I will dig deeper.
>
> -sanjay
>
> On 5/14/19 5:22 PM, Mark Adams wrote:
>
> I would hope you get full precision. How many digits are you seeing?
>
> On Tue, May 14, 2019 at 7:15 PM Sanjay Govindjee via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
>> I am using the following bit of code to debug a matrix.  What is the
>> expected precision of the numbers that I will find in my ASCII file?
>> As far as I can tell it is not the full double precision that I was
>> expecting.
>>
>>              call PetscViewerASCIIOpen(PETSC_COMM_WORLD,
>> tangview,K_view, ierr)
>>              call PetscViewerSetFormat(K_view,
>> PETSC_VIEWER_ASCII_MATLAB, ierr)
>>              call MatView                     (Kmat, K_view, ierr)
>>
>> -sanjay
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190515/c16c7d6e/attachment.html>


More information about the petsc-users mailing list