JuliaIO / MAT.jl

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

Added support for compression #77

Closed fguevaravas closed 4 years ago

fguevaravas commented 6 years ago

MAT.jl already supports compression when reading mat files. This pull request implements compression in write mode, that Matlab/Octave supports (MATLAB v7.3 format). Here is a sample usage

# create a big matrix that compresses well
A = zeros(1000,1000); A[4,5] = 1; A[999,3]=1;

# uncompressed
f=matopen("toto.mat","w"); write(f,"A",A); close(f)

# compressed
f=matopen("totoz.mat","wz"); write(f,"A",A); close(f)

# compare
f=matopen("totoz.mat"); B=read(f,"A"); close(f)
norm(vec(A-B),Inf)

Enabling compression reduces size from 8MB to 5k in this (contrived) example.

Some other details:

nistath commented 5 years ago

I'd be really interested in this getting merged.

timholy commented 4 years ago

Incorporated in #123