Mercurial > hg > octave-terminal
changeset 10623:0e98fb2068fc
Fix error when saving sparse arrays to matlab files (bug #29786)
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 12 May 2010 02:17:18 +0200 |
parents | f35903fa42ed |
children | 3eafa521550b |
files | src/ChangeLog src/ls-mat5.cc |
diffstat | 2 files changed, 23 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-05-11 David Bateman <dbateman@free.fr> + + * ls-mat5.cc (save_mat5_element_length): Correct element length for + sparse elements with NZMAX=1 or NC=0. + (save_mat5_binary_element): Save the NZMAX elements of the RIDX + sparse index. + 2010-05-11 Jaroslav Hajek <highegg@gmail.com> * ov-lazy-idx.cc (octave_lazy_index::save_binary): Fix arguments to
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -1788,10 +1788,13 @@ { SparseComplexMatrix m = tc.sparse_complex_matrix_value (); octave_idx_type nc = m.cols (); - octave_idx_type nnz = m.nzmax (); + octave_idx_type nnz = m.nzmax (); // Yes its nzmax - ret += 16 + PAD (nnz * sizeof (int)) + PAD ((nc + 1) * sizeof (int)) + - save_mat5_array_length (m.data (), nnz, save_as_floats); + ret += 16 + save_mat5_array_length (m.data (), nnz, save_as_floats); + if (nnz > 1) + ret += PAD (nnz * sizeof (int32_t)); + if (nc > 1) + ret += PAD ((nc + 1) * sizeof (int32_t)); } else { @@ -1799,8 +1802,11 @@ octave_idx_type nc = m.cols (); octave_idx_type nnz = m.nzmax (); - ret += 16 + PAD (nnz * sizeof (int)) + PAD ((nc + 1) * sizeof (int)) + - save_mat5_array_length (m.data (), nnz, save_as_floats); + ret += 16 + save_mat5_array_length (m.data (), nnz, save_as_floats); + if (nnz > 1) + ret += PAD (nnz * sizeof (int32_t)); + if (nc > 1) + ret += PAD ((nc + 1) * sizeof (int32_t)); } } @@ -1896,7 +1902,7 @@ const octave_idx_type *idx, octave_idx_type nel) { - int tmp = sizeof (int); + int tmp = sizeof (int32_t); OCTAVE_LOCAL_BUFFER (int32_t, tmp_idx, nel); @@ -2132,9 +2138,10 @@ { SparseComplexMatrix m = tc.sparse_complex_matrix_value (); octave_idx_type nnz = m.nnz (); + octave_idx_type nzmax = m.nzmax (); octave_idx_type nc = m.cols (); - write_mat5_sparse_index_vector (os, m.ridx (), nnz); + write_mat5_sparse_index_vector (os, m.ridx (), nzmax); write_mat5_sparse_index_vector (os, m.cidx (), nc + 1); NDArray buf (dim_vector (nnz, 1)); @@ -2153,9 +2160,10 @@ { SparseMatrix m = tc.sparse_matrix_value (); octave_idx_type nnz = m.nnz (); + octave_idx_type nzmax = m.nzmax (); octave_idx_type nc = m.cols (); - write_mat5_sparse_index_vector (os, m.ridx (), nnz); + write_mat5_sparse_index_vector (os, m.ridx (), nzmax); write_mat5_sparse_index_vector (os, m.cidx (), nc + 1); // FIXME