bugGNU Octave - Bugs: bug #31098, Incompatible spline behaviour

 
 

bug #31098: Incompatible spline behaviour

Submitter:  Marco Caliari <caliari>
Submitted:  Wed 22 Sep 2010 07:51:43 AM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Performance
Status:  Fixed Assigned to:  None
Originator Name:  Marco Open/Closed:  * Closed
Release:  * 3.3.51 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 06 Nov 2010 05:46:53 PM UTC, comment #7: 

Pushed as changeset d17cb8a1271d

regards

Thorsten

Thorsten Meyer <tmeyier>
Fri 05 Nov 2010 08:38:09 AM UTC, comment #6: 

Fine for me. Once the patch is committed, I have another one treating the case with length(x) == 2.

Marco

Marco Caliari <caliari>
Group Member
Thu 04 Nov 2010 10:30:46 PM UTC, comment #5: 

This bug is still open, although parts of it such as the polyval improvement, have been committed.  Marco, could you validate Thorsten's final patchset?

Rik <rik5>
Group administrator
Mon 18 Oct 2010 05:18:45 PM UTC, comment #4: 

In the attached version of the patch, I have reordered the conditionals to avoid unneeded calculations in case of n == 3.

Marco, could you check, that it still does what you intended?

Thanks

Thorsten

(file #21707)

Thorsten Meyer <tmeyier>
Thu 30 Sep 2010 08:43:49 AM UTC, comment #3: 

The implementation of Horner's scheme in polyval is straightforward (see the attachment). It fixes the difference between ppval and polyval and it is much faster: on my pc, the evaluation of

polyval(rand(1,100),rand(100))

drops from 0.123 to 0.019.
Maybe I should start a new item.

Marco

(file #21579)

Marco Caliari <caliari>
Group Member
Thu 30 Sep 2010 07:21:22 AM UTC, comment #2: 

Dear Thorsten, please push this new attachment instead. It does the same, but the coefficients are computed explicitly.
About the difference between ppval and polyval, I see that the first uses Horner's method, while the second the Vandermonde matrix. I think the first is better.

Marco

(file #21578)

Marco Caliari <caliari>
Group Member
Wed 29 Sep 2010 08:44:58 PM UTC, comment #1: 

I like the new behaviour given by the patch especially because it gives a continuously differentiable interpolation curve also for not-equispaced x values (in the case of 3 element input vectors).

for the example below comparing with the exact fit polynomial I get the following:

pp=[21 -20 0];
polyval(pp, x) - y
ans =

   0   0   0

max(abs((yy-polyval(pp, xx))./yy./eps))
ans =  3.2670

So at least for this example the result is very accurate. (interestingly, in MATLAB the difference between the spline and the above polynomial gives exactly zero).

Also the code change only touches the behaviour of spline for 3 value input vectors as far as I can see and spline still passes its tests.

I would like to push this (attributed to Marco) if nobody objects.

Regards

Thorsten

Thorsten Meyer <tmeyier>
Wed 22 Sep 2010 07:51:43 AM UTC, original submission:  

Dear all,

while trying to implement a new bicubic.m function, I encountered the following incompatible behavior with spline.m: when only three Thorsten Meyer points X (and three values Y) are given, a unique quadratic interpolant should be constructed. Besides compatibility, this approach improves a lot the interpolation behavior with strongly not-equispaced X points. Try the difference with (example taken by Thorsten Meyer)

x = [0,1,20];
y = x.^3;
xx = linspace(0,20,100);
yy = spline(x,y,xx);
plot(xx,yy)

with and without the enclosed patch.

Best regards,

Marco

Marco Caliari <caliari>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #21707:  spline_fix_version3.txt added by tmeyier (4KiB - text/plain)
file #21579:  polyval.m.diff added by caliari (1006B - text/x-patch)
file #21578:  spline.m.diff added by caliari (1KiB - text/x-patch)
file #21517:  spline.m.diff added by caliari (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by tmeyier (Posted a comment)
  • -email is unavailable- added by caliari (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-11-06 tmeyier StatusNone Fixed
        Open/ClosedOpen Closed
    2010-10-18 tmeyier Attached File- Added spline_fix_version3.txt, #21707
    2010-09-30 caliari Attached File- Added polyval.m.diff, #21579
    2010-09-30 caliari Attached File- Added spline.m.diff, #21578
    2010-09-22 caliari Attached File- Added spline.m.diff, #21517

    Back to the top

    Powered by Savane 3.13-cf05.
    Corresponding source code