bugGNU Octave - Bugs: bug #47013, bug in spline function

 
 

bug #47013: bug in spline function

Submitter:  None
Submitted:  Fri 29 Jan 2016 05:04:39 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  bug in spline function Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 20 Feb 2016 08:11:01 PM UTC, comment #5: 

I applied Lachlan's patch to stable (http://hg.savannah.gnu.org/hgweb/octave/rev/7a91166b1d09).  This should be a part of the 4.0.1 bug fix release.

Rik <rik5>
Group administrator
Tue 16 Feb 2016 12:05:42 PM UTC, comment #4: 

I can confirm that the other cases do not also need the added .'(:).  The attached patch makes that clearer by removing some unnecessary code, which took (1:n-1,:) of vectors that were already row vectors.

The change in 138~139 seems unnecessary because of automatic broadcasting.

(file #36356)

Lachlan Andrew <lachlan>
Mon 15 Feb 2016 10:05:36 PM UTC, comment #3: 

Confirming that Marco's change fixes the reported problem and attaching as a diff (just to make clear which lines were changed). I can't say whether this change is appropriate or complete.

(file #36350)

Mike Miller <mtmiller>
Group Member
Mon 01 Feb 2016 08:44:02 AM UTC, comment #2: 

I confirm the problem and I was able to fix with the only change


d = d(1:n-1,:); d = d.'(:);
c = c(1:n-1,:); c = c.'(:);
b = b(1:n-1,:); b = b.'(:);
a = a(1:n-1,:); a = a.'(:);


Can you confirm?

Marco Caliari <caliari>
Group Member
Fri 29 Jan 2016 05:09:28 PM UTC, comment #1: 

Note:

I was trying to implement the example of MatLab function spline:


x = pi*[0:.5:2];
y = [0  1  0 -1  0  1  0;
     1  0  1  0 -1  0  1];
pp = spline(x,y);
yy = ppval(pp, linspace(0,2*pi,101));


It returned an error, and I tried to fix it.

This is my fixed source code.

ChingChuan Chen

Anonymous
Fri 29 Jan 2016 05:04:39 PM UTC, original submission:  

Hi,

There is a bug in spline.

For the complete case in function `spline`, when n > 2,

(line 138 ~ 139 in source code)


      g(2:n-1,:) = (a(3:n,:) - a(2:n-1,:)) ./ h(2:n-1) - ...
                   (a(2:n-1,:) - a(1:n-2,:)) ./ h(1:n-2);


should be


      g(2:n-1,:) = (a(3:n,:) - a(2:n-1,:)) ./ h(2:n-1, idx) - ...
                   (a(2:n-1,:) - a(1:n-2,:)) ./ h(1:n-2, idx);


and (line 147~150 in source code)


      d = d(1:n-1,:);
      c = c(1:n-1,:);
      b = b(1:n-1,:);
      a = a(1:n-1,:);


should be


      d = d(1:n-1,:); d = reshape(permute(d, [2, 1]), 1, []);
      c = c(1:n-1,:); c = reshape(permute(c, [2, 1]), 1, []);
      b = b(1:n-1,:); b = reshape(permute(b, [2, 1]), 1, []);
      a = a(1:n-1,:); a = reshape(permute(a, [2, 1]), 1, []);


sincerely,

ChingChuan Chen

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #36356:  bug_47013.cset added by lachlan (2KiB - application/octet-stream)
file #36350:  spline.diff added by mtmiller (549B - text/x-diff)

 

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 lachlan (Updated the item)
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by caliari (Posted a comment)
  •  

    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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-02-20 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2016-02-16 lachlan Attached File- Added bug_47013.cset, #36356
    2016-02-15 mtmiller Attached File- Added spline.diff, #36350
        CategoryNone Octave Function
        StatusConfirmed Patch Submitted
    2016-02-01 caliari StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code