[petsc-users] Precision of MatView

Sanjay Govindjee s_g at berkeley.edu
Wed May 15 10:44:37 CDT 2019


The issue is not with trailing zeros. The last ~7 digits are incorrect (in comparison to a write(*,*) from my serial code). I’m going to track down the issue today and will report back — I’m guessing the problem is somewhere in my code. 

Sent from my iPhone

> On May 15, 2019, at 7:25 AM, Mark Adams <mfadams at lbl.gov> wrote:
> 
> This thread suggests that I was at least not wrong in assuming that trailing 0s should be printed by printf (although I did not trace the code down to printf)
> 
> https://stackoverflow.com/questions/277772/avoid-trailing-zeroes-in-printf
> 
> Maybe Sanjay's machines printf cuts off trailing 0s.
> 
>> On Wed, May 15, 2019 at 10:06 AM Smith, Barry F. <bsmith at mcs.anl.gov> wrote:
>> 
>>    The 10-20% in seven digits are presumably printed accurately; it is presumably simply the case that the rest of the digits would be zero and hence are not printed. 
>> 
>> > On May 15, 2019, at 8:59 AM, Mark Adams via petsc-users <petsc-users at mcs.anl.gov> wrote:
>> > 
>> > 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/db1f42f5/attachment-0001.html>


More information about the petsc-users mailing list