annotate test/test_range.m @ 16088:b29b10fbb744 stable release-3-6-4

Version 3.6.4 released. * configure.ac (AC_INIT): Version is now 3.6.4. (OCTAVE_RELEASE_DATE): Now 2013-02-21.
author John W. Eaton <jwe@octave.org>
date Thu, 21 Feb 2013 15:17:54 -0500
parents 72c96de7a403
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14131
diff changeset
1 ## Copyright (C) 2007-2012 John W. Eaton
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
2 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
3 ## This file is part of Octave.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
4 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
6 ## under the terms of the GNU General Public License as published by
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
8 ## your option) any later version.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
9 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
13 ## General Public License for more details.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
14 ##
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
15 ## You should have received a copy of the GNU General Public License
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
17 ## <http://www.gnu.org/licenses/>.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6938
diff changeset
18
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
19 ## Test values of range
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
20
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
21 %!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
22 %!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
23 %!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
24 %!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
25 %!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
26 %!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
27 %!assert (full (i:2i:10i), zeros (1,0))
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
28
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
29 ## Test mixing integer range with other types
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
30
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
31 %!shared expect, r, z
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
32 %! expect = [ 1 2 3 4 5 6 7 8 9
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
33 %! 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
34 %! z = zeros (1,9);
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
35 %! r = 1:9;
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
36
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
37 %!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
38 %!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
39 %!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
40 %!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
41 %!assert ([ r ; sparse(logical(z)) ], sparse (expect))
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
42
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
43 %!assert ([ r ; int8(z) ], int8(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 ; int16(z) ], int16(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 ; int32(z) ], int32(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
46 %!assert ([ r ; int64(z) ], int64(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
47 %!assert ([ r ; uint8(z) ], uint8(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
48 %!assert ([ r ; uint16(z) ], uint16(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
49 %!assert ([ r ; uint32(z) ], uint32(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
50 %!assert ([ r ; uint64(z) ], uint64(expect))
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
51
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
52 ## Test mixing non-integer range with other types
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
53
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
54 %!shared expect, r, z
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
55 %! expect = [ 1.0 1.4 1.8 2.2 2.6 3.0
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
56 %! 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
57 %! z = zeros (1,6);
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
58 %! r = 1:0.4:3;
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
59
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
60 %!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
61 %!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
62 %!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
63 %!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
64 %!assert ([ r ; sparse(logical(z)) ], sparse (expect))
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
65
14131
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
66 %!assert ([ r ; int8(z) ], int8(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 ; int16(z) ], int16(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 ; int32(z) ], int32(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
69 %!assert ([ r ; int64(z) ], int64(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
70 %!assert ([ r ; uint8(z) ], uint8(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
71 %!assert ([ r ; uint16(z) ], uint16(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
72 %!assert ([ r ; uint32(z) ], uint32(expect))
c3309e1ec50d test: Use Octave coding and spacing conventions for fixed test scripts
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
73 %!assert ([ r ; uint64(z) ], uint64(expect))
6938
688ef9440022 [project @ 2007-10-01 15:59:33 by dbateman]
dbateman
parents:
diff changeset
74