bugGNU Octave - Bugs: bug #49506, interp2(...,'linear') gives...

 
 

bug #49506: interp2(...,'linear') gives incorrect result

Submitted by:  Muhali <muhali>
Submitted on:  Tue 01 Nov 2016 02:04:45 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: FixedAssigned to: None
Originator Name: Open/Closed: Closed
Release: devOperating 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)

Mon 07 Nov 2016 12:44:03 AM UTC, comment #7:

I checked something in along the lines that Nir suggested (http://hg.savannah.gnu.org/hgweb/octave/rev/125391edc71b). Fixed, closing report.

Rik <rik5>
Project Administrator
Sun 06 Nov 2016 11:47:22 AM UTC, comment #6:

Senseless undocumented Matlab behavior.

As a work-around, we can replace line 228 in scripts/general/interp2.m

with

Then we can check that

Nir Krakauer <nir_krakauer>
Sun 06 Nov 2016 02:57:35 AM UTC, comment #5:

I asked on the Octave Maintainer's list and the behavior of indexing with a vector is required for Matlab compatibility.

Rik <rik5>
Project Administrator
Wed 02 Nov 2016 03:28:35 PM UTC, comment #4:

Is this something we are following for Matlab compatibility? For scalars or matrices, the resulting value after indexing has the size of the idx vector. It is only when a vector is indexed by another vector that the result follows the original vector's size.

Matlab test

Rik <rik5>
Project Administrator
Wed 02 Nov 2016 12:40:37 PM UTC, comment #3:

The problem is caused by how vector indexing is working in Octave. If a is 2x1, while idx is 1x2, is there any reason that a(idx) is 2x1? Seems like it should be 1x2. (If a was a matrix instead of a vector, a(idx) would indeed be 1x2.)

Nir Krakauer <nir_krakauer>
Tue 01 Nov 2016 09:38:08 PM UTC, comment #2:

The problem is in the final line of the "linear" method.

At this point the factors a, b, c, d are all column vectors (2x1), while Xsc and Ysc are row vectors (1x2). The multiplication steps broadcast automatically to create 2x2 final matrices.

I don't know what the best way to resolve this is.

Rik <rik5>
Project Administrator
Tue 01 Nov 2016 06:04:27 PM UTC, comment #1:

Confirmed. Maybe something with automatic broadcasting is going on.

Rik <rik5>
Project Administrator
Tue 01 Nov 2016 02:04:45 PM UTC, original submission:

try

and you get

ans =

3 4
3 4

With any other method one gets the correct result [3 4].

Muhali <muhali>

 

(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 nir_krakauer (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by muhali (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 07 Nov 2016 12:44:03 AM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Tue 01 Nov 2016 06:04:27 PM UTCrik5StatusNone=>Confirmed

    Back to the top


    Powered by Savane 3.1-cleanup1