Mercurial > octave
comparison liboctave/array/fCMatrix.cc @ 25237:ca022a8c4015
linspace: handle ranges with equal Inf endpoints (bug #53489)
* CMatrix.cc (ComplexMatrix::linspace): Change delta calculation to yield 0 if
endpoints are the same, otherwise calculate delta as normal.
* CRowVector.cc (ComplexRowVector::linspace): Likewise.
* dMatrix.cc (Matrix::linspace): Likewise.
* dRowVector.cc (RowVector::linspace): Likewise.
* fCMatrix.cc (FloatComplexMatrix::linspace): Likewise.
* fCRowVector.cc (FloatComplexRowVector::linspace): Likewise.
* fMatrix.cc (FloatMatrix::linspace): Likewise.
* fRowVector.cc (FloatRowVector::linspace): Likewise.
* data.cc (Flinspace): Added Matlab compatibility tests.
* logspace.m: Added same tests as in linspace containing Inf in endpoints.
author | Maor Shutman <maorus12@gmail.com> |
---|---|
date | Fri, 06 Apr 2018 20:25:05 +0300 |
parents | 078b795c5219 |
children | cb1606f78f6b |
comparison
equal
deleted
inserted
replaced
25236:69b21b8a0e9f | 25237:ca022a8c4015 |
---|---|
3846 retval(i, 0) = x1(i); | 3846 retval(i, 0) = x1(i); |
3847 | 3847 |
3848 // The last column is unused so temporarily store delta there | 3848 // The last column is unused so temporarily store delta there |
3849 FloatComplex *delta = &retval(0, n-1); | 3849 FloatComplex *delta = &retval(0, n-1); |
3850 for (octave_idx_type i = 0; i < m; i++) | 3850 for (octave_idx_type i = 0; i < m; i++) |
3851 delta[i] = (x2(i) - x1(i)) / (n - 1.0f); | 3851 delta[i] = (x1(i) == x2(i)) ? 0 : (x2(i) - x1(i)) / (n - 1.0f); |
3852 | 3852 |
3853 for (octave_idx_type j = 1; j < n-1; j++) | 3853 for (octave_idx_type j = 1; j < n-1; j++) |
3854 for (octave_idx_type i = 0; i < m; i++) | 3854 for (octave_idx_type i = 0; i < m; i++) |
3855 retval(i, j) = x1(i) + static_cast<float> (j)*delta[i]; | 3855 retval(i, j) = x1(i) + static_cast<float> (j)*delta[i]; |
3856 | 3856 |