get a variety of errors in my attempts to create empty sparse matrices,
including stack overflows in the SparseMatrixCSC constructor and errors in
the SparseMatrixCSC show function.  I'll email the Julia mailing list about
it.


On Mon, Jun 17, 2013 at 5:55 PM, Raphael Sofaer <rsofaer@gmail.com> wrote:

> That's also way less dumb performance wise.  I've changed it.
>
>
> On Mon, Jun 17, 2013 at 5:50 PM, Simon Kornblith <notifications@github.com
> > wrote:
>
>> In src/MAT_HDF5.jl:
>>
>> > @@ -187,7 +188,19 @@ end
>> >  function read(g::HDF5Group{
>> MatlabHDF5File})
>> >      mattype = a_read(g, name_type_attr_matlab)
>> >      if mattype != "struct"
>> > -        error("Cannot read from a non-struct group")
>> > +        # Check if this is a sparse matrix.
>> > +        fn = names(g)
>> > +        if fn == ["data", "ir", "jc"] && contains(names(attrs(g)), sparse_attr_matlab)
>> > +            # Let's say this is a sparse matrix.
>> > +            # ir is the row indices, jc is the column boundaries.
>> > +            # We add one to account for the zero-based (MATLAB) to one-based (Julia) transition
>> > +            ir = read(plain(g["ir"]),HDF5.hdf5_to_julia(g["ir"])) + 1
>> > +            jc = read(plain(g["jc"]),HDF5.hdf5_to_julia(g["jc"])) + 1
>> > +            data = read(plain(g["data"]),HDF5.hdf5_to_julia(g["data"]))
>> > +            return SparseMatrixCSC(max(ir), length(jc) -1, jc, ir, data)
>>
>> I don't think max(ir) will work if there are rows that are entirely made
>> up of zeros. It looks like the size of the first dimension is stored in the
>> MATLAB_sparse attribute.
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/simonster/MAT.jl/pull/14/files#r4736047>
>> .
>>
>
>