Mercurial > octave
annotate test/range.tst @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
1 ## Copyright (C) 2007-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
2 ## |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
3 ## See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
4 ## or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
5 ## |
7016 | 6 ## |
7 ## This file is part of Octave. | |
8 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
9 ## Octave is free software: you can redistribute it and/or modify it |
7016 | 10 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
11 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
12 ## (at your option) any later version. |
7016 | 13 ## |
14 ## Octave is distributed in the hope that it will be useful, but | |
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## GNU General Public License for more details. |
7016 | 18 ## |
19 ## You should have received a copy of the GNU General Public License | |
20 ## along with Octave; see the file COPYING. If not, see | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
21 ## <https://www.gnu.org/licenses/>. |
7016 | 22 |
6938 | 23 ## Test values of range |
24 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
25 %!assert (full (1:9), [ 1 2 3 4 5 6 7 8 9 ]) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 %!assert (full (1:0.4:3), [ 1.0 1.4 1.8 2.2 2.6 3.0 ]) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
27 %!assert (full (9:1), zeros (1,0)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
28 %!assert (full (9:-1:1), [ 9 8 7 6 5 4 3 2 1 ]) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
29 %!assert (full (1:-1:9), zeros (1,0)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
30 %!assert (full (1:1:1), 1) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
31 %!assert (full (i:2i:10i), zeros (1,0)) |
6938 | 32 |
33 ## Test mixing integer range with other types | |
34 | |
35 %!shared expect, r, z | |
36 %! expect = [ 1 2 3 4 5 6 7 8 9 | |
37 %! 0 0 0 0 0 0 0 0 0 ]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
38 %! z = zeros (1,9); |
6938 | 39 %! r = 1:9; |
40 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
41 %!assert ([ r ; z ], expect) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
42 %!assert ([ r ; single(z) ], single (expect)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
43 %!assert ([ r ; logical(z) ], expect) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
44 %!assert ([ r ; sparse(z) ], sparse (expect)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
45 %!assert ([ r ; sparse(logical(z)) ], sparse (expect)) |
6938 | 46 |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
47 %!assert ([ r ; int8(z) ], int8 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
48 %!assert ([ r ; int16(z) ], int16 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
49 %!assert ([ r ; int32(z) ], int32 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
50 %!assert ([ r ; int64(z) ], int64 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
51 %!assert ([ r ; uint8(z) ], uint8 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
52 %!assert ([ r ; uint16(z) ], uint16 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
53 %!assert ([ r ; uint32(z) ], uint32 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
54 %!assert ([ r ; uint64(z) ], uint64 (expect)) |
6938 | 55 |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
56 ## Test mixing non-integer range with other types |
6938 | 57 |
58 %!shared expect, r, z | |
59 %! expect = [ 1.0 1.4 1.8 2.2 2.6 3.0 | |
60 %! 0 0 0 0 0 0 ]; | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
61 %! z = zeros (1,6); |
6938 | 62 %! r = 1:0.4:3; |
63 | |
14131
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
64 %!assert ([ r ; z ], expect) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
65 %!assert ([ r ; single(z) ], single (expect)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
66 %!assert ([ r ; logical(z) ], expect) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
67 %!assert ([ r ; sparse(z) ], sparse (expect)) |
c3309e1ec50d
test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
68 %!assert ([ r ; sparse(logical(z)) ], sparse (expect)) |
6938 | 69 |
16213
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
70 %!assert ([ r ; int8(z) ], int8 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
71 %!assert ([ r ; int16(z) ], int16 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
72 %!assert ([ r ; int32(z) ], int32 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
73 %!assert ([ r ; int64(z) ], int64 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
74 %!assert ([ r ; uint8(z) ], uint8 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
75 %!assert ([ r ; uint16(z) ], uint16 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
76 %!assert ([ r ; uint32(z) ], uint32 (expect)) |
b1283d4c06c2
test: Use Octave coding standards for scripts in test/ directory.
Rik <rik@octave.org>
parents:
16179
diff
changeset
|
77 %!assert ([ r ; uint64(z) ], uint64 (expect)) |
6938 | 78 |
16169
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
79 ## Test corner cases of ranges (base and limit) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
80 |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
81 %!shared r, rrev, rneg |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
82 %! r = -0:3; |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
83 %! rrev = 3:-1:-0; |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
84 %! rneg = -3:-0; |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
85 |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
86 %!assert (full (r), [-0 1 2 3]) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
87 %!assert (signbit (full (r)), logical ([1 0 0 0])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
88 %!assert (r(1), -0) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
89 %!assert (signbit (r(1)), true) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
90 %!assert (signbit (r(1:2)), logical ([1 0])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
91 %!assert (signbit (r(2:-1:1)), logical ([0 1])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
92 %!assert (signbit (r([2 1 1 3])), logical ([0 1 1 0])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
93 |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
94 %!assert (full (rrev), [3 2 1 -0]) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
95 %!assert (signbit (full (rrev)), logical ([0 0 0 1])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
96 %!assert (rrev(4), -0) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
97 %!assert (signbit (rrev(4)), true) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
98 %!assert (signbit (rrev(3:4)), logical ([0 1])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
99 %!assert (signbit (rrev(4:-1:3)), logical ([1 0])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
100 %!assert (signbit (rrev([1 4 4 2])), logical ([0 1 1 0])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
101 |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
102 %!assert (min (r), -0) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
103 %!assert (signbit (min (r)), true) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
104 %!assert (min (rrev), -0) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
105 %!assert (signbit (min (rrev)), true) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
106 |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
107 %!assert (max (rneg), -0) |
16179
025393bef399
range.tst: Correct typo min -> max in test.
Rik <rik@octave.org>
parents:
16169
diff
changeset
|
108 %!assert (signbit (max (rneg)), true) |
16169
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
109 |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
110 %!assert (sort (r, "descend"), [3 2 1 -0]) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
111 %!assert (signbit (sort (r, "descend")), logical ([0 0 0 1])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
112 %!assert (signbit (sort (rrev, "ascend")), logical ([1 0 0 0])) |
0303fda3e929
Fix range behavior with -0 endpoints (bug #38423)
Rik <rik@octave.org>
parents:
16030
diff
changeset
|
113 |
25812
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
114 ## Test mathematical operations (also, non-finite values and 0) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
115 %!shared r |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
116 %! r = 1:5; |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
117 |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
118 %!assert (-r, -1:-1:-5) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
119 %!assert (1 + r, 2:6) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
120 %!assert (Inf + r, Inf (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
121 %!assert (NaN + r, NaN (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
122 %!assert (r + 1, 2:6) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
123 %!assert (r + Inf, Inf (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
124 %!assert (r + NaN, NaN (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
125 %!assert (1 - r, 0:-1:-4) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
126 %!assert (Inf - r, Inf (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
127 %!assert (NaN - r, NaN (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
128 %!assert (r - 1, 0:4) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
129 %!assert (r - Inf, -Inf (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
130 %!assert (r - NaN, NaN (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
131 %!assert (2 * r, 2:2:10) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
132 %!assert (0 * r, zeros (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
133 %!assert (Inf * r, Inf (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
134 %!assert (NaN * r, NaN (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
135 %!assert (r * 2, 2:2:10) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
136 %!assert (r * 0, zeros (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
137 %!assert (r * Inf, Inf (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
138 %!assert (r * NaN, NaN (1,5)) |
fc74c8d2a584
Clean up liboctave Range implementation.
Rik <rik@octave.org>
parents:
25808
diff
changeset
|
139 |
20458
ba032e57fd96
range.tst: Add tests for bug #45739.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
140 ## Test sorting of ranges (bug #45739) |
ba032e57fd96
range.tst: Add tests for bug #45739.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
141 %!shared r, rrev |
ba032e57fd96
range.tst: Add tests for bug #45739.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
142 %! r = 1:2:10; |
ba032e57fd96
range.tst: Add tests for bug #45739.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
143 %! rrev = 10:-2:1; |
ba032e57fd96
range.tst: Add tests for bug #45739.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
144 |
25808
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
145 %!assert <*45739> (sort (r, "descend"), [9 7 5 3 1]) |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
146 %!assert <*45739> (sort (rrev, "ascend"), [2 4 6 8 10]) |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
147 |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
148 ## Test final value within eps of an integer (bug #46859) |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
149 %!test <*46859> |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
150 %! rng = 1 : (1001/250)/(1/250); |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
151 %! assert (rng(end), 1001); |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
152 |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
153 %!test <*46859> |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
154 %! rng = 2000: -1 : (1001/250)/(1/250); |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
155 %! assert (rng(end), 1001); |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
156 |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
157 ## This is not Matlab compatible (stops at 1000 with 999 elements) |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
158 ## Octave prefers the more intuitive "pure math" approach where |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
159 ## (1001/250) / (1/250) => (1001/250)*(250/1) => 1001. |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
160 %!test <*46859> |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
161 %! rng = 1 : (1001/250)/(1/250); |
dc47c9e48801
Guarantee an integer for max of Range when base and increment are ints (bug #46859).
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
162 %! assert (numel (1000)); |