Mercurial > hg > octave-nkf
changeset 14828:e437bacb3ef6
Fix ppval when pp.dim > 1 and xi is an array (bug #36665)
* ppval.m: Correctly evaluate a piecewise polynomial structure when
pp.dim > 1 and xi is a multi-dimensional array. Added a test for this bug.
author | Marco Caliari <marco.caliari@univr.it> |
---|---|
date | Mon, 02 Jul 2012 10:26:19 +0200 |
parents | 93e5ade3fda4 |
children | 619fedc6ea61 |
files | scripts/polynomial/ppval.m |
diffstat | 1 files changed, 10 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/polynomial/ppval.m +++ b/scripts/polynomial/ppval.m @@ -68,8 +68,8 @@ ndv = length (dimvec); ## Offsets. - dx = (xi - x(idx)); - dx = repmat (dx, [prod(d), 1]); + dx = (xi - x(idx))(:); + dx = repmat (dx, [1, prod(d)])'; dx = reshape (dx, dimvec); dx = shiftdim (dx, ndv - 1); @@ -119,4 +119,11 @@ %!assert (ppval (pp2, xi), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr) %!assert (ppval (pp2, xi'), [1.1 1.3 1.9 1.1;1.1 1.3 1.9 1.1], abserr) %!assert (size (ppval (pp2, [xi;xi])), [2 2 4]) - +%!test +%! breaks = [0, 1, 2, 3]; +%! coefs = rand (6, 4); +%! pp = mkpp (breaks, coefs, 2); +%! ret = zeros (2, 4, 2); +%! ret(:,:,1) = ppval (pp, breaks'); +%! ret(:,:,2) = ppval (pp, breaks'); +%! assert (ppval (pp, [breaks',breaks']), ret)