Mercurial > hg > octave-nkf
diff liboctave/array/fCMatrix.cc @ 20676: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 | a9574e3c6e9e |
children |
line wrap: on
line diff
--- a/liboctave/array/fCMatrix.cc +++ b/liboctave/array/fCMatrix.cc @@ -4019,8 +4019,6 @@ octave_idx_type n) { - if (n < 1) n = 1; - octave_idx_type m = x1.numel (); if (x2.numel () != m) @@ -4029,11 +4027,17 @@ NoAlias<FloatComplexMatrix> 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 FloatComplex *delta = &retval(0, n-1); for (octave_idx_type i = 0; i < m; i++) delta[i] = (x2(i) - x1(i)) / (n - 1.0f);