Amrit,

    We have just recently made sure that PetscBinaryWrite.m and 
PetscBinaryRead.m fully support complex numbers; you can access the release 
candidate for PETSc 3.2 for this support 

One can use the following tarball. It will correspond to
petsc-3.2 sources for the next few days. And i've set it up to be
updated every 3 hours [from the sources in mercurial].

http://ftp.mcs.anl.gov/pub/petsc/petsc-dev.tar.gz

or

> 
>   You can find the PETSc 3.2 release candidate via Mecurial at:
>> 
>> ssh://petsc at petsc.cs.iit.edu//hg/petsc/releases/petsc-3.2                 
>>        or    http://petsc.cs.iit.edu/petsc/releases/petsc-3.2
>> ssh://petsc at petsc.cs.iit.edu//hg/petsc/releases/BuildSystem-3.2           
>> or    http://petsc.cs.iit.edu/petsc/releases/BuildSystem-3.2

  Should you have problems reading the complex matrices/vectors saved from 
MATLAB please send all information to petsc-maint at mcs.anl.gov

  We do not support the Matrix Market sparse format because it is not scalable 
for large matrices (i.e. it is too slow) ; reading ASCII files in parallel is 
not viable.

 
  Barry

On Sep 4, 2011, at 9:05 PM, amrit poudel wrote:

> 
> 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 
> 

Reply via email to