Mercurial > hg > octave-nkf
annotate scripts/polynomial/ppjumps.m @ 11587:c792872f8942
all script files: untabify and strip trailing whitespace
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 20 Jan 2011 17:35:29 -0500 |
parents | 702dbd0c53f5 |
children | 59e2460acae1 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2008-2011 VZLU Prague, a.s., Czech Republic |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11536
diff
changeset
|
2 ## |
9976
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11536
diff
changeset
|
4 ## |
9976
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published by |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
8 ## (at your option) any later version. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11536
diff
changeset
|
9 ## |
9976
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
10 ## This program is distributed in the hope that it will be useful, |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
13 ## GNU General Public License for more details. |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11536
diff
changeset
|
14 ## |
9976
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
16 ## along with this software; see the file COPYING. If not, see |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
18 |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
20 ## @deftypefn {Function File} {@var{jumps} =} ppjumps (@var{pp}) |
11536
702dbd0c53f5
Add undocumented ppder, ppint, ppjumps functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
21 ## Evaluate the boundary jumps of a piecewise polynomial. |
702dbd0c53f5
Add undocumented ppder, ppint, ppjumps functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
22 ## If there are @math{n} intervals, and the dimensionality of @var{pp} is |
702dbd0c53f5
Add undocumented ppder, ppint, ppjumps functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
23 ## @math{d}, the resulting array has dimensions @code{[d, n-1]}. |
702dbd0c53f5
Add undocumented ppder, ppint, ppjumps functions to documentation.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
24 ## @seealso{mkpp} |
9976
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 ## @end deftypefn |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
26 |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
27 function jumps = ppjumps (pp) |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
28 if (nargin != 1) |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 print_usage (); |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
30 endif |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
31 if (! isstruct (pp)) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
32 error ("ppjumps: PP must be a structure"); |
9976
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
33 endif |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
35 ## Extract info. |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
36 x = pp.x; |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
37 P = pp.P; |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
38 d = pp.d; |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
39 [nd, n, k] = size (P); |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
40 |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
41 ## Offsets. |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
42 dx = diff (x(1:n)).'; |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
43 dx = dx(ones (1, nd), :); # spread (do nothing in 1D) |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
44 |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 ## Use Horner scheme to get limits from the left. |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 llim = P(:,1:n-1,1); |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
47 for i = 2:k; |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
48 llim .*= dx; |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
49 llim += P(:,1:n-1,i); |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
50 endfor |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
51 |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
52 rlim = P(:,2:n,k); # limits from the right |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
53 jumps = reshape (rlim - llim, [d, n-1]); |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
54 |
702b998698ea
implement ppder, ppint, ppjmups
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
55 endfunction |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
56 |