Error: Write out matrix

Issue #38 invalid
zheng li created an issue

Hi, I try to output the petsc matrix to a matrix that matlab can recongize. I read the demo matvecio.py, and changed the default output matrix format to BINARY_MATLAB or ASCII_MATLAB but failed. My part code is

viewer = PETSc.Viewer().createBinary('matrix-A.dat', 'r')

B = PETSc.Mat().load(viewer)

viewer = PETSc.Viewer().createBinary('A.dat', 'w', 'BINARY_MATLAB')

viewer(B)

and error is

Traceback (most recent call last): File "matvecio.py", line 44, in <module> viewer = PETSc.Viewer().createBinary('A.dat', 'w', 'BINARY_MATLAB') File "PETSc/Viewer.pyx", line 135, in petsc4py.PETSc.Viewer.createBinary (src/petsc4py.PETSc.c:67020) TypeError: an integer is required

I have no idea about it. Does it not recognize the input format ?

Comments (3)

  1. Lisandro Dalcin

    You should use PETSc.Viewer().createBinary('A.dat', 'w', PETSc.Viewer.Format.BINARY_MATLAB), however, I think PETSc does not actually supports the binary MATLAB format for vector and matrices.

  2. Log in to comment