bugGNU Octave - Bugs: bug #59856, interpn with vectors: unexpected...

 
 

bug #59856: interpn with vectors: unexpected error regarding incompatible size

Submitter:  None
Submitted:  Mon 11 Jan 2021 05:16:56 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Stefan Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 6.1.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 12 Jan 2021 04:53:12 PM UTC, comment #4: 

I just added to Markus's changeset here (http://hg.savannah.gnu.org/hgweb/octave/rev/4cb0fc7ecd4b) with a 10X speed improvement.  It's not that the input validation was particularly slow (~1 millisecond on my computer), but it made use of cellfun() (which is slow then not using one of the few built-in accelerated functions) and isequal() (which is slow because it is an m-file).  I replaced with a single call to size_equal() which is a C++ function and it reduced the time to 0.1 millisecond.

I separately tested the fix and it works fine.  Marking bug as fixed and closing report.

Rik <rik5>
Group administrator
Tue 12 Jan 2021 02:50:43 PM UTC, comment #3: 

I pushed a change to stable that should fix this issue and also improve the docstring:
https://hg.savannah.gnu.org/hgweb/octave/rev/067b663529bb

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Tue 12 Jan 2021 02:18:20 PM UTC, comment #2: 

From the documentation of that function in Matlab:
https://www.mathworks.com/help/matlab/ref/interpn.html

> If Xq1,Xq2,...,Xqn are vectors of different orientations, then Xq1,Xq2,...,Xqn are treated as grid vectors in Rn.
> If Xq1,Xq2,...,Xqn are vectors of the same size and orientation, then Xq1,Xq2,...,Xqn are treated as scattered points in Rn.


Octave's documentation isn't very specific when it comes to different vector orientation. But it looks like there is an issue if the numbers of elements in the Y vectors coincide (and they have differing orientation).

The last result in comment #1 looks correct to me. The output is an array with the values at the 3 (scattered) points for which coordinates are provided.

Markus Mützel <mmuetzel>
Group administrator
Tue 12 Jan 2021 12:18:58 PM UTC, comment #1: 

I can reproduce the issue both with octave stable and octave default. This fails:


>> A2=interpn([0,1],[0,1]',[0,0.5;0.5,1],[0,0.5,1],[0,0.5,1]')
error: interpn: incompatible size of argument number 5
error: called from
    interpn at line 178 column 8


but if I add one more value to the last vector, it works:


>> A2=interpn([0,1],[0,1]',[0,0.5;0.5,1],[0,0.5,1],[0,0.5,0.7,1]')
A2 =
        0   0.2500   0.3500   0.5000
   0.2500   0.5000   0.6000   0.7500
   0.5000   0.7500   0.8500   1.0000


If I try the first example without transposing vectors, it does not produce any error, but the result is incorrect:


>> A2=interpn([0,1],[0,1],[0,0.5;0.5,1],[0,0.5,1],[0,0.5,1])
A2 =
        0   0.5000   1.0000


Fernando <tutissanalio>
Mon 11 Jan 2021 05:16:56 PM UTC, original submission:  

the attached example works fine and delivers expected results in MATLAB (2019b), but Octave fails with

error: interpn: incompatible size of argument number 5

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #50698:  testinterpn.m added by None (174B - text/plain)

 

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 mmuetzel (Posted a comment)
  • -email is unavailable- added by tutissanalio (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-12 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2021-01-12 mmuetzel StatusConfirmed Ready For Test
    2021-01-12 mmuetzel Item GroupUnexpected Error or Warning Matlab Compatibility
        StatusNone Confirmed
        Operating SystemMicrosoft Windows Any
    2021-01-11 None Attached File- Added testinterpn.m, #50698

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code