JuliaIO / MAT.jl

Julia module for reading MATLAB files
MIT License
279 stars 71 forks source link

Cannot write complex matrices #6

Closed ViralBShah closed 11 years ago

ViralBShah commented 11 years ago

Would it be possible to save complex matrices as well?

julia> y = complex(rand(5,5),rand(5,5))
5x5 Complex128 Array:
    0.647783+0.85824im  0.00916134+0.951223im  0.282909+0.0147227im   0.0586552+0.26651im  0.880246+0.789439im
  0.0642369+0.587805im    0.928508+0.337794im   0.910828+0.602694im   0.866889+0.451158im  0.876455+0.965597im
   0.288223+0.253479im    0.924115+0.837454im  0.0783773+0.900726im    0.59707+0.684809im  0.216177+0.352811im
 0.999205+0.00247775im    0.502037+0.681987im     0.48883+0.59233im  0.172648+0.0151089im  0.548206+0.786362im
    0.830459+0.88749im   0.979251+0.0932437im  0.345495+0.0189409im   0.998324+0.229752im  0.175204+0.531069im

julia> matwrite("/tmp/y.mat", { "y" => y })
This is the write function for CompositeKind, but the input doesn't fit
 in m_write at /home/viral/.julia/MAT/src/MAT_HDF5.jl:370
 in m_write at /home/viral/.julia/MAT/src/MAT_HDF5.jl:315
 in write at /home/viral/.julia/MAT/src/MAT_HDF5.jl:378
 in matwrite at /home/viral/.julia/MAT/src/MAT.jl:92
timholy commented 11 years ago

That doesn't sound like too much to ask for. Fixed in a60739591b4ce760804aa3b696d5c93ed7f20f35

simonster commented 11 years ago

I added a test for this, but it's failing because realtype is undefined. Either something on my system is out of date, or I think this needs to be moved from jld.jl to plain.jl in HDF5 (or copy/pasted to MAT_HDF5.jl).

timholy commented 11 years ago

On Thursday, January 10, 2013 08:08:01 PM Simon Kornblith wrote:

I added a test for this, but it's failing because realtype is undefined. Either something on my system is out of date, or I think this needs to be moved from jld.jl to plain.jl in HDF5 (or copy/pasted to MAT_HDF5.jl).

That's curious. Examine lines 472-474 of your repository: https://github.com/simonster/MAT.jl/blob/master/src/MAT_HDF5.jl I don't understand why you're seeing that.

--Tim

ViralBShah commented 11 years ago

Thanks.

simonster commented 11 years ago

I was confused. It's failing because the variables are ComplexPair{Int64}.

timholy commented 11 years ago

Ah. I don't have an implementation for anything but FloatingPoint right now. I can't remember why, but at the time it seemed to be a sensible shortcut.

Personally I would wait to worry about complex integers until someone asks---it seems very unlikely that anyone will care. And if they do, maybe they'll add it themselves and become a contributor.