[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #29601] bugs in cubic and spline interpolation
From: |
Thorsten Meyer |
Subject: |
[Octave-bug-tracker] [bug #29601] bugs in cubic and spline interpolation with interp2 |
Date: |
Sun, 18 Apr 2010 21:03:52 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100308 Iceweasel/3.5.8 (like Firefox/3.5.8) |
URL:
<http://savannah.gnu.org/bugs/?29601>
Summary: bugs in cubic and spline interpolation with interp2
Project: GNU Octave
Submitted by: tmeyier
Submitted on: Sun 18 Apr 2010 09:03:51 PM UTC
Category: None
Severity: 3 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name:
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: GNU/Linux
_______________________________________________________
Details:
There seem to be several bugs in the cubic and spline interpolation code of
interp2.
Reproduce with:
octave> demo interp2
[...]
interp2 example 7:
A=[13,-1,12;5,4,3;1,6,2];
x=[0,1,2]; y=[10,11,12];
xi=linspace(min(x),max(x),17);
yi=linspace(min(y),max(y),26)';
mesh(xi,yi,interp2(x,y,A,xi,yi,'cubic'));
[x,y] = meshgrid(x,y);
hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
interp2 example 7: failed
mx_el_or: nonconformant arguments (op1 is 1x17, op2 is 26x1)
error: called from:
error: /home/thorsten/hg/octave/scripts/general/interp2.m at line 352,
column 8
The offending line is
inside = !(XI < X (1) | XI > X (end) | YI < Y (1) | YI > Y (end));
To me it seems that this works only if xi and yi are meshgrid data as well.
But this case is handled in the preceding conditional. Strange... Also
strange: the bicubic function can handle the input of the above example, i.e.
mesh(xi,yi,bicubic(x,y,A,xi,yi));
works. So what is the purpose of the 2nd implementation of cubic
interpolation in interp2.m?
next failure of the demos:
[...]
interp2 example 8:
[x,y,A] = peaks(10);
x = x(1,:)'; y = y(:,1);
xi=linspace(min(x),max(x),41);
yi=linspace(min(y),max(y),41)';
mesh(xi,yi,interp2(x,y,A,xi,yi,'cubic'));
[x,y] = meshgrid(x,y);
hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
interp2 example 8: failed
interp2: input data must have `meshgrid' format
Here, the data generated by peaks are not accepted as meshgrid data due to a
floating point problem. Also, the function isgriddata (defined in interp2.m)
seems to require not only equal lines in the grid matrix but also equally
spaced values. Is that intended (or really necessary?).
and the last failure in the demos:
interp2 example 9:
A=[13,-1,12;5,4,3;1,6,2];
x=[0,1,2]; y=[10,11,12];
xi=linspace(min(x),max(x),17);
yi=linspace(min(y),max(y),26)';
mesh(xi,yi,interp2(x,y,A,xi,yi,'spline'));
[x,y] = meshgrid(x,y);
hold on; plot3(x(:),y(:),A(:),"b*"); hold off;
interp2 example 9: failed
interp2: input data must have `meshgrid' format
Looking at the sources, the __splinen__ function that actually calculates the
interpolation is called only with the first row/column of the x and y
variables, so why require meshgrids here?
regards
Thorsten
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?29601>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #29601] bugs in cubic and spline interpolation with interp2,
Thorsten Meyer <=