Mercurial > octave
annotate scripts/polynomial/mpoles.m @ 33625:d213a148b3f1 default tip @
ensure exp. terminal widget has focus at startup
* main-window.cc (main_window): call focus_command_window only if
event loop is idle by using a single shot timer
* main-window.h: make focus_command_window a public slot
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sun, 26 May 2024 02:29:44 +0200 |
parents | 2e484f9f1f18 |
children |
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 ## |
32632
2e484f9f1f18
maint: update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
31915
diff
changeset
|
3 ## Copyright (C) 2007-2024 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/>. |
6964 | 7 ## |
8 ## This file is part of Octave. | |
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 |
6964 | 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. |
6964 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
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. |
6964 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 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 ######################################################################## |
6964 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
27 ## @deftypefn {} {[@var{multp}, @var{idxp}] =} mpoles (@var{p}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
28 ## @deftypefnx {} {[@var{multp}, @var{idxp}] =} mpoles (@var{p}, @var{tol}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
29 ## @deftypefnx {} {[@var{multp}, @var{idxp}] =} mpoles (@var{p}, @var{tol}, @var{reorder}) |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
30 ## Identify unique poles in @var{p} and their associated multiplicity. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
31 ## |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
32 ## By default, the output is ordered from the pole with the largest magnitude |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
33 ## to the smallest magnitude. |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
34 ## |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
35 ## Two poles are considered to be multiples if the difference between them |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
36 ## is less than the relative tolerance @var{tol}. |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
37 ## |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
38 ## @example |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
39 ## abs (@var{p1} - @var{p0}) / abs (@var{p0}) < @var{tol} |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
40 ## @end example |
6964 | 41 ## |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
42 ## If the pole is 0 then no scaling is done and @var{tol} is interpreted as an |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
43 ## absolute tolerance. The default value for @var{tol} is 0.001. |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
44 ## |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
45 ## If the optional parameter @var{reorder} is false/zero, poles are not |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
46 ## sorted. |
6964 | 47 ## |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
48 ## The output @var{multp} is a vector specifying the multiplicity of the poles. |
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
49 ## @code{@var{multp}(n)} refers to the multiplicity of the Nth pole |
14104
614505385171
doc: Overhaul docstrings for polynomial functions.
Rik <octave@nomad.inbox5.com>
parents:
13963
diff
changeset
|
50 ## @code{@var{p}(@var{idxp}(n))}. |
6964 | 51 ## |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
52 ## For example: |
6964 | 53 ## |
54 ## @example | |
55 ## @group | |
56 ## p = [2 3 1 1 2]; | |
14327
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
57 ## [m, n] = mpoles (p) |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
58 ## @result{} m = [1; 1; 2; 1; 2] |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 ## @result{} n = [2; 5; 1; 4; 3] |
4d917a6a858b
doc: Use Octave coding conventions in @example blocks of docstrings.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
60 ## @result{} p(n) = [3, 2, 2, 1, 1] |
6964 | 61 ## @end group |
62 ## @end example | |
63 ## | |
14104
614505385171
doc: Overhaul docstrings for polynomial functions.
Rik <octave@nomad.inbox5.com>
parents:
13963
diff
changeset
|
64 ## @seealso{residue, poly, roots, conv, deconv} |
6964 | 65 ## @end deftypefn |
66 | |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
67 function [multp, idxp] = mpoles (p, tol, reorder) |
6964 | 68 |
28789
28de41192f3c
Eliminate unneeded verification of nargin, nargout in m-files.
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
69 if (nargin < 1) |
6964 | 70 print_usage (); |
71 endif | |
72 | |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
73 if (! isfloat (p)) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
74 error ("mpoles: P must be a single or double floating point vector"); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
75 endif |
6964 | 76 |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
77 if (nargin < 2 || isempty (tol)) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
78 tol = 0.001; |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
79 elseif (! (isscalar (tol) && isreal (tol) && tol > 0)) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
80 error ("mpoles: TOL must be a real scalar greater than 0"); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
81 endif |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
82 |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
83 if (nargin < 3 || isempty (reorder)) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
84 reorder = true; |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
85 elseif (! (isscalar (reorder) && isreal (reorder))) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
86 error ("mpoles: REORDER must be a numeric or logical scalar"); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
87 endif |
6964 | 88 |
89 Np = numel (p); | |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
90 p = p(:); # force poles to be a column vector |
6964 | 91 |
92 if (reorder) | |
29533
6dfc06f55cd2
mpoles.m: Fix detection of pole multiplicity (bug #60384).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
93 ## sort with largest magnitude first |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
94 [~, order] = sort (abs (p), "descend"); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
95 p = p(order); |
6964 | 96 else |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
97 order = (1:Np).'; |
6964 | 98 endif |
99 | |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
100 ## Create vector of tolerances for use in algorithm. |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
101 vtol = zeros (Np, 1, class (p)); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
102 p_nz = (p != 0); # non-zero poles |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
103 vtol(! p_nz) = tol; # use absolute tolerance for zero poles |
6964 | 104 |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
105 ## Find pole multiplicity by comparing relative difference of poles. |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
106 multp = zeros (Np, 1, class (p)); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
107 idxp = []; |
6964 | 108 n = find (multp == 0, 1); |
109 while (n) | |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
110 dp = abs (p - p(n)); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
111 vtol(p_nz) = tol * abs (p(n)); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
112 k = find (dp < vtol); |
7360 | 113 ## Poles can only be members of one multiplicity group. |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
114 if (numel (idxp)) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
115 k = k(! ismember (k, idxp)); |
7360 | 116 endif |
6964 | 117 m = 1:numel (k); |
118 multp(k) = m; | |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
119 idxp = [idxp; k]; |
6964 | 120 n = find (multp == 0, 1); |
121 endwhile | |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
122 multp = multp(idxp); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
123 idxp = order(idxp); |
6964 | 124 |
125 endfunction | |
9360
df42106beec8
mpoles.m: Fix infinite loop for a multiplicity of poles at zero. Test added.
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
126 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
127 |
9360
df42106beec8
mpoles.m: Fix infinite loop for a multiplicity of poles at zero. Test added.
Ben Abbott <bpabbott@mac.com>
parents:
9245
diff
changeset
|
128 %!test |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
129 %! [mp, ip] = mpoles ([0 0], 0.01); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14327
diff
changeset
|
130 %! assert (mp, [1; 2]); |
29533
6dfc06f55cd2
mpoles.m: Fix detection of pole multiplicity (bug #60384).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
131 |
6dfc06f55cd2
mpoles.m: Fix detection of pole multiplicity (bug #60384).
Markus Mützel <markus.muetzel@gmx.de>
parents:
29358
diff
changeset
|
132 %!test |
31915
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
133 %! [mp, ip] = mpoles ([-1e4, -0.1, 0]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
134 %! assert (mp, [1; 1; 1]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
135 %! assert (ip, [1; 2; 3]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
136 |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
137 ## Test single inputs |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
138 %!test |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
139 %! [mp, ip] = mpoles (single ([-1e4, -0.1, 0])); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
140 %! assert (mp, single ([1; 1; 1])); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
141 %! assert (ip, [1; 2; 3]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
142 |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
143 ## Test relative tolerance criteria |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
144 %!test |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
145 %! [mp, ip] = mpoles ([1, 1.1, 1.3], .1/1.1); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
146 %! assert (mp, [1; 1; 1]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
147 %! [mp, ip] = mpoles ([1, 1.1, 1.3], .1/1.1 + eps); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
148 %! assert (mp, [1; 1; 2]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
149 |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
150 ## Test absolute tolerance criteria with a zero pole |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
151 %!test |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
152 %! [mp, ip] = mpoles ([0, -0.1, 0.3], .1); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
153 %! assert (mp, [1; 1; 1]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
154 %! [mp, ip] = mpoles ([0, -0.1, 0.3], .1 + eps); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
155 %! assert (mp, [1; 1; 2]); |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
156 |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
157 ## Test input validation |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
158 %!error <Invalid call> mpoles () |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
159 %!error <P must be a single or double floating point vector> mpoles (uint8 (1)) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
160 %!error <TOL must be a real scalar greater than 0> mpoles (1, [1, 2]) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
161 %!error <TOL must be a real scalar greater than 0> mpoles (1, 1i) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
162 %!error <TOL must be a real scalar greater than 0> mpoles (1, 0) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
163 %!error <REORDER must be a numeric or logical scalar> mpoles (1, 1, [1, 2]) |
8eeb49ec16d8
mpoles.m: Overhaul function and use absolute tolerance for zero poles (bug #63937)
Rik <rik@octave.org>
parents:
31706
diff
changeset
|
164 %!error <REORDER must be a numeric or logical scalar> mpoles (1, 1, {1}) |