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

Submitter:  None
Submitted:  Thu 28 Feb 2013 08:32:07 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Gyorgy Hexner Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.3
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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>
Group 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 Files:
   
   
Comment:
   

No files currently attached

 

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

    Date Changed by Updated Field Previous Value => Replaced by
    2013-02-28 rik5 StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code