1 ## Copyright (C) 2000-2012 Paul Kienzle
3 ## This file is part of Octave.
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 3 of the License, or (at
8 ## your option) any later version.
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.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {[@var{x}, @var{p}, @var{n}, @var{k}, @var{d}] =} unmkpp (@var{pp})
22 ## Extract the components of a piecewise polynomial structure @var{pp}.
23 ## The components are:
30 ## Polynomial coefficients for points in sample interval. @code{@var{p}
31 ## (@var{i}, :)} contains the coefficients for the polynomial over
32 ## interval @var{i} ordered from highest to lowest. If @code{@var{d} >
33 ## 1}, @code{@var{p} (@var{r}, @var{i}, :)} contains the coefficients for
34 ## the r-th polynomial defined on interval @var{i}.
37 ## Number of polynomial pieces.
40 ## Order of the polynomial plus 1.
43 ## Number of polynomials defined for each interval.
46 ## @seealso{mkpp, ppval, spline, pchip}
49 function [x, P, n, k, d] = unmkpp (pp)
54 if (! (isstruct (pp) && isfield (pp, "form") && strcmp (pp.form, "pp")))
55 error ("unmkpp: PP must be a piecewise polynomial structure");
70 %! [x, P, n, k, d] = unmkpp (pp);
72 %! assert (P, reshape (c, [2 12]));
77 %% Test input validation
80 %!error <piecewise polynomial structure> unmkpp (1)
81 %!error <piecewise polynomial structure> unmkpp (struct ("field1", "pp"))
82 %!error <piecewise polynomial structure> unmkpp (struct ("form", "not_a_pp"))