Mercurial > octave-nkf
diff liboctave/array/fMatrix.cc @ 20501:16b9ec39ff46
Return empty matrix when linspace called with 0 points (bug #45820)
* NEWS: Announce change.
* data.cc (Flinspace): Verify input N is scalar. Verify inputs BASE, LIMIT are
scalar/vectors. Add BIST tests for input validation, complex values, class of
output, Matlab compatibility. Clarify documentation about vector inputs.
* CMatrix.cc, CRowVector.cc, dMatrix.cc, dRowVector.cc, fCMatrix.cc,
fCRowVector.cc, fMatrix.cc, fRowVector.cc:
Return empty matrix when N < 1.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 27 Aug 2015 13:12:21 -0700 |
parents | 5ce959c55cc0 |
children |
line wrap: on
line diff
--- a/liboctave/array/fMatrix.cc Wed Aug 26 16:05:49 2015 -0400 +++ b/liboctave/array/fMatrix.cc Thu Aug 27 13:12:21 2015 -0700 @@ -3335,8 +3335,6 @@ octave_idx_type n) { - if (n < 1) n = 1; - octave_idx_type m = x1.numel (); if (x2.numel () != m) @@ -3345,11 +3343,17 @@ NoAlias<FloatMatrix> retval; + if (n < 1) + { + retval.clear (m, 0); + return retval; + } + retval.clear (m, n); for (octave_idx_type i = 0; i < m; i++) retval(i, 0) = x1(i); - // The last column is not needed while using delta. + // The last column is unused so temporarily store delta there float *delta = &retval(0, n-1); for (octave_idx_type i = 0; i < m; i++) delta[i] = (x2(i) - x1(i)) / (n - 1);