Mercurial > octave
annotate scripts/general/isequal.m @ 24312:9d25e88d83f6
isequal.m, isequaln.m: Return a full, non-sparse, logical value for compatibility.
* isequal.m, isequaln.m: Always convert final return value to full matrix.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 26 Nov 2017 14:55:26 -0800 |
parents | 1262d7c4712e |
children | 7ba994876f3a |
rev | line source |
---|---|
24309
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
1 ## Copyright (C) 2017 Rik Wehbring |
23219
3ac9f9ecfae5
maint: Update copyright dates.
John W. Eaton <jwe@octave.org>
parents:
23083
diff
changeset
|
2 ## Copyright (C) 2005-2017 William Poetra Yoga Hadisoeseno |
24309
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
3 ## Copyright (C) 2000-2017 Paul Kienzle |
5178 | 4 ## |
5181 | 5 ## This file is part of Octave. |
5178 | 6 ## |
7016 | 7 ## Octave is free software; you can redistribute it and/or modify it |
8 ## 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
|
9 ## the Free Software Foundation; either version 3 of the License, or |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
10 ## (at your option) any later version. |
5181 | 11 ## |
7016 | 12 ## Octave is distributed in the hope that it will be useful, but |
13 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
15 ## GNU General Public License for more details. |
5178 | 16 ## |
17 ## You should have received a copy of the GNU General Public License | |
7016 | 18 ## along with Octave; see the file COPYING. If not, see |
19 ## <http://www.gnu.org/licenses/>. | |
5178 | 20 |
5182 | 21 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
22 ## @deftypefn {} {} isequal (@var{x1}, @var{x2}, @dots{}) |
5550 | 23 ## 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
|
24 ## @seealso{isequaln} |
5182 | 25 ## @end deftypefn |
5178 | 26 |
24309
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
27 ## Algorithm: |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
28 ## |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
29 ## 1. Verify the class of x. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
30 ## a. All objects are of the same class |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
31 ## b. All objects are of a generic "numeric" class which includes |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
32 ## numeric, logical, and character arrays |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
33 ## 2. Verify size of all objects match. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
34 ## 3. Convert objects to struct, and then compare as stated below. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
35 ## 4. For each argument after x, compare it for equality with x: |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
36 ## a. char compare each member with strcmp |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
37 ## b. numeric compare each member with '==' |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
38 ## c. struct compare number of fieldnames, value of fieldnames, |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
39 ## and then each field with isequal (recursive) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
40 ## d. cellstr compare each cellstr member with strcmp |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
41 ## e. cell compare each member with isequal (recursive) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
42 ## f. fcn_handle compare using overloaded "eq" operator |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
43 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
44 function t = isequal (x, varargin) |
5181 | 45 |
12604
132c89bb44e3
maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
46 if (nargin < 2) |
6046 | 47 print_usage (); |
5550 | 48 endif |
5181 | 49 |
24309
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
50 nvarargin = nargin - 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
51 two_args = (nvarargin == 1); # Optimization for base case of just 2 args |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
52 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
53 if (two_args) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
54 y = varargin{1}; # alias y to second input for comparison |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
55 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
56 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
57 ############################################################ |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
58 ## Generic tests for equality |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
59 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
60 ## All arguments must either be of the same class, |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
61 ## or they must be "numeric" values. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
62 if (two_args) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
63 t = (strcmp (class (x), class (y)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
64 || ((isreal (x) || iscomplex (x)) && (isreal (y) || iscomplex (y)))); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
65 else |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
66 t = (all (cellfun ("isclass", varargin, class (x))) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
67 || ((isreal (x) || iscomplex (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
68 && all (cellfun ("isreal", varargin) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
69 | cellfun ("isnumeric", varargin)))); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
70 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
71 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
72 ## Test that everything is the same size (which also tests dimensions) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
73 if (t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
74 t = size_equal (x, varargin{:}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
75 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
76 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
77 ## From here on, compare any objects as if they were structures. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
78 if (t && isobject (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
79 ## Locally suppress class-to-struct warning. We know what we are doing. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
80 warning ("off", "Octave:classdef-to-struct", "local"); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
81 x = builtin ("struct", x); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
82 if (two_args) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
83 clear y; # break link to existing variable |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
84 varargin(1) = builtin ("struct", varargin{1}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
85 y = varargin{1}; # re-alias y to second input |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
86 else |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
87 for i = 1:nvarargin |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
88 varargin(i) = builtin ("struct", varargin{i}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
89 endfor |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
90 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
91 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
92 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
93 ############################################################ |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
94 ## Check individual classes. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
95 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
96 if (t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
97 if (two_args) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
98 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
99 if (ischar (x) && ischar (y)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
100 ## char type. Optimization, strcmp is ~35% faster than '==' operator. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
101 t = strcmp (x, y); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
102 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
103 elseif (isreal (x) || iscomplex (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
104 ## general "numeric" type. Use '==' operator. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
105 m = (x == y); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
106 t = all (m(:)); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
107 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
108 elseif (isstruct (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
109 ## struct type. Compare # of fields, fieldnames, then field values. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
110 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
111 ## Test number of fields are equal. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
112 t = (numfields (x) == numfields (y)); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
113 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
114 ## Test that all the field names are equal. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
115 if (t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
116 s_fnm_x = sort (fieldnames (x)); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
117 t = all (strcmp (s_fnm_x, sort (fieldnames (y)))); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
118 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
119 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
120 ## Test that all field values are equal. Slow because of recursion. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
121 if (t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
122 for fldnm = s_fnm_x.' |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
123 t = isequal (x.(fldnm{1}), y.(fldnm{1})); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
124 if (! t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
125 break; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
126 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
127 endfor |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
128 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
129 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
130 elseif (iscellstr (x) && iscellstr (y)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
131 ## cellstr type. Optimization over cell type by using strcmp. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
132 ## FIXME: It would be faster to use strcmp on whole cellstr arrays, |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
133 ## but bug #51412 needs to be fixed. Instead, time/space trade-off. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
134 ## Convert to char (space) for faster processing with strcmp (time). |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
135 t = strcmp (char (x), char (y)); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
136 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
137 elseif (iscell (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
138 ## cell type. Check that each element of a cell is equal. Slow. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
139 n = numel (x); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
140 idx = 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
141 while (t && idx <= n) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
142 t = isequal (x{idx}, y{idx}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
143 idx += 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
144 endwhile |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
145 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
146 elseif (isa (x, "function_handle")) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
147 ## function type. Use '==' operator which is overloaded. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
148 t = (x == y); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
149 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
150 else |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
151 error ("isequal: Impossible to reach code. File a bug report."); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
152 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
153 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
154 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
155 else ## More than two args. This is going to be slower in general. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
156 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
157 if (ischar (x) && all (cellfun ("isclass", varargin, "char"))) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
158 ## char type. Optimization, strcmp is ~35% faster than '==' operator. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
159 idx = 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
160 while (t && idx <= nvarargin) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
161 t = strcmp (x, varargin{idx}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
162 idx += 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
163 endwhile |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
164 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
165 elseif (isreal (x) || iscomplex (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
166 ## general "numeric" type. Use '==' operator. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
167 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
168 idx = 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
169 while (t && idx <= nvarargin) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
170 y = varargin{idx}; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
171 m = (x == y); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
172 t = all (m(:)); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
173 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
174 idx += 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
175 endwhile |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
176 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
177 elseif (isstruct (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
178 ## struct type. Compare # of fields, fieldnames, then field values. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
179 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
180 ## Test number of fields are equal. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
181 fnm_x = fieldnames (x); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
182 n = numel (fnm_x); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
183 fnm_v = cellfun ("fieldnames", varargin, "uniformoutput", false); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
184 t = all (n == cellfun ("numel", fnm_v)); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
185 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
186 ## Test that all the field names are equal. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
187 if (t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
188 fnm_x = sort (fnm_x); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
189 idx = 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
190 while (t && idx <= nvarargin) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
191 ## Allow the fieldnames to be in a different order. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
192 t = all (strcmp (fnm_x, sort (fnm_v{idx}))); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
193 idx += 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
194 endwhile |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
195 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
196 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
197 ## Test that all field values are equal. Slow because of recursion. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
198 if (t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
199 args = cell (1, 1 + nvarargin); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
200 for fldnm = fnm_x.' |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
201 args(1) = x.(fldnm{1}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
202 for argn = 1:nvarargin |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
203 args(argn+1) = varargin{argn}.(fldnm{1}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
204 endfor |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
205 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
206 t = isequal (args{:}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
207 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
208 if (! t) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
209 break; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
210 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
211 endfor |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
212 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
213 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
214 elseif (iscellstr (x) && all (cellfun (@iscellstr, varargin))) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
215 ## cellstr type. Optimization over cell type by using strcmp. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
216 ## FIXME: It would be faster to use strcmp on whole cellstr arrays, |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
217 ## but bug #51412 needs to be fixed. Instead, time/space trade-off. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
218 ## Convert to char (space) for faster processing with strcmp (time). |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
219 idx = 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
220 x = char (x); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
221 while (t && idx <= nvarargin) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
222 t = strcmp (x, char (varargin{idx})); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
223 idx += 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
224 endwhile |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
225 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
226 elseif (iscell (x)) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
227 ## cell type. Check that each element of a cell is equal. Slow. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
228 n = numel (x); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
229 args = cell (1, 1 + nvarargin); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
230 idx = 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
231 while (t && idx <= n) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
232 args(1) = x{idx}; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
233 args(2:end) = [cellindexmat(varargin, idx){:}]; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
234 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
235 t = isequal (args{:}); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
236 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
237 idx += 1; |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
238 endwhile |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
239 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
240 elseif (isa (x, "function_handle")) |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
241 ## function type. Use '==' operator which is overloaded. |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
242 t = all (cellfun ("eq", {x}, varargin)); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
243 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
244 else |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
245 error ("isequal: Impossible to reach code. File a bug report."); |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
246 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
247 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
248 |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
249 endif |
1262d7c4712e
Promote __iseqal__.m to isequal.m, isequaln.m for 20% performance benefit (bug #51403).
Rik <rik@octave.org>
parents:
24308
diff
changeset
|
250 endif |
12604
132c89bb44e3
maint: Refactor general/isXXX.m scripts to put input validation first.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
251 |
24312
9d25e88d83f6
isequal.m, isequaln.m: Return a full, non-sparse, logical value for compatibility.
Rik <rik@octave.org>
parents:
24309
diff
changeset
|
252 t = full (t); # Always return full logical value for Matlab compatibility. |
9d25e88d83f6
isequal.m, isequaln.m: Return a full, non-sparse, logical value for compatibility.
Rik <rik@octave.org>
parents:
24309
diff
changeset
|
253 |
5178 | 254 endfunction |
5549 | 255 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
256 |
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
|
257 ## 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
|
258 %!assert (isequal ([], []), true) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
259 %!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
|
260 %!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
|
261 %!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
|
262 %!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
|
263 |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
264 ## 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
|
265 %!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
|
266 %!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
|
267 %!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
|
268 %!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
|
269 %!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
|
270 %!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
|
271 %!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
|
272 %!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
|
273 %!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
|
274 %!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
|
275 |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
276 ## General tests |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
277 %!test |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
278 %! A = 1:8; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
279 %! B = reshape (A, 2, 2, 2); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
280 %! assert (isequal (A, B), false); |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
281 %! assert (isequal (A, A, B), false); |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
282 %!test |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
283 %! A = reshape (1:8, 2, 2, 2); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
284 %! B = A; |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
285 %! assert (isequal (A, B), true); |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
286 %! assert (isequal (A, A, B), true); |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
287 %!test |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
288 %! A = reshape (1:8, 2, 4); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
289 %! B = reshape (A, 2, 2, 2); |
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
290 %! assert (isequal (A, B), false); |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
291 %! assert (isequal (A, A, B), false); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
292 |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
293 ## test characters and strings |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
294 %!assert (isequal ('a', "a"), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
295 %!assert (isequal ('a', 'a', "a"), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
296 %!assert (isequal ("abab", ["a", "b", "a", "b"]), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
297 %!assert (isequal ("abab", "abab", ["a", "b", "a", "b"]), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
298 %!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
|
299 %!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
|
300 %! true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
301 %!assert (isequal (["test ";"strings"], ["test ";"strings"]), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
302 %!assert (isequal (["test ";"strings"], ["test ";"strings"], |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
303 %! ["test ";"strings"]), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
304 %!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
|
305 %!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
|
306 %! false) |
9899
9f25290a35e8
more private function and subfunction changes
John W. Eaton <jwe@octave.org>
parents:
7017
diff
changeset
|
307 |
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
|
308 ## test all numeric built-in primitives |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
309 %!assert (isequal (false, 0)) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
310 %!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
|
311 %!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
|
312 %! 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
|
313 %! 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
|
314 %! double (0), single (0), |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
315 %! double (complex (0,0)), single (complex (0,0)), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
316 %! sparse (false), sparse (logical (0)), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
317 %! sparse (double (0)), sparse (single (0)), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
318 %! sparse (double (complex (0,0))), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
319 %! 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
|
320 %! true) |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18786
diff
changeset
|
321 %!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
|
322 %! 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
|
323 %! 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
|
324 %! double (1), single (1), |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
325 %! double (complex (1,0)), single (complex (1,0)), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
326 %! sparse (true), sparse (logical (1)), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
327 %! sparse (double (1)), sparse (single (1)), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
328 %! sparse (double (complex (1,0))), |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
329 %! 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
|
330 %! 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
|
331 |
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
|
332 ## test structures |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
333 %!assert (isequal (struct ([]), struct ([])), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
334 %!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
|
335 %!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
|
336 %!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
|
337 %!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
|
338 %!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
|
339 %!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
|
340 %!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
|
341 %!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
|
342 %!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
|
343 %!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
|
344 %!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
|
345 %! 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
|
346 %!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
|
347 %!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
|
348 %! 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
|
349 %!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
|
350 %!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
|
351 %! 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
|
352 |
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
|
353 ## recursive structure |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
18786
diff
changeset
|
354 %!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
|
355 %! 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
|
356 %! 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
|
357 %! x.b.b = "bb1"; |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
358 %! 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
|
359 %! 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
|
360 %! 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
|
361 %! 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
|
362 %! assert (isequal (x, y), false); |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
363 %! 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
|
364 %! 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
|
365 %! 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
|
366 %! 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
|
367 %! assert (isequal (x, y), false); |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
368 %! assert (isequal (x, x, y), false); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
369 |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
370 ## test cellstr |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
371 %!assert (isequal (cell (1,1), cell (1,1)), true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
372 %!assert (isequal (cell (1,1), cell (1,2)), false) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
373 %!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
|
374 %!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
|
375 %! true) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
376 %!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
|
377 %!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
|
378 %! false) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
379 %!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
|
380 %!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
|
381 %! false) |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
382 %!test |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
383 %! x = { ["ab"; "cd"] ; ["ef"; "gh"] }; |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
384 %! assert (isequal (x, x), true); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
385 %! assert (isequal (x, x, x), true); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
386 %! y = x; |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
387 %! y(2) = ["ef"; "gH"]; |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
388 %! assert (isequal (x, y), false); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
389 %! 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
|
390 |
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
|
391 ## 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
|
392 %!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
|
393 %!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
|
394 %!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
|
395 %!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
|
396 %!assert (isequal ({"a",1}, {"a",1}), true) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
397 %!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
|
398 %!assert (isequal ({"a",1}, {"a",2}), false) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
399 %!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
|
400 %!assert (isequal ({"a",1}, {"b",1}), false) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
401 %!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
|
402 %!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
|
403 %!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
|
404 %!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
|
405 %!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
|
406 %!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
|
407 %!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
|
408 %! 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
|
409 |
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
|
410 ## 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
|
411 %!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
|
412 %! 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
|
413 %! 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
|
414 %! 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
|
415 %! 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
|
416 %! 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
|
417 %! 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
|
418 %! 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
|
419 %! 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
|
420 |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
421 ## test function_handle |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
422 %!test |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
423 %! fcn = @(x) x.^2; |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
424 %! assert (isequal (fcn, fcn), true); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
425 %! assert (isequal (fcn, fcn, fcn), true); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
426 %! assert (isequal (fcn, @(x) x.^2), false); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
427 %! assert (isequal (fcn, fcn, @(x) x.^2), false); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
428 %! assert (isequal (@(x) x.^2, fcn), false); |
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
429 %! 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
|
430 |
17278
79d4b6089968
Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents:
16935
diff
changeset
|
431 ## 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
|
432 %!assert (isequal (sparse ([]), []), true) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
433 %!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
|
434 %!assert (isequal ([], sparse ([])), true) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
435 %!assert (isequal ([], [], sparse ([])), true) |
17278
79d4b6089968
Fix isequal for sparse matrix (bug #37321)
Stefan Mahr <dac922@gmx.de>
parents:
16935
diff
changeset
|
436 %!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
|
437 %!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
|
438 %!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
|
439 %!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
|
440 %!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
|
441 %!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
|
442 %!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
|
443 %!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
|
444 %!assert (isequal (speye (1), eye (1)), true) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
445 %!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
|
446 %!assert (isequal (eye (300), speye (300)), true) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
447 %!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
|
448 %!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
|
449 %!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
|
450 |
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
|
451 ## 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
|
452 %!assert (isequal (NaN, NaN), false) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
453 %!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
|
454 %!assert (isequal (NaN, Inf), false) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
455 %!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
|
456 %!assert (isequal (NaN, 1.0), false) |
24308
606f3866cdb7
__isequal__.m: Rewrite function for performance.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
457 %!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
|
458 %!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
|
459 %!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
|
460 %!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
|
461 %!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
|
462 %! 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
|
463 |
24312
9d25e88d83f6
isequal.m, isequaln.m: Return a full, non-sparse, logical value for compatibility.
Rik <rik@octave.org>
parents:
24309
diff
changeset
|
464 ## Matlab compatibility |
9d25e88d83f6
isequal.m, isequaln.m: Return a full, non-sparse, logical value for compatibility.
Rik <rik@octave.org>
parents:
24309
diff
changeset
|
465 %!assert (isequal (sparse (1), sparse (1)), true) |
9d25e88d83f6
isequal.m, isequaln.m: Return a full, non-sparse, logical value for compatibility.
Rik <rik@octave.org>
parents:
24309
diff
changeset
|
466 %!assert (isequal (sparse (1), sparse (1)), sparse (1)), true) |
9d25e88d83f6
isequal.m, isequaln.m: Return a full, non-sparse, logical value for compatibility.
Rik <rik@octave.org>
parents:
24309
diff
changeset
|
467 |
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
|
468 ## 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
|
469 %!error isequal () |
a7b2fc7fe1a9
binocdf.m: Reverse calling convention to betaincinv to preserve accuracy when p =~ 1.
Rik <rik@octave.org>
parents:
14363
diff
changeset
|
470 %!error isequal (1) |