comparison scripts/polynomial/polyreduce.m @ 11469:c776f063fefe

Overhaul m-script files to use common variable name between code and documentation.
author Rik <octave@nomad.inbox5.com>
date Sun, 09 Jan 2011 12:41:21 -0800
parents f6e0404421f4
children fd0a3ac60b0e
comparison
equal deleted inserted replaced
11468:e1edf0ba3bcb 11469:c776f063fefe
27 27
28 ## Author: Tony Richardson <arichard@stark.cc.oh.us> 28 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
29 ## Created: June 1994 29 ## Created: June 1994
30 ## Adapted-By: jwe 30 ## Adapted-By: jwe
31 31
32 function p = polyreduce (p) 32 function p = polyreduce (c)
33 33
34 if (nargin != 1) 34 if (nargin != 1)
35 print_usage (); 35 print_usage ();
36 endif 36 endif
37 37
38 if (! (isvector (p) || isempty (p))) 38 if (!isvector (c) || isempty (c))
39 error ("polyreduce: argument must be a vector"); 39 error ("polyreduce: C must be a non-empty vector");
40 endif 40 endif
41 41
42 if (! isempty (p)) 42 if (! isempty (c))
43 43
44 index = find (p != 0); 44 index = find (c != 0);
45 45
46 if (isempty (index)) 46 if (isempty (index))
47 47
48 p = 0; 48 p = 0;
49 49
50 else 50 else
51 51
52 p = p (index (1):length (p)); 52 p = c(index (1):length (c));
53 53
54 endif 54 endif
55 55
56 endif 56 endif
57 57
61 61
62 %!assert(all (all (polyreduce ([1, 2, 3, 0, 0]) == [1, 2, 3, 0, 0]))); 62 %!assert(all (all (polyreduce ([1, 2, 3, 0, 0]) == [1, 2, 3, 0, 0])));
63 63
64 %!assert(all (all (polyreduce ([1, 0, 3]) == [1, 0, 3]))); 64 %!assert(all (all (polyreduce ([1, 0, 3]) == [1, 0, 3])));
65 65
66 %!assert(isempty (polyreduce ([])));
67
68 %!error polyreduce ([1, 2; 3, 4]); 66 %!error polyreduce ([1, 2; 3, 4]);
69 67