Mercurial > hg > octave-lyh
comparison scripts/polynomial/polyreduce.m @ 2716:2b5c27299cde
[project @ 1997-02-22 08:40:55 by jwe]
author | jwe |
---|---|
date | Sat, 22 Feb 1997 08:44:22 +0000 |
parents | 5ca126254d15 |
children | 8b262e771614 |
comparison
equal
deleted
inserted
replaced
2715:df8c732b4fb2 | 2716:2b5c27299cde |
---|---|
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 (p) |
33 | 33 |
34 index = find (p == 0); | 34 if (nargin != 1) |
35 usage ("polyreduce (p)"); | |
36 endif | |
35 | 37 |
36 if (length (index) != 0) | 38 if (! (is_vector (p) || isempty (p))) |
39 error ("polyreduce: argument must be a vector"); | |
40 endif | |
37 | 41 |
38 index = find (index == 1:length (index)); | 42 if (! isempty (p)) |
43 | |
44 index = find (p == 0); | |
39 | 45 |
40 if (length (index) != 0) | 46 if (length (index) != 0) |
41 | 47 |
42 if (length (p) > 1) | 48 index = find (index == 1:length (index)); |
43 p = p (index (length (index))+1:length (p)); | |
44 endif | |
45 | 49 |
46 if (length (p) == 0) | 50 if (length (index) != 0) |
47 p = 0; | 51 |
52 if (length (p) > 1) | |
53 p = p (index (length (index))+1:length (p)); | |
54 endif | |
55 | |
56 if (length (p) == 0) | |
57 p = 0; | |
58 endif | |
59 | |
48 endif | 60 endif |
49 | 61 |
50 endif | 62 endif |
51 | 63 |
52 endif | 64 endif |