Mercurial > octave
annotate scripts/polynomial/polyreduce.m @ 28891:de5f2f9a64ff
maint: Use same coding style when checking for a minimum of 1 input.
* disp.m, __get_properties__.m, disp.m, isplaying.m, pause.m, resume.m,
stop.m, __get_properties__.m, disp.m, isrecording.m, pause.m, resume.m, stop.m,
mu2lin.m, acosd.m, acot.m, acotd.m, acoth.m, acsc.m, acscd.m, acsch.m, asec.m,
asecd.m, asech.m, asind.m, atand.m, cosd.m, cot.m, cotd.m, coth.m, csc.m,
cscd.m, csch.m, sec.m, secd.m, sech.m, sind.m, tand.m, cell2mat.m, deg2rad.m,
fliplr.m, flipud.m, int2str.m, nextpow2.m, num2str.m, rad2deg.m, subsindex.m,
rotx.m, roty.m, rotz.m, voronoin.m, __unimplemented__.m, frame2im.m, hsv2rgb.m,
iscolormap.m, __imfinfo__.m, rgb2gray.m, rgb2hsv.m, fileread.m,
is_valid_file_id.m, usejava.m, argnames.m, char.m, formula.m, vectorize.m,
isdir.m, vectorize.m, condeig.m, duplication_matrix.m, expm.m, isdiag.m,
istril.m, istriu.m, normest.m, planerot.m, trace.m, vech.m, fieldnames.m,
fileparts.m, grabcode.m, isfile.m, isfolder.m, mustBeFinite.m, mustBeInteger.m,
mustBeNegative.m, mustBeNonNan.m, mustBeNonempty.m, mustBeNonnegative.m,
mustBeNonpositive.m, mustBeNonsparse.m, mustBeNonzero.m, mustBeNumeric.m,
mustBeNumericOrLogical.m, mustBePositive.m, mustBeReal.m, namedargs2cell.m,
open.m, run.m, swapbytes.m, pareto.m, allchild.m, colstyle.m, hdl2struct.m,
isaxes.m, isfigure.m, ishandle.m, compan.m, poly.m, polyreduce.m, ppjumps.m,
roots.m, unmkpp.m, profexplore.m, profile.m, bartlett.m, fftshift.m, hurst.m,
ifftshift.m, sinc.m, spencer.m, yulewalker.m, colperm.m, nonzeros.m,
spconvert.m, spones.m, sprandsym.m, cosint.m, expint.m, factor.m, factorial.m,
isprime.m, perms.m, primes.m, reallog.m, realsqrt.m, sinint.m, gallery.m,
hadamard.m, hilb.m, invhilb.m, magic.m, wilkinson.m, center.m, iqr.m, meansq.m,
median.m, runlength.m, bin2dec.m, blanks.m, deblank.m, hex2dec.m, isletter.m,
isstring.m, str2num.m, strtrim.m, asctime.m, ctime.m:
Replace "if (nargin != 1)" formulations with "if (nargin < 1)" to match
the rest of Octave.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 10 Oct 2020 16:32:20 -0700 |
parents | d8318c12d903 |
children | 7854d5752dd2 |
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 ## |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 ## Copyright (C) 1994-2020 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/>. |
2313 | 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 |
2313 | 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. |
2313 | 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. |
2313 | 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 ######################################################################## |
904 | 25 |
3368 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
27 ## @deftypefn {} {} polyreduce (@var{c}) |
12575
d0b799dafede
Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
28 ## Reduce a polynomial coefficient vector to a minimum number of terms by |
3368 | 29 ## stripping off any leading zeros. |
14104
614505385171
doc: Overhaul docstrings for polynomial functions.
Rik <octave@nomad.inbox5.com>
parents:
13963
diff
changeset
|
30 ## @seealso{polyout} |
3368 | 31 ## @end deftypefn |
1025 | 32 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10224
diff
changeset
|
33 function p = polyreduce (c) |
1025 | 34 |
28891
de5f2f9a64ff
maint: Use same coding style when checking for a minimum of 1 input.
Rik <rik@octave.org>
parents:
28886
diff
changeset
|
35 if (nargin < 1) |
6046 | 36 print_usage (); |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
37 elseif (! isvector (c) || isempty (c)) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10224
diff
changeset
|
38 error ("polyreduce: C must be a non-empty vector"); |
2716 | 39 endif |
561 | 40 |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
41 idx = find (c != 0, 1); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
42 |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
43 if (isempty (idx)) |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
44 p = 0; |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
45 else |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
46 p = c(idx:end); |
561 | 47 endif |
1025 | 48 |
561 | 49 endfunction |
7411 | 50 |
51 | |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
52 %!assert (polyreduce ([0, 0, 1, 2, 3]), [1, 2, 3]) |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
53 %!assert (polyreduce ([1, 2, 3, 0, 0]), [1, 2, 3, 0, 0]) |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 %!assert (polyreduce ([1, 0, 3]), [1, 0, 3]) |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 %!assert (polyreduce ([0, 0, 0]), 0) |
7411 | 56 |
28886
d8318c12d903
test: remove unnecessary BIST tests in m-files checking for excessive number of inputs.
Rik <rik@octave.org>
parents:
27985
diff
changeset
|
57 %!error <Invalid call> polyreduce () |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
58 %!error <C must be a non-empty vector> polyreduce ([1, 2; 3, 4]) |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
59 %!error <C must be a non-empty vector> polyreduce ([]) |