# HG changeset patch # User Rik # Date 1384970708 28800 # Node ID 3232956a6081d1d1c94f43f539f84bef39b2c8e6 # Parent 1d58abc740c0639b912f377d859d261a86621213 spline.m: Fix problem with transposed "complete" inputs (bug #40584). * scripts/polynomial/spline.m: Orient input vector correctly for not-a-knot (n) and "complete (n+2) inputs. Add %!tests to check behavior. diff -r 1d58abc740c0 -r 3232956a6081 scripts/polynomial/spline.m --- a/scripts/polynomial/spline.m Wed Nov 20 09:15:56 2013 -0800 +++ b/scripts/polynomial/spline.m Wed Nov 20 10:05:08 2013 -0800 @@ -83,12 +83,12 @@ ## Check the size and shape of y ndy = ndims (y); szy = size (y); - if (ndy == 2 && (szy(1) == n || szy(2) == n)) - if (szy(2) == n) + if (ndy == 2 && (any (szy == n) || any (szy == n+2))) + if (szy(2) == n || szy(2) == n+2) a = y.'; else a = y; - szy = fliplr (szy); + szy = szy([2 1]); endif else a = shiftdim (reshape (y, [prod(szy(1:end-1)), szy(end)]), 1); @@ -283,18 +283,24 @@ %! x = [2,1]; %! y = [1,2,3,4]; %! pp = spline (x,y); +%! pp2 = spline (x', y'); %! [x,P] = unmkpp (pp); %! assert (P, [7,-9,1,3], abserr); +%! assert (pp2, pp); %!test %! x = [0,1,2]; %! y = [0,0,1,0,0]; %! pp = spline (x,y); +%! pp2 = spline (x', y'); %! [x,P] = unmkpp (pp); %! assert (P, [-2,3,0,0;2,-3,0,1], abserr); +%! assert (pp2, pp); %!test %! x = [0,1,2,3]; %! y = [0,0,1,1,0,0]; %! pp = spline (x,y); +%! pp2 = spline (x', y'); %! [x,P] = unmkpp (pp); %! assert (P, [-1,2,0,0;0,-1,1,1;1,-1,-1,1], abserr); +%! assert (pp2, pp);