If you already have Matlab matrices that were saved with, for example,

save example.mat A

It may be possible to use MatLoad() directly on them using the PETSCVIEWERHDF5 
viewer type (and not need to use the PetscBinaryWrite()). Please read the full 
manual page https://petsc.org/release/docs/manualpages/Mat/MatLoad.html 
<https://petsc.org/release/docs/manualpages/Mat/MatLoad.html> for details and 
caveats.

 

> On Jul 29, 2022, at 12:00 PM, Jed Brown <[email protected]> wrote:
> 
> You can use share/petsc/matlab/PetscBinaryWrite.m.
> 
> matlab> PetscBinaryWrite('matrix.petsc', sparse(A))
> 
> Then load it with MatLoad in PETSc.
> 
> Ahmed Mansur <[email protected]> writes:
> 
>> How to import a sparse matrix from Matlab using C++ and PETSC , if anyone
>> has any example code, thanks

Reply via email to