changeset 15349:9ed4fc294f3f draft

when writing sparse matrices to MAT files, use nzmax of at least 1 (bug #36603) * ls-mat5.cc (save_mat5_binary_element): If nnz is 0, write 1 for nzmax in array flags element.
author John W. Eaton <jwe@octave.org>
date Tue, 11 Sep 2012 01:47:48 -0400
parents 6bdf379592d9
children 450fedd44176
files libinterp/interp-core/ls-mat5.cc
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/interp-core/ls-mat5.cc
+++ b/libinterp/interp-core/ls-mat5.cc
@@ -2429,6 +2429,10 @@
     }
 
   os.write (reinterpret_cast<char *> (&flags), 4);
+  // Matlab seems to have trouble reading files that have nzmax == 0 at
+  // this point in the file.
+  if (nnz_32 == 0)
+    nnz_32 = 1;
   os.write (reinterpret_cast<char *> (&nnz_32), 4);
 
   write_mat5_tag (os, miINT32, dim_len);