Mercurial > hg > octave-lyh
diff src/ls-mat5.cc @ 11517:da8e32c99969
Fix for savving of sparse matrices to matlab files when nnz is not equal to nzmax
author | David Bateman <dbateman@free.fr> |
---|---|
date | Thu, 13 Jan 2011 22:51:09 +0100 |
parents | e1edf0ba3bcb |
children | fd0a3ac60b0e |
line wrap: on
line diff
--- a/src/ls-mat5.cc +++ b/src/ls-mat5.cc @@ -2079,7 +2079,7 @@ { const SparseComplexMatrix m = tc.sparse_complex_matrix_value (); octave_idx_type nc = m.cols (); - octave_idx_type nnz = m.nzmax (); // Yes its nzmax + octave_idx_type nnz = m.nnz (); ret += 16 + save_mat5_array_length (m.data (), nnz, save_as_floats); if (nnz > 1) @@ -2091,7 +2091,7 @@ { const SparseMatrix m = tc.sparse_matrix_value (); octave_idx_type nc = m.cols (); - octave_idx_type nnz = m.nzmax (); + octave_idx_type nnz = m.nnz (); ret += 16 + save_mat5_array_length (m.data (), nnz, save_as_floats); if (nnz > 1) @@ -2445,12 +2445,11 @@ { if (tc.is_complex_type ()) { - SparseComplexMatrix m = tc.sparse_complex_matrix_value (); + const 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 (), nzmax); + write_mat5_sparse_index_vector (os, m.ridx (), nnz); write_mat5_sparse_index_vector (os, m.cidx (), nc + 1); NDArray buf (dim_vector (nnz, 1)); @@ -2467,12 +2466,11 @@ } else { - SparseMatrix m = tc.sparse_matrix_value (); + const 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 (), nzmax); + write_mat5_sparse_index_vector (os, m.ridx (), nnz); write_mat5_sparse_index_vector (os, m.cidx (), nc + 1); // FIXME