annotate scripts/polynomial/ppval.m @ 18429:90568d7fe382 stable

ppval.m: Return correctly sized output for scalar polynomial input (bug #41448). * ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
author Rik <rik@octave.org>
date Mon, 03 Feb 2014 14:25:11 -0800
parents d63878346099
children 4197fc428c7d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 17725
diff changeset
1 ## Copyright (C) 2000-2013 Paul Kienzle
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
2 ##
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
4 ##
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
9 ##
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
14 ##
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
18
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
5831
b0d4ff99a0c5 [project @ 2006-05-26 21:06:00 by jwe]
jwe
parents: 5824
diff changeset
20 ## @deftypefn {Function File} {@var{yi} =} ppval (@var{pp}, @var{xi})
14104
614505385171 doc: Overhaul docstrings for polynomial functions.
Rik <octave@nomad.inbox5.com>
parents: 13258
diff changeset
21 ## Evaluate the piecewise polynomial structure @var{pp} at the points @var{xi}.
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
22 ## If @var{pp} describes a scalar polynomial function, the result is an
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
23 ## array of the same shape as @var{xi}.
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
24 ## Otherwise, the size of the result is @code{[pp.dim, length(@var{xi})]} if
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
25 ## @var{xi} is a vector, or @code{[pp.dim, size(@var{xi})]} if it is a
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
26 ## multi-dimensional array.
14104
614505385171 doc: Overhaul docstrings for polynomial functions.
Rik <octave@nomad.inbox5.com>
parents: 13258
diff changeset
27 ## @seealso{mkpp, unmkpp, spline, pchip}
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11536
diff changeset
28 ## @end deftypefn
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
29
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
30 function yi = ppval (pp, xi)
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
31
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
32 if (nargin != 2)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 6014
diff changeset
33 print_usage ();
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
34 endif
18429
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
35 if (! (isstruct (pp) && isfield (pp, "form") && strcmp (pp.form, "pp")))
13258
be74491c20e8 Correct typo in input validation of polynomial functions (Bug #33252)
Rik <octave@nomad.inbox5.com>
parents: 13176
diff changeset
36 error ("ppval: first argument must be a pp-form structure");
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
37 endif
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
38
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
39 ## Extract info.
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
40 [x, P, n, k, d] = unmkpp (pp);
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
41
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
42 ## dimension checks
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
43 sxi = size (xi);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
44 if (isvector (xi))
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
45 xi = xi(:).';
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
46 endif
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
47
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
48 nd = length (d);
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
49
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
50 ## Determine intervals.
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
51 xn = numel (xi);
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
52 idx = lookup (x, xi, "lr");
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
53
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
54 P = reshape (P, [d, n * k]);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
55 P = shiftdim (P, nd);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
56 P = reshape (P, [n, k, d]);
18429
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
57 Pidx = P(idx(:), :); # 2D matrix size: x = coefs*prod(d), y = prod(sxi)
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
58
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14834
diff changeset
59 if (isvector (xi))
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
60 Pidx = reshape (Pidx, [xn, k, d]);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
61 Pidx = shiftdim (Pidx, 1);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
62 dimvec = [d, xn];
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
63 else
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
64 Pidx = reshape (Pidx, [sxi, k, d]);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
65 Pidx = shiftdim (Pidx, length (sxi));
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
66 dimvec = [d, sxi];
13176
9b8e786bbf3c maint: use specific endif, endfor tokens instead of simple end
John W. Eaton <jwe@octave.org>
parents: 13141
diff changeset
67 endif
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
68 ndv = length (dimvec);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
69
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
70 ## Offsets.
14834
619fedc6ea61 ppval.m: Small efficiency improvement in determining offsets.
Rik <octave@nomad.inbox5.com>
parents: 14828
diff changeset
71 dx = (xi - x(idx))(:)';
619fedc6ea61 ppval.m: Small efficiency improvement in determining offsets.
Rik <octave@nomad.inbox5.com>
parents: 14828
diff changeset
72 dx = repmat (dx, [prod(d), 1]);
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
73 dx = reshape (dx, dimvec);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
74 dx = shiftdim (dx, ndv - 1);
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
75
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
76 ## Use Horner scheme.
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
77 if (k > 1)
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
78 yi = shiftdim (reshape (Pidx(1,:), dimvec), ndv - 1);
17725
3f02bcf2bdcc ppval.m: ensure consistency in the shape of intermediate interpolated matrix between "nearest" and higher order methods.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17338
diff changeset
79 else
3f02bcf2bdcc ppval.m: ensure consistency in the shape of intermediate interpolated matrix between "nearest" and higher order methods.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents: 17338
diff changeset
80 yi = shiftdim (reshape (Pidx, dimvec), ndv - 1);
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
81 endif
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
82
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
83 for i = 2 : k;
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
84 yi .*= dx;
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
85 yi += shiftdim (reshape (Pidx(i,:), dimvec), ndv - 1);
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
86 endfor
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
87
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
88 ## Adjust shape.
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
89 if ((numel (xi) > 1) || (length (d) == 1))
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
90 yi = reshape (shiftdim (yi, 1), dimvec);
9768
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
91 endif
31900e17b5f5 improve Matlab compatibility & performance of ppval/mkpp and some associated funcs
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
92
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
93 if (isvector (xi) && (d == 1))
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
94 yi = reshape (yi, sxi);
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
95 elseif (isfield (pp, "orient") && strcmp (pp.orient, "first"))
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14834
diff changeset
96 yi = shiftdim (yi, nd);
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
97 endif
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
98
18429
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
99 if (d == 1)
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
100 yi = reshape (yi, sxi);
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
101 endif
13141
e81ddf9cacd5 maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 12608
diff changeset
102
5824
448f9982e7fb [project @ 2006-05-19 06:53:31 by jwe]
jwe
parents:
diff changeset
103 endfunction
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
104
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
105
14364
721a4a83cba6 test: Space out %!shared variable declaration for readability
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
106 %!shared b, c, pp, pp2, xi, abserr
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
107 %! b = 1:3;
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
108 %! c = ones (2);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
109 %! pp = mkpp (b, c);
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
110 %! abserr = 1e-14;
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
111 %! pp2 = mkpp (b, [c;c], 2);
12608
59e2460acae1 make piecewise polynomial (pp) functions more compatible
Kai Habel <kai.habel@gmx.de>
parents: 11587
diff changeset
112 %! xi = [1.1 1.3 1.9 2.1];
18429
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
113 %!
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
114 %!assert (ppval (pp, 1.1), 1.1, abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
115 %!assert (ppval (pp, 2.1), 1.1, abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
116 %!assert (ppval (pp, xi), [1.1 1.3 1.9 1.1], abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
117 %!assert (ppval (pp, xi.'), [1.1 1.3 1.9 1.1].', abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
118 %!assert (ppval (pp2, 1.1), [1.1;1.1], abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
119 %!assert (ppval (pp2, 2.1), [1.1;1.1], abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
120 %!assert (ppval (pp2, xi), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
121 %!assert (ppval (pp2, xi'), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr)
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
122 %!assert (size (ppval (pp2, [xi;xi])), [2 2 4])
18429
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
123 %!assert (ppval (mkpp([0 1],1), magic (3)), ones(3,3))
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
124 %!
14828
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
125 %!test
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
126 %! breaks = [0, 1, 2, 3];
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
127 %! coefs = rand (6, 4);
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
128 %! pp = mkpp (breaks, coefs, 2);
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
129 %! ret = zeros (2, 4, 2);
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
130 %! ret(:,:,1) = ppval (pp, breaks');
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
131 %! ret(:,:,2) = ppval (pp, breaks');
e437bacb3ef6 Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
Marco Caliari <marco.caliari@univr.it>
parents: 14364
diff changeset
132 %! assert (ppval (pp, [breaks',breaks']), ret)
17338
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 17336
diff changeset
133
18429
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
134 %% Test input validation
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
135 %!error ppval ()
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
136 %!error ppval (1)
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
137 %!error ppval (1,2,3)
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
138 %!error <argument must be a pp-form structure> ppval (1,2)
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
139 %!error <argument must be a pp-form structure> ppval (struct ("a", 1), 2)
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
140 %!error <argument must be a pp-form structure> ppval (struct ("form", "ab"), 2)
90568d7fe382 ppval.m: Return correctly sized output for scalar polynomial input (bug #41448).
Rik <rik@octave.org>
parents: 17744
diff changeset
141