6853
|
1 ## Copyright (C) 1996, 1997 John W. Eaton |
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} polyint (@var{c}, @var{k}) |
|
22 ## Return the coefficients of the integral of the polynomial whose |
|
23 ## coefficients are represented by the vector @var{c}. The variable |
|
24 ## @var{k} is the constant of integration, which by default is set to zero. |
|
25 ## @seealso{poly, polyderiv, polyreduce, roots, conv, deconv, residue, |
|
26 ## filter, polyval, and polyvalm} |
|
27 ## @end deftypefn |
|
28 |
|
29 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
|
30 ## Created: June 1994 |
|
31 ## Adapted-By: jwe |
|
32 |
|
33 function p = polyint (p, k) |
|
34 |
|
35 if (nargin < 1 || nargin > 2) |
|
36 print_usage (); |
|
37 endif |
|
38 |
|
39 if (nargin == 1) |
|
40 k = 0; |
|
41 elseif (! isscalar (k)) |
|
42 error ("polyint: the constant of integration must be a scalar"); |
|
43 endif |
|
44 |
|
45 if (! (isvector (p) || isempty (p))) |
|
46 error ("argument must be a vector"); |
|
47 endif |
|
48 |
|
49 lp = length (p); |
|
50 |
|
51 if (lp == 0) |
|
52 p = []; |
|
53 return; |
|
54 end |
|
55 |
|
56 if (rows (p) > 1) |
|
57 ## Convert to column vector |
|
58 p = p.'; |
|
59 endif |
|
60 |
|
61 p = [(p ./ [lp:-1:1]), k]; |
|
62 |
|
63 endfunction |