[petsc-users] Controlling decimal points when PETSC matrices and vectors are outputted.

Barry Smith bsmith at mcs.anl.gov
Wed Oct 15 19:01:09 CDT 2014


  Evan,

   There is very little control. But if you are reading the vectors/matrices into MATLAB or Python you should use the binary format; it is much faster and always preserves all the precision.  Use PetscViewerBinaryOpen()  then in MATLAB use PetscBinaryRead.m to read them in (it is in bin/matlab in PETSc 3.4 and earlier and in share/petsc/matlab in PETSc 3.5)  to read into Python you can use bin/pythonscripts/petscBinaryIO.py

  Barry

On Oct 15, 2014, at 6:52 PM, Evan Um <evanum at gmail.com> wrote:

> Dear users,
> 
> Is there any way to control the precision (i.e. decimal points) of matrices and vectors when they are written into files? Otherwise, do I need to access elements of a matrix by myself and then write them with my own format? In advance, thanks for tour advice.
> 
> Regards,
> Evan
> 
> 
> PetscViewerASCIIOpen(PETSC_COMM_WORLD,"A.out",&viewer);
> PetscViewerSetFormat(viewer, PETSC_VIEWER_ASCII_MATLAB);
> MatView(A_dt,viewer);



More information about the petsc-users mailing list