bugGNU Octave - Bugs: bug #35860, incorrect interp1 with array first...

 
 

bug #35860: incorrect interp1 with array first argument

Submitted by:  None
Submitted on:  Fri 16 Mar 2012 06:22:04 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: Jordi Gutiérrez Hermoso <jordigh>
Originator Name: DavidOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.6.1
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Fri 26 Jul 2013 05:02:23 AM UTC, comment #4:

I fixed this error with the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/c8586e6fc60d

Mike Miller <mtmiller>
Project Administrator
Fri 16 Mar 2012 10:04:00 PM UTC, comment #3:

When the first argument is a vector, it must be a column vector in order to make sense at all. Indeed, interp1((0:4)', 2.5) does not give an error.
To make it pass all the tests, I suggest putting in

if isvector(y)
y=y(:);
end

before the
x=1:size(y,1);
statement. Not pretty, but it gets the job done.

David Nijkerk <davidn>
Fri 16 Mar 2012 12:10:03 PM UTC, comment #2:

Perhaps "length (y)" instead of "numel (y)", but I'm not certain.

Jordi Gutiérrez Hermoso <jordigh>
Project AdministratorIn charge of this item.
Fri 16 Mar 2012 12:07:26 PM UTC, comment #1:

Thanks for reporting.

Your proposed change breaks one of the existing tests:

Do you have a suggestion?

Jordi Gutiérrez Hermoso <jordigh>
Project AdministratorIn charge of this item.
Fri 16 Mar 2012 06:22:04 AM UTC, original submission:

Using interp1 in the following way
YI = interp1 (Y, XI)
with the default, linear interpolation,
gives an error when Y is an array (with more than one dimension).

Example:
========
octave:2> data=rand(3,2)
data =

0.69133 0.95758
0.34407 0.70075
0.23343 0.35873

octave:3> interp1(data,[1 2 3])
error: interp1: quotient: nonconformant arguments (op1 is 2x2, op2 is 5x2)
error: evaluating argument list element number 1
error: called from:
error: C:\Octave\Octave3.6.1_gcc4.6.2\share\octave\3.6.1\m\general\interp1.m at line 213, column 11
=========
End of example.

I suppose there is an error in the interp1.m script,

if (isempty (xi) && firstnumeric && ! ispp)
xi = y;
y = x;
x = 1:numel(y);
endif

should actually read

if (isempty (xi) && firstnumeric && ! ispp)
xi = y;
y = x;
x = 1:size(y,1);
endif

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 mtmiller (Posted a comment)
  • -unavailable- added by davidn (Posted a comment)
  • -unavailable- added by jordigh (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 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 26 Jul 2013 05:02:23 AM UTCmtmillerStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
      Operating SystemMicrosoft Windows=>Any
    Fri 16 Mar 2012 12:10:33 PM UTCjordighAssigned toNone=>jordigh
    Fri 16 Mar 2012 12:07:26 PM UTCjordighStatusNone=>In Progress

    Back to the top


    Powered by Savane 3.1-cleanup1