annotate scripts/general/isequal.m @ 24308:606f3866cdb7

__isequal__.m: Rewrite function for performance. * isequal.m: Add many more BIST tests. Most are to verify the same thing through the two different internal code paths (2 args vs. multiple args) in __isequal__.m * __isequal__.m: Add Rik Wehbring to Copyright. Rewrite docstring and comments describing algorithm. Add special fast path for only two arguments (most common case). Use size_equal() rather than hand-rolled code to check ndims() and size() along each dimension. Use strcmp without reshaping for better performance. Add special fast conversion for cellstr type by converting to char arrays and using strcmp. Put if/elseif branches in rough order of probability so common cases are hit first. Only run isnan tests on floating point objects which can actually have NaN values. Rename variables for clarity.
author Rik <rik@octave.org>
date Sat, 25 Nov 2017 21:56:15 -0800
parents 092078913d54
children 1262d7c4712e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23219
3ac9f9ecfae5 maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents: 23083
diff changeset
1 ## Copyright (C) 2005-2017 William Poetra Yoga Hadisoeseno
5178
6758c11b5b99 [project @ 2005-03-03 05:18:04 by jwe]
jwe
parents:
diff changeset
2 ##
5181
41cd70503c72 [project @ 2005-03-03 05:49:55 by jwe]
jwe
parents: 5178
diff changeset
3 ## This file is part of Octave.
5178
6758c11b5b99 [project @ 2005-03-03 05:18:04 by jwe]
jwe
parents:
diff changeset
4 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
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: 6046
diff changeset
6 ## under the terms of the GNU General Public License as published by
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
8 ## (at your option) any later version.
5181
41cd70503c72 [project @ 2005-03-03 05:49:55 by jwe]
jwe
parents: 5178
diff changeset
9 ##
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
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: 6046
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## GNU General Public License for more details.
5178
6758c11b5b99 [project @ 2005-03-03 05:18:04 by jwe]
jwe
parents:
diff changeset
14 ##
6758c11b5b99 [project @ 2005-03-03 05:18:04 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
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: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5178
6758c11b5b99 [project @ 2005-03-03 05:18:04 by jwe]
jwe
parents:
diff changeset
18
5182
5b361aa47dff [project @ 2005-03-03 06:21:47 by jwe]
jwe
parents: 5181
diff changeset
19 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
20 ## @deftypefn {} {} isequal (@var{x1}, @var{x2}, @dots{})
5550
815926a781f6 [project @ 2005-11-30 03:22:53 by jwe]
jwe
parents: 5549
diff changeset
21 ## Return true if all of @var{x1}, @var{x2}, @dots{} are equal.
16935
a7b2fc7fe1a9 binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
Rik <rik@octave.org>
parents: 14363
diff changeset
22 ## @seealso{isequaln}
5182
5b361aa47dff [project @ 2005-03-03 06:21:47 by jwe]
jwe
parents: 5181
diff changeset
23 ## @end deftypefn
5178
6758c11b5b99 [project @ 2005-03-03 05:18:04 by jwe]
jwe
parents:
diff changeset
24
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 9899
diff changeset
25 function retval = isequal (x1, varargin)
5181
41cd70503c72 [project @ 2005-03-03 05:49:55 by jwe]
jwe
parents: 5178
diff changeset
26
12604
132c89bb44e3 maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
27 if (nargin < 2)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5720
diff changeset
28 print_usage ();
5550
815926a781f6 [project @ 2005-11-30 03:22:53 by jwe]
jwe
parents: 5549
diff changeset
29 endif
5181
41cd70503c72 [project @ 2005-03-03 05:49:55 by jwe]
jwe
parents: 5178
diff changeset
30
12604
132c89bb44e3 maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
31 retval = __isequal__ (false, x1, varargin{:});
132c89bb44e3 maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents: 11523
diff changeset
32
5178
6758c11b5b99 [project @ 2005-03-03 05:18:04 by jwe]
jwe
parents:
diff changeset
33 endfunction
5549
6db3a5df1eab [project @ 2005-11-30 03:15:19 by jwe]
jwe
parents: 5393
diff changeset
34
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
35
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
36 ## test empty input
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
37 %!assert (isequal ([], []), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
38 %!assert (isequal ([], 1), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
39 %!assert (isequal ([], [], 1), false)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
40 %!assert (isequal ([], 1, []), false)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
41 %!assert (isequal (1, [], []), false)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
42
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
43 ## test size and shape
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
44 %!assert (isequal ([1,2,3,4], [1,2,3,4]), true)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
45 %!assert (isequal ([1;2;3;4], [1;2;3;4]), true)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
46 %!assert (isequal ([1,2,3,4], [1;2;3;4]), false)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
47 %!assert (isequal ([1,2,3,4], [1,2;3,4]), false)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
48 %!assert (isequal ([1,2,3,4], [1,3;2,4]), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
49 %!assert (isequal ([1,2,3,4], [1,2,3,4], [1,2,3,4]), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
50 %!assert (isequal ([1;2;3;4], [1;2;3;4], [1;2;3;4]), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
51 %!assert (isequal ([1,2,3,4], [1,2,3,4], [1;2;3;4]), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
52 %!assert (isequal ([1,2,3,4], [1,2,3,4], [1,2;3,4]), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
53 %!assert (isequal ([1,2,3,4], [1,2,3,4], [1,3;2,4]), false)
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
54
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
55 ## General tests
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
56 %!test
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
57 %! A = 1:8;
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
58 %! B = reshape (A, 2, 2, 2);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
59 %! assert (isequal (A, B), false);
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
60 %! assert (isequal (A, A, B), false);
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
61 %!test
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
62 %! A = reshape (1:8, 2, 2, 2);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
63 %! B = A;
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
64 %! assert (isequal (A, B), true);
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
65 %! assert (isequal (A, A, B), true);
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
66 %!test
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
67 %! A = reshape (1:8, 2, 4);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
68 %! B = reshape (A, 2, 2, 2);
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
69 %! assert (isequal (A, B), false);
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
70 %! assert (isequal (A, A, B), false);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
71
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
72 ## test characters and strings
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
73 %!assert (isequal ('a', "a"), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
74 %!assert (isequal ('a', 'a', "a"), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
75 %!assert (isequal ("abab", ["a", "b", "a", "b"]), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
76 %!assert (isequal ("abab", "abab", ["a", "b", "a", "b"]), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
77 %!assert (isequal (["a","b","c","d"], ["a","b","c","d"]), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
78 %!assert (isequal (["a","b","c","d"], ["a","b","c","d"], ["a","b","c","d"]),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
79 %! true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
80 %!assert (isequal (["test ";"strings"], ["test ";"strings"]), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
81 %!assert (isequal (["test ";"strings"], ["test ";"strings"],
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
82 %! ["test ";"strings"]), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
83 %!assert (isequal (["a","b","c","d"], ["a";"b";"c";"d"]), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
84 %!assert (isequal (["a","b","c","d"], ["a","b","c","d"], ["a";"b";"c";"d"]),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
85 %! false)
9899
9f25290a35e8 more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
86
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
87 ## test all numeric built-in primitives
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
88 %!assert (isequal (false, 0))
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
89 %!assert (isequal (char (0), 0))
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
90 %!assert (isequal (false, logical (0), char (0),
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
91 %! int8 (0), int16 (0), int32 (0), int64 (0),
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
92 %! uint8 (0), uint16 (0), uint32 (0), uint64 (0),
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
93 %! double (0), single (0),
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
94 %! double (complex (0,0)), single (complex (0,0)),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
95 %! sparse (false), sparse (logical (0)),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
96 %! sparse (double (0)), sparse (single (0)),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
97 %! sparse (double (complex (0,0))),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
98 %! sparse (single (complex (0,0)))),
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
99 %! true)
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18786
diff changeset
100 %!assert (isequal (true, logical (1), char (1),
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18786
diff changeset
101 %! int8 (1), int16 (1), int32 (1), int64 (1),
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18786
diff changeset
102 %! uint8 (1), uint16 (1), uint32 (1), uint64 (1),
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
103 %! double (1), single (1),
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
104 %! double (complex (1,0)), single (complex (1,0)),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
105 %! sparse (true), sparse (logical (1)),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
106 %! sparse (double (1)), sparse (single (1)),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
107 %! sparse (double (complex (1,0))),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
108 %! sparse (single (complex (1,0)))),
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
109 %! true)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
110
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
111 ## test structures
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
112 %!assert (isequal (struct ([]), struct ([])), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
113 %!assert (isequal (struct ([]), struct ([]), struct ([])), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
114 %!assert (isequal (struct ("a",1), struct ("a",1)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
115 %!assert (isequal (struct ("a",1), struct ("a",1), struct ("a",1)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
116 %!assert (isequal (struct ("a",1), struct ("a",2)), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
117 %!assert (isequal (struct ("a",1), struct ("a",1), struct ("a",2)), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
118 %!assert (isequal (struct ("a",1), struct ("a",1,"b",2)), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
119 %!assert (isequal (struct ("a",1), struct ("a",1),struct ("a",1,"b",2)), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
120 %!assert (isequal (struct ("a",1), struct ("b",1)), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
121 %!assert (isequal (struct ("a",1), struct ("a",1), struct ("b",1)), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
122 %!assert (isequal (struct ("a",1,"b",2), struct ("a",1,"b",2)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
123 %!assert (isequal (struct ("a",1,"b",2), struct ("a",1,"b",2),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
124 %! struct ("a",1,"b",2)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
125 %!assert (isequal (struct ("a",1,"b",2), struct ("b",2,"a",1)), true)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
126 %!assert (isequal (struct ("a",1,"b",2), struct ("a",1,"b",2),
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
127 %! struct ("b",2,"a",1)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
128 %!assert (isequal (struct ("a","abc","b",2), struct ("a","abc","b",2)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
129 %!assert (isequal (struct ("a","abc","b",2), struct ("a","abc","b",2),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
130 %! struct ("a","abc","b",2)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
131
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
132 ## recursive structure
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18786
diff changeset
133 %!test
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
134 %! x.a = "a1";
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
135 %! x.b.a = "ba1";
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
136 %! x.b.b = "bb1";
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
137 %! assert (isequal (x, x), true);
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
138 %! assert (isequal (x, x, x), true);
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
139 %! y = x;
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
140 %! y.b.b = "bb2";
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
141 %! assert (isequal (x, y), false);
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
142 %! assert (isequal (x, x, y), false);
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
143 %! y = x;
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
144 %! y.b = rmfield (y.b, "b");
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
145 %! y.b.b.a = "bba1";
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
146 %! assert (isequal (x, y), false);
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
147 %! assert (isequal (x, x, y), false);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
148
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
149 ## test cellstr
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
150 %!assert (isequal (cell (1,1), cell (1,1)), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
151 %!assert (isequal (cell (1,1), cell (1,2)), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
152 %!assert (isequal ({"a","b";"c","d"}, {"a","b";"c","d"}), true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
153 %!assert (isequal ({"a","b";"c","d"}, {"a","b";"c","d"}, {"a","b";"c","d"}),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
154 %! true)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
155 %!assert (isequal ({"a","b","c","d"}, {"a";"b";"c";"d"}), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
156 %!assert (isequal ({"a","b","c","d"}, {"a","b","c","d"}, {"a";"b";"c";"d"}),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
157 %! false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
158 %!assert (isequal (["a","b","c","d"], {"a","b","c","d"}), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
159 %!assert (isequal (["a","b","c","d"], ["a","b","c","d"], {"a","b","c","d"}),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
160 %! false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
161 %!test
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
162 %! x = { ["ab"; "cd"] ; ["ef"; "gh"] };
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
163 %! assert (isequal (x, x), true);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
164 %! assert (isequal (x, x, x), true);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
165 %! y = x;
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
166 %! y(2) = ["ef"; "gH"];
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
167 %! assert (isequal (x, y), false);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
168 %! assert (isequal (x, x, y), false);
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
169
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
170 ## test cells
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
171 %!assert (isequal (cell (1,1), cell (1,1)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
172 %!assert (isequal (cell (1,1), cell (1,1), cell (1,1)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
173 %!assert (isequal (cell (1,1), cell (1,2)), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
174 %!assert (isequal (cell (1,1), cell (1,1), cell (1,2)), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
175 %!assert (isequal ({"a",1}, {"a",1}), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
176 %!assert (isequal ({"a",1}, {"a",1}, {"a",1}), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
177 %!assert (isequal ({"a",1}, {"a",2}), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
178 %!assert (isequal ({"a",1}, {"a",1}, {"a",2}), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
179 %!assert (isequal ({"a",1}, {"b",1}), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
180 %!assert (isequal ({"a",1}, {"a",1}, {"b",1}), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
181 %!assert (isequal ({"a",1,"b",2}, {"a",1,"b",2}), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
182 %!assert (isequal ({"a",1,"b",2}, {"a",1,"b",2}, {"a",1,"b",2}), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
183 %!assert (isequal ({"a",1,"b",2}, {"b",2,"a",1}), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
184 %!assert (isequal ({"a",1,"b",2}, {"a",1,"b",2}, {"b",2,"a",1}), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
185 %!assert (isequal ({"a","abc","b",2}, {"a","abc","b",2}), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
186 %!assert (isequal ({"a","abc","b",2}, {"a","abc","b",2}, {"a","abc","b",2}),
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
187 %! true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
188
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
189 ## recursive cell
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
190 %!test
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
191 %! x = cell (1,3);
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
192 %! x{1} = {[1], [1 2]};
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
193 %! x{2} = true;
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
194 %! x{3} = {{"hello"}, {"world"}};
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
195 %! assert (isequal (x, x));
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
196 %! y = x;
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
197 %! y{3}{1}{1} = "goodbye";
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
198 %! assert (isequal (x, y), false);
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
199
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
200 ## test function_handle
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
201 %!test
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
202 %! fcn = @(x) x.^2;
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
203 %! assert (isequal (fcn, fcn), true);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
204 %! assert (isequal (fcn, fcn, fcn), true);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
205 %! assert (isequal (fcn, @(x) x.^2), false);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
206 %! assert (isequal (fcn, fcn, @(x) x.^2), false);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
207 %! assert (isequal (@(x) x.^2, fcn), false);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
208 %! assert (isequal (@(x) x.^2, @(x) x.^2, fcn), false);
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
209
17278
79d4b6089968 Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents: 16935
diff changeset
210 ## test for sparse matrices
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
211 %!assert (isequal (sparse ([]), []), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
212 %!assert (isequal (sparse ([]), sparse ([]), []), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
213 %!assert (isequal ([], sparse ([])), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
214 %!assert (isequal ([], [], sparse ([])), true)
17278
79d4b6089968 Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents: 16935
diff changeset
215 %!assert (isequal (sparse (0,1), sparse (0,1)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
216 %!assert (isequal (sparse (0,1), sparse (0,1), sparse (0,1)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
217 %!assert (isequal (sparse (0,1), zeros (0,1)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
218 %!assert (isequal (sparse (0,1), sparse (0,1), zeros (0,1)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
219 %!assert (isequal (sparse (2,2), sparse (2,2)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
220 %!assert (isequal (sparse (2,2), sparse (2,2), sparse (2,2)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
221 %!assert (isequal (zeros (2,2), sparse (2,2)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
222 %!assert (isequal (zeros (2,2), zeros (2,2), sparse (2,2)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
223 %!assert (isequal (speye (1), eye (1)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
224 %!assert (isequal (speye (1), speye (1), eye (1)), true)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
225 %!assert (isequal (eye (300), speye (300)), true)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
226 %!assert (isequal (eye (300), eye (300), speye (300)), true)
17278
79d4b6089968 Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents: 16935
diff changeset
227 %!assert (isequal (sparse (0,1), sparse (1,0)), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
228 %!assert (isequal (sparse (0,1), sparse (0,1), sparse (1,0)), false)
17278
79d4b6089968 Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents: 16935
diff changeset
229
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
230 ## test NaN
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
231 %!assert (isequal (NaN, NaN), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
232 %!assert (isequal (NaN, NaN, NaN), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
233 %!assert (isequal (NaN, Inf), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
234 %!assert (isequal (NaN, Inf, Inf), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
235 %!assert (isequal (NaN, 1.0), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
236 %!assert (isequal (NaN, 1.0, 1.0), false)
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
237 %!assert (isequal ([1,2,NaN,4], [1,2,NaN,4]), false)
24308
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
238 %!assert (isequal ([1,2,NaN,4], [1,2,NaN,4], [1,2,NaN,4]), false)
606f3866cdb7 __isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents: 23220
diff changeset
239 %!assert (isequal (struct ("a",NaN,"b",2), struct ("a",NaN,"b",2)), false)
19597
db92e7e28e1f strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 18786
diff changeset
240 %!assert (isequal (struct ("a",NaN,"b",2), struct ("a",NaN,"b",2),
18786
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
241 %! struct ("a",NaN,"b",2)), false)
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
242
ff613b6a7b6f Add tests for empty value and correct alphanumerical value comparision of isequal (bug #42408).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 17744
diff changeset
243 ## test input validation
16935
a7b2fc7fe1a9 binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
Rik <rik@octave.org>
parents: 14363
diff changeset
244 %!error isequal ()
a7b2fc7fe1a9 binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
Rik <rik@octave.org>
parents: 14363
diff changeset
245 %!error isequal (1)