# HG changeset patch # User David Bateman # Date 1293565577 -3600 # Node ID a4822f3d103243882073e685f9d2733684293b52 # Parent a140991387fb4aeb62b079297f7ac4cb0d783ce8 Fix for saving of single precision arrays to the matlab file format diff -r a140991387fb -r a4822f3d1032 src/ChangeLog --- a/src/ChangeLog Tue Dec 28 07:42:34 2010 -0500 +++ b/src/ChangeLog Tue Dec 28 20:46:17 2010 +0100 @@ -1,3 +1,9 @@ +2010-12-28 David Bateman + + * ls-mat5.cc (save_mat5_array_length (const float*, octave_idx_type, + bool)): Take in to account the 4 bytes of padding for an odd number + of elements in single precision arrays. + 2010-12-27 Rik * syscalls.cc (stat): Add additional calling form using file descriptor diff -r a140991387fb -r a4822f3d1032 src/ls-mat5.cc --- a/src/ls-mat5.cc Tue Dec 28 07:42:34 2010 -0500 +++ b/src/ls-mat5.cc Tue Dec 28 20:46:17 2010 +0100 @@ -1314,7 +1314,7 @@ FloatComplexNDArray ctmp (dims); for (octave_idx_type i = 0; i < n; i++) - ctmp(i) = Complex (re(i), im(i)); + ctmp(i) = FloatComplex (re(i), im(i)); tc = ctmp; } @@ -1954,7 +1954,7 @@ } int -save_mat5_array_length (const float* val, octave_idx_type nel, bool) +save_mat5_array_length (const float* /* val */, octave_idx_type nel, bool) { if (nel > 0) { @@ -2002,7 +2002,8 @@ // size = 4; // } - return 8 + nel * size; + // Round nel up to nearest even number of elements + return 8 + ((nel + 1) & ~0x1LL) * size; } else return 8;