Mercurial > hg > octave-nkf
annotate scripts/polynomial/polyreduce.m @ 18126:d76f790b4eec gui-release
enable do_braindead_shortcircuit_evaluation by default and deprecate
* octave.cc (maximum_braindamage): Don't call
Fdo_brainded_shortcircuit_evaluation.
* pt-exp.h (tree_expression::mark_braindead_shortcircuit): Eliminate
file name argument.
* pt-binop.h, pt-binop.cc
(tree_binary_expression::mark_braindead_shortcircuit): Likewise.
* oct-parse.in.yy (if_cmd_list1, elseif_clause, loop_command):
Eliminate argument from call to mark_braindead_shortcircuit.
* pt-binop.h, pt-binop.cc (Vdo_braindead_shortcircuit_evaluation):
Initialize to true.
(tree_binary_expression::matlab_style_short_circuit_warning): New function.
(tree_binary_expression::rvalue1): Call
matlab_style_short_circuit_warning if short circuit evaluation occurs.
(Fdo_braindead_shortcircuit_evaluation): Display deprecated warning.
Delete tests for do_braindead_shortcircuit_evaluation.
(tree_binary_expression::braindead_shortcircuit_warning_issued): New
member variable.
* NEWS: Mention change in default value and deprecated function.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 11 Dec 2013 20:51:22 -0500 |
parents | d63878346099 |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
14224
diff
changeset
|
1 ## Copyright (C) 1994-2013 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 |