Mercurial > octave
comparison scripts/general/logspace.m @ 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 | 6652d3823428 |
children | 592a4258b237 |
comparison
equal
deleted
inserted
replaced
25236:69b21b8a0e9f | 25237:ca022a8c4015 |
---|---|
95 %! x4 = logspace (1, pi, 10); | 95 %! x4 = logspace (1, pi, 10); |
96 %! assert (size (x1) == [1, 50] && abs (x1(1) - 10) < eps && abs (x1(50) - 100) < eps); | 96 %! assert (size (x1) == [1, 50] && abs (x1(1) - 10) < eps && abs (x1(50) - 100) < eps); |
97 %! assert (size (x2) == [1, 10] && abs (x2(1) - 10) < eps && abs (x2(10) - 100) < eps); | 97 %! assert (size (x2) == [1, 10] && abs (x2(1) - 10) < eps && abs (x2(10) - 100) < eps); |
98 %! assert (size (x3) == [1, 10] && abs (x3(1) - 10) < eps && abs (x3(10) - 0.01) < eps); | 98 %! assert (size (x3) == [1, 10] && abs (x3(1) - 10) < eps && abs (x3(10) - 0.01) < eps); |
99 %! assert (size (x4) == [1, 10] && abs (x4(1) - 10) < eps && abs (x4(10) - pi) < sqrt (eps)); | 99 %! assert (size (x4) == [1, 10] && abs (x4(1) - 10) < eps && abs (x4(10) - pi) < sqrt (eps)); |
100 %!assert (logspace (Inf, Inf, 3), [Inf, Inf, Inf]) | |
101 %!assert (logspace (-Inf, -Inf, 3), [0, 0, 0]) | |
102 %!assert (logspace (-Inf, Inf, 3), [0, NaN, Inf]) | |
103 %!assert (logspace (Inf + 1i, Inf + 1i, 3), [-Inf + Inf * 1i, -Inf + Inf * 1i, -Inf + Inf * 1i]) | |
104 %!assert (logspace (-Inf + 1i, Inf + 1i, 3), [0, NaN + NaN * 1i, -Inf + Inf * 1i]) | |
105 %!assert (logspace (0, Inf, 3), [1, Inf, Inf]) | |
106 %!assert (logspace (0, -Inf, 3), [1, 0, 0]) | |
107 %!assert (logspace (-Inf, 0, 3), [0, NaN, 1]) | |
108 %!assert (logspace (Inf, 0, 3), [Inf, NaN, 1]) | |
109 %!assert (logspace (Inf, -Inf, 3), [Inf, NaN, 0]) | |
100 | 110 |
101 ## Test input validation | 111 ## Test input validation |
102 %!error logspace () | 112 %!error logspace () |
103 %!error logspace (1, 2, 3, 4) | 113 %!error logspace (1, 2, 3, 4) |
104 %!error logspace ([1, 2; 3, 4], 5, 6) | 114 %!error logspace ([1, 2; 3, 4], 5, 6) |