cannot read/write sparse matrices to matlab v4
John W. Eaton
jwe at bevo.che.wisc.edu
Tue Jul 8 11:22:23 CDT 2008
On 8-Jul-2008, David Bateman wrote:
| Daniel Heiserer wrote:
| > Hi,
| >
| > the read and write of sparse matrices to v4 matlab does not work:
| >
| > octave:5> tic;load C4.mat;toc
| > error: load: can't read sparse matrices
| >
| >
| > When writing is tried, it seems octave will internally create a full matrix before writing it to the v4 file. This will explode once the matrix is too large:
| >
| >
| > N=1E7;C=sparse(ceil(N*rand(N,1)),ceil(N*rand(N,1)),rand(N,1),N,N);
| > save -v4 C4.mat C
| >
| >
| > octave version was:
| >
| > octave:5> version
| > ans = 3.0.0
| >
| >
| >
| Huh, I never even realized that matlab could save a sparse matrix to a
| v4 file format! The documentation has a flag for the sparse file format
| but then doesn't document how the nnz, cidx, ridx and data parts of the
| Sparse matrix are stored. So I presumed that as documented they were
| saved as full matrices in v4 format. Without knowledge of the v4 sparse
| format I'm not really sure how to implement this..
I don't remember whether the docs covering the v4 format completely
described the sparse matrix storage, but I'm sure that Octave did not
support sparse matrices when the MAT file code was first added to
Octave. In any case, I would consider a patch if someone would like
to implement this feature.
jwe
More information about the Bug-octave
mailing list