Mercurial > hg > octave-nkf
annotate scripts/polynomial/polyreduce.m @ 15063:36cbcc37fdb8
Refactor configure.ac to make it more understandable.
Use common syntax for messages in config.h
Correct typos, refer to libraries in all caps, use two spaces after period.
Follow Autoconf guidelines and place general tests before specific tests.
* configure.ac, m4/acinclude.m4: Use common syntax for messages in config.h
Correct typos, refer to libraries in all caps, use two spaces after period.
Follow Autoconf guidelines and place general tests before specific tests.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 31 Jul 2012 10:28:51 -0700 |
parents | f6007bb54f06 |
children | d63878346099 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14104
diff
changeset
|
1 ## Copyright (C) 1994-2012 John W. Eaton |
2313 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
904 | 18 |
3368 | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} polyreduce (@var{c}) | |
12575
d0b799dafede
Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
21 ## Reduce a polynomial coefficient vector to a minimum number of terms by |
3368 | 22 ## stripping off any leading zeros. |
14104
614505385171
doc: Overhaul docstrings for polynomial functions.
Rik <octave@nomad.inbox5.com>
parents:
13963
diff
changeset
|
23 ## @seealso{polyout} |
3368 | 24 ## @end deftypefn |
1025 | 25 |
3202 | 26 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312 | 27 ## Created: June 1994 |
28 ## Adapted-By: jwe | |
561 | 29 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
10224
diff
changeset
|
30 function p = polyreduce (c) |
1025 | 31 |
2716 | 32 if (nargin != 1) |
6046 | 33 print_usage (); |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
34 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
|
35 error ("polyreduce: C must be a non-empty vector"); |
2716 | 36 endif |
561 | 37 |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
38 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
|
39 |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
40 if (isempty (idx)) |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
41 p = 0; |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
42 else |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
43 p = c(idx:end); |
561 | 44 endif |
1025 | 45 |
561 | 46 endfunction |
7411 | 47 |
48 | |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
49 %!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
|
50 %!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
|
51 %!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
|
52 %!assert (polyreduce ([0, 0, 0]), 0) |
7411 | 53 |
14224
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
54 %!error polyreduce () |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
55 %!error polyreduce (1, 2) |
f6007bb54f06
polyreduce.m: Recode function using modern syntax.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
56 %!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
|
57 %!error <C must be a non-empty vector> polyreduce ([]) |
7411 | 58 |