[petsc-users] Required structure and attrs for MatLoad from hdf5

Smith, Barry F. bsmith at mcs.anl.gov
Tue Feb 4 19:56:34 CST 2020


  I think this is a Python-Matlab question, not specifically related to PETSc in any way. Googling python matrix hdf5 matlab there are mentions of h5py library that can be used to write out sparse matrices in Matlab HDF5 format. Which could presumably be read by PETSc. PETSc can also read in the non-transposed version which presumably can also be written out with h5py

  https://www.loc.gov/preservation/digital/formats/fdd/fdd000440.shtml gives some indication that an indication of whether the transpose is stored in the file might exist, if so and it is used by Matlab we wouldn't need the special matlab format flag.

   Barry


> On Feb 4, 2020, at 6:30 PM, Sajid Ali <sajidsyed2021 at u.northwestern.edu> wrote:
> 
> Hi PETSc-developers,
> 
> The example src/mat/examples/tutorials/ex10.c shows how one would read a matrix from a hdf5 file. Since MatView isn’t implemented for hdf5_mat format, how is the hdf5 file (to be used to run ex10) generated ?
> 
> I tried reading from an hdf5 file but I saw an error stating object 'jc' doesn't exist and thus would like to know how I should store a sparse matrix in an hdf5 file so that MatLoad works.
> 
> PS: I’m guessing that MATLAB stores the matrix in the format that PETSc expects (group/dset/attrs) but I’m creating this from Python. If the recommended approach is to transfer numpy arrays to PETSc matrices via petsc4py, I’d switch to that instead of directly creating hdf5 files.
> 
> Thank You,
> Sajid Ali | PhD Candidate
> Applied Physics
> Northwestern University
> s-sajid-ali.github.io
> 



More information about the petsc-users mailing list