bugGNU Octave - Bugs: bug #38445, interp1 with pchip or spline...

 
 

bug #38445: interp1 with pchip or spline options outputs column vector intead of row vector

Submitted by:  None
Submitted on:  Thu 28 Feb 2013 08:32:07 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Gyorgy HexnerOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.3
Operating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 28 Feb 2013 08:48:09 PM UTC, comment #1:

Happily, this has already been fixed on the development branch. You can get the fix by building from Mercurial sources or waiting until the next major release (3.8.0).

Rik <rik5>
Project Administrator
Thu 28 Feb 2013 08:32:07 PM UTC, original submission:

+verbatim
##
##interp1 error demo
##

x=0:0.1:2;
y=[sin(x); cos(x)]';

##call to interp1 reults in a row vector
z = interp1(x, y, 0.5)

##but a call with the option pchip results in a column vector
zp = interp1(x, y, 0.5, 'pchip')
-verbatim

problem is easily corrected by adding transpose .' operation when using pchip or spline options

--- /usr/share/octave/3.6.3/m/general/interp1.m 2012-12-01 21:46:44.000000000 +0200
+++ interp1.m 2013-02-28 19:57:56.075784320 +0200
@@ -247,10 +247,10 @@

if (ispp)
y = shiftdim (reshape (y, szy), 1);
- yi = pchip (x, y);
+ yi = pchip (x, y).';
else
y = shiftdim (y, 1);
- yi = pchip (x, y, reshape (xi, szx));
+ yi = pchip (x, y, reshape (xi, szx)).';
endif
case {"spline", "*spline"}
if (nx == 2 || starmethod)
@@ -259,10 +259,10 @@

if (ispp)
y = shiftdim (reshape (y, szy), 1);
- yi = spline (x, y);
+ yi = spline (x, y).';
else
y = shiftdim (y, 1);
- yi = spline (x, y, reshape (xi, szx));
+ yi = spline (x, y, reshape (xi, szx)).';
endif
otherwise
error ("interp1: invalid method '%s'", method);

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

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 None (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 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 28 Feb 2013 08:48:09 PM UTCrik5StatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1