bugGNU Octave - Bugs: bug #45467, Assigning empty matrix to empty...

 
 

bug #45467: Assigning empty matrix to empty indexing slice gives dimension mismatch error

Submitter:  Lachlan Andrew <lachlan>
Submitted:  Fri 03 Jul 2015 10:35:51 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Lachlan Open/Closed:  * Closed
Release:  * 4.0.0 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 24 Jul 2015 09:42:36 PM UTC, comment #1: 

Thanks for the patch.  I added comments for version control and checked in the change under your name here (http://hg.savannah.gnu.org/hgweb/octave/rev/41d19a6ef55a).  This will be a part of the next major release, 4.2.

Rik <rik5>
Group administrator
Fri 03 Jul 2015 10:35:51 AM UTC, original submission:  

Assigning a zero-sized matrix to a zero-sized slice of a matrix should work, even if the non-zero dimensions do not match.

The snippet

z = zeros(2);
empty = [];
z([],1) = [];
z([],1) = empty;

allows the third line, but for the fourth line gives the error

A(I,J,...) = X: dimensions mismatch

In general, Matlab allows assignment of an empty slice from any empty matrix, regardless of the sizes of the non-zero dimensions.

The attached patch allows Matlab-compliant behaviour.  In order not to slow down all assignments, the special case code is not on the fast path.

Lachlan Andrew <lachlan>

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

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 jordigh (Updated the item)
  • -email is unavailable- added by lachlan (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
    2015-07-24 rik5 StatusPatch Submitted Fixed
        Open/ClosedOpen Closed
    2015-07-06 jordigh StatusNone Patch Submitted
    2015-07-04 rik5 Carbon-CopyRemoved 72865 -
    2015-07-04 rik5 SummaryAssigning empty matrix to empty range gives error Assigning empty matrix to empty indexing slice gives dimension mismatch error
    2015-07-04 rik5 Item GroupIncorrect Result Matlab Compatibility
    2015-07-03 lachlan Attached File- Added empty_assignment_patch.txt, #34370

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code