Hello everyone,
Does anyone here know how one can write a complex or real, matrix or vector
(matrix could be sparse or full) in MATLAB to a binary file such that it can
be read correctly by PETSc?
I tried using PetscBinaryWrite.m that came with PETSc ( /bin/matlab) to write
a simple real (or complex), full (or sparse) matrix in binary file named
'matrix.dat' and tried reading it in PETSc, but it absolutely does not work :(
I did PetscBinaryWrite('matrix.dat', C) to write a matrix C in an empty file
named 'matrix.dat' in MATLAB. Then I tried reading 'matrix.dat' file in PETSc
using the following command :
PetscViewer binviewer ;
Mat C ;
char fileC[PETSC_MAX_PATH_LEN] ;
ierr = PetscOptionsGetString(PETSC_NULL, "-fC", fileC, PETSC_MAX_PATH_LEN-1,
PETSC_NULL) ; CHKERRQ(ierr) ;
ierr = PetscViewerBinaryOpen(PETSC_COMM_WORLD, fileC, FILE_MODE_READ,
&binviewer) ; CHKERRQ(ierr) ;
ierr = MatLoad(binviewer, MATMPIAIJ, &C) ; CHKERRQ(ierr) ;
I must add that I compiled PETSc with complex numbers.
I plan on assembling my matrix (very large square sparse matrix, size greater
than 1e+8) in MATLAB, which does not take too long to assemble in MATLAB at
all. Then I will write the matrix to a binary file and read that in PETSc and
solve a very large linear system of equations in parallel in PETSc using MPI.
Hence, I really need to be able to write the matrix in MATLAB to a binary file
such that PETSc can correctly read the matrix.
I am really surprised to find out that PETSc cannot read/write a matrix or
vector, full or sparse, real or complex in MATRIX MARKET FORMAT. I have gone
though the manual, googled around quite a bit, but I just have not found
anything useful.
I will truly appreciate any help or a pointer in this regard.
Thank you.
Amrit
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110905/3aa0f1e9/attachment.htm>