Mercurial > octave-nkf
comparison scripts/polynomial/ppjumps.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 =} ppjumps (pp) | |
21 ## Evaluates the boundary jumps of a piecewise polynomial. | |
22 ## If there are n intervals, and the dimensionality of pp is d, | |
23 ## the resulting array has dimensions @code{[d, n-1]}. | |
24 ## @end deftypefn | |
25 | |
26 function jumps = ppjumps (pp) | |
27 if (nargin != 1) | |
28 print_usage (); | |
29 endif | |
30 if (! isstruct (pp)) | |
31 error ("ppjumps: expects a pp structure"); | |
32 endif | |
33 | |
34 ## Extract info. | |
35 x = pp.x; | |
36 P = pp.P; | |
37 d = pp.d; | |
38 [nd, n, k] = size (P); | |
39 | |
40 ## Offsets. | |
41 dx = diff (x(1:n)).'; | |
42 dx = dx(ones (1, nd), :); # spread (do nothing in 1D) | |
43 | |
44 ## Use Horner scheme to get limits from the left. | |
45 llim = P(:,1:n-1,1); | |
46 for i = 2:k; | |
47 llim .*= dx; | |
48 llim += P(:,1:n-1,i); | |
49 endfor | |
50 | |
51 rlim = P(:,2:n,k); # limits from the right | |
52 jumps = reshape (rlim - llim, [d, n-1]); | |
53 | |
54 endfunction |