annotate test/complex.tst @ 31214:19bd1953fc1d stable

GitHub-CI: Remove ubuntu-18.04 runners from build matrix. * .github/workflow/make.yaml (ubuntu): GitHub-hosted runners for ubuntu-18.04 are being deprecated. Remove them from build matrix. See also: https://github.com/actions/runner-images/issues/6002
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 30 Aug 2022 11:16:27 +0200
parents 796f54d4ddbf
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
3 ## Copyright (C) 2016-2022 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
7 ##
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
8 ## This file is part of Octave.
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
14 ##
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
19 ##
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
25
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
26 ## Test ordering of complex values by magnitude and then by phase
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
27 %!test
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
28 %! x = [0 i 1+i 2 3i 3+4i];
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
29 %! assert (sort (x, "descend"), fliplr (x));
19923
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
30 %! assert (sort (single (x), "descend"), fliplr (single (x)));
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
31
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
32 %!test
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
33 %! x = [1, -1, i, -i];
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
34 %! xs = [-i, 1, i, -1];
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
35 %! assert (sort (x), xs);
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
36 %! assert (sort (x, "descend"), fliplr (xs));
19923
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
37 %! assert (sort (single (x)), single (xs));
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
38 %! assert (sort (single (x), "descend"), fliplr (single (xs)));
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
39
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
40 ## bug #44071, issorted incorrect because it uses different sort routine.
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
41 %!assert (issorted ([1, -1, i, -i]), false)
19923
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
42 %!assert (issorted (single ([1, -1, i, -i])), false)
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
43
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
44 ## bug #43313, -1 is both '>' and '==' to (-1 - 0i)
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
45 %!test
28916
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27923
diff changeset
46 %! assert (complex (-1,0) == complex (-1,-0), true);
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27923
diff changeset
47 %! assert (complex (-1,0) > complex (-1,-0), false);
ec591c500fa4 maint: Use Octave convention of space after function name in test/.
Rik <rik@octave.org>
parents: 27923
diff changeset
48 %! assert (complex (-1,0) < complex (-1,-0), false);
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
49
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
50 ## Test that sort and issorted both agree on boundary case
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
51 %!test
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
52 %! x = [complex(-1,0), complex(-1,-0), i, -i, 1];
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
53 %! xs = sort (x);
19923
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
54 %! xf = single (x);
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
55 %! xfs = sort (xf);
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
56 %! assert (issorted (xs));
19923
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
57 %! assert (issorted (xfs));
31e3799b9e27 Map -pi to pi for principal argument in complex operators with float values (bug #43313)
Rik <rik@octave.org>
parents: 19635
diff changeset
58 %! assert (double (xfs), xs);
19635
bdf90710dddf Map -pi to pi for principal argument used in complex operators (bug #43313).
Daniel J Sebald <daniel.sebald@ieee.org>
parents:
diff changeset
59
19972
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
60 ## Finally, test that sort and issorted agree on NaNs
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
61 %!test
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
62 %! x = [complex(NaN,-1), complex(NaN,NaN), ...
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
63 %! complex(-1,0), complex(-1,-0), i, -i, 1, ...
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
64 %! complex(1,NaN)];
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
65 %! xs = sort (x);
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
66 %! xf = single (x);
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
67 %! xfs = sort (xf);
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
68 %! assert (issorted (xs));
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
69 %! assert (issorted (xfs));
117ccb5080c1 Add BIST tests for complex sort/issorted routines with NaN values.
Rik <rik@octave.org>
parents: 19923
diff changeset
70 %! assert (double (xfs), xs);