comparison scripts/polynomial/ppder.m @ 9976:702b998698ea

implement ppder, ppint, ppjmups
author Jaroslav Hajek <highegg@gmail.com>
date Sun, 13 Dec 2009 13:18:27 +0100
parents
children be55736a0783
comparison
equal deleted inserted replaced
9975:14ed68363284 9976:702b998698ea
1 ## Copyright (C) 2008, 2009 VZLU Prague, a.s., Czech Republic
2 ##
3 ## This file is part of Octave.
4 ##
5 ## Octave is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation; either version 3 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
14 ##
15 ## You should have received a copy of the GNU General Public License
16 ## along with this software; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
18
19 ## -*- texinfo -*-
20 ## @deftypefn{Function File} {ppd =} ppder (pp)
21 ## Computes the piecewise derivative of a piecewise polynomial struct @var{pp}.
22 ## @seealso{mkpp,ppval}
23 ## @end deftypefn
24
25 function ppd = ppder (pp)
26 if (nargin != 1)
27 print_usage ();
28 endif
29 if (! isstruct (pp))
30 error ("ppder: expects a pp structure");
31 endif
32
33 [x, p, n, k, d] = unmkpp (pp);
34 p = reshape (p, [], k);
35 if (k <= 1)
36 pd = zeros (rows (p), 1);
37 k = 1;
38 else
39 k -= 1;
40 pd = p(:,1:k) * diag (k:-1:1);
41 endif
42 ppd = mkpp (x, pd, d);
43 endfunction
44