bugGNU Octave - Bugs: bug #62184, ind2sub behavior different in...

 
 

bug #62184: ind2sub behavior different in matlab and octave

Submitter:  None
Submitted:  Mon 14 Mar 2022 10:39:36 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  ajohansson Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 05 Apr 2022 10:27:28 PM UTC, comment #3: 

I used jwe's diff to create a cset which I checked in under his name here: http://hg.savannah.gnu.org/hgweb/octave/rev/972959edc3ff.

Marking bug as fixed and closing report.

Rik <rik5>
Group administrator
Sun 27 Mar 2022 02:43:58 PM UTC, comment #2: 

I haven't tested it much, but the attached change might be a starting point.

(file #53016)

John W. Eaton <jwe>
Group administrator
Sat 26 Mar 2022 10:13:34 PM UTC, comment #1: 

This turns out to be way harder to fix than it looks.  The code is in liboctave/Array/Array-util.cc in function ind2sub (line 619).

The check for index out of range is done early, but eliminating the test is not enough to get the function to be Matlab compatible.  The dimension vector needs to be temporarily re-sized which I can't figure out how to do in C++.

Rik <rik5>
Group administrator
Mon 14 Mar 2022 10:39:36 PM UTC, original submission:  

ind2sub behaves differently in matlab and octave.

Matlab R2021b allows this:


>> ind2sub(1, [1 2])
ans =
     1     2


octave 6.4 gives an error:


octave:1> ind2sub(1, [1 2])
error: ind2sub: index out of range


This issue is discussed at https://octave.discourse.group/t/ind2sub-behavior-different-in-matlab-and-octave/2373

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #53016:  ind2sub-diffs.txt added by jwe (2KiB - 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 jwe (Updated the item)
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-04-05 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2022-03-27 jwe Attached File- Added ind2sub-diffs.txt, #53016
    2022-03-26 rik5 StatusNone Confirmed
        Release6.4.0 dev

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code