Mercurial > hg > octave-lyh
annotate scripts/polynomial/unmkpp.m @ 9768:31900e17b5f5
improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 02 Nov 2009 14:04:06 +0100 |
parents | 16f53d29049f |
children | 693e22af08ae |
rev | line source |
---|---|
9245 | 1 ## Copyright (C) 2000, 2006, 2007, 2008, 2009 Paul Kienzle |
5824 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
5824 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
5824 | 18 |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {[@var{x}, @var{p}, @var{n}, @var{k}, @var{d}] =} unmkpp (@var{pp}) | |
21 ## | |
22 ## Extract the components of a piece-wise polynomial structure @var{pp}. | |
23 ## These are as follows: | |
24 ## | |
25 ## @table @asis | |
26 ## @item @var{x} | |
8347
fa78cb8d8a5c
corrections for typos
Brian Gough<bjg@network-theory.co.uk>
parents:
7017
diff
changeset
|
27 ## Sample points. |
5824 | 28 ## @item @var{p} |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
29 ## Polynomial coefficients for points in sample interval. @code{@var{p} |
5824 | 30 ## (@var{i}, :)} contains the coefficients for the polynomial over |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
31 ## interval @var{i} ordered from highest to lowest. If @code{@var{d} > |
7001 | 32 ## 1}, @code{@var{p} (@var{r}, @var{i}, :)} contains the coefficients for |
9768
31900e17b5f5
improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
33 ## the r-th polynomial defined on interval @var{i}. |
5824 | 34 ## @item @var{n} |
35 ## Number of polynomial pieces. | |
36 ## @item @var{k} | |
37 ## Order of the polynomial plus 1. | |
38 ## @item @var{d} | |
39 ## Number of polynomials defined for each interval. | |
40 ## @end table | |
41 ## | |
42 ## @seealso{mkpp, ppval, spline} | |
43 ## @end deftypefn | |
44 | |
45 function [x, P, n, k, d] = unmkpp (pp) | |
46 if (nargin == 0) | |
6046 | 47 print_usage (); |
5824 | 48 endif |
49 if (! isstruct (pp)) | |
50 error ("unmkpp: expecting piecewise polynomial structure"); | |
51 endif | |
52 x = pp.x; | |
53 P = pp.P; | |
9768
31900e17b5f5
improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
54 n = size (P, 2); |
31900e17b5f5
improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
55 k = size (P, 3); |
5824 | 56 d = pp.d; |
9768
31900e17b5f5
improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
57 if (d == 1) |
31900e17b5f5
improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
58 P = reshape (P, n, k); |
31900e17b5f5
improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents:
9245
diff
changeset
|
59 endif |
5824 | 60 endfunction |