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

 
 

bug #31098: Incompatible spline behaviour

Submitted by:  Marco Caliari <caliari>
Submitted on:  Wed 22 Sep 2010 07:51:43 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Performance
Status: FixedAssigned to: None
Originator Name: MarcoOpen/Closed: Closed
Release: 3.3.51Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission 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>
Project 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>
Project 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>
Project 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>
Project 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>
Project Member

 

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

Attach File(s):
   
   
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
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by tmeyier (Posted a comment)
  • -unavailable- added by caliari (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 06 Nov 2010 05:46:53 PM UTCtmeyierStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Mon 18 Oct 2010 05:18:45 PM UTCtmeyierAttached File-=>Added spline_fix_version3.txt, #21707
    Thu 30 Sep 2010 08:43:49 AM UTCcaliariAttached File-=>Added polyval.m.diff, #21579
    Thu 30 Sep 2010 07:21:22 AM UTCcaliariAttached File-=>Added spline.m.diff, #21578
    Wed 22 Sep 2010 07:51:43 AM UTCcaliariAttached File-=>Added spline.m.diff, #21517

    Back to the top


    Powered by Savane 3.1-cleanup1