bugGNU Octave - Bugs: bug #47298, zeros() with empty dimensions but...

 
 

bug #47298: zeros() with empty dimensions but non zero rows or columns does not fail

Submitted by:  Carnë Draug <carandraug>
Submitted on:  Sun 28 Feb 2016 06:07:03 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedAssigned to: Carnë Draug <carandraug>
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.

 

Sat 05 Mar 2016 02:40:19 AM UTC, comment #4:

Thank you Markus for the heads up on what Matlab does in this cases.

I pushed http://hg.savannah.gnu.org/hgweb/octave/rev/120bb822c6f4 which fixes this, keeping Matlab compatibility but also in accordance with Octave's acceptance of any vector.

Carnë Draug <carandraug>
Project MemberIn charge of this item.
Sat 05 Mar 2016 01:43:10 AM UTC, comment #3:

Hmm... I see the logic behind supporting a 1x0 vector by Matlab. Because they require it to be a row vector. But Octave will accept both a row and column vector so by the same logic it should accept both a 1x0 and a 0x1 vector.

I will rework on this patch.

Carnë Draug <carandraug>
Project MemberIn charge of this item.
Thu 03 Mar 2016 02:50:28 PM UTC, comment #2:

For what it's worth:
Matlab R2012a does not fail on

but it produces an empty matrix of size 0x0.
This seems to be the only case where you can pass empty matrices to zeros(), ones(), Inf() or NaN() without provoking an error.

I am not sure whether this is an error in Matlab or whether its behaviour is correct. After all, the documentation [1] states that the input argument sz is the "Size of each dimension, specified as a row vector of integer values." You could argue that a 1x0 vector was a row vector. Thus, a matrix with "no dimensions" should be returned...

[1] https://de.mathworks.com/help/matlab/ref/zeros.html

The function nan() behaves the same as described in #comment 0 and is not touched with your patch. Maybe you could fix it, too?

Markus Mützel <mmuetzel>
Project Member
Sun 28 Feb 2016 07:10:20 PM UTC, comment #1:

I have attached a cset that fixes this.

(file #36500)

Carnë Draug <carandraug>
Project MemberIn charge of this item.
Sun 28 Feb 2016 06:07:03 PM UTC, original submission:

Check for the dimensions for zeros() seems a bit odd.

It should have errored in all of the examples above.

Carnë Draug <carandraug>
Project MemberIn charge of this item.

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #36500:  fill_matrix_empty_array.cset added by carandraug (2KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mmuetzel (Posted a comment)
  • -unavailable- added by carandraug (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
    Sat 05 Mar 2016 02:40:19 AM UTCcarandraugStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Sun 28 Feb 2016 07:10:20 PM UTCcarandraugAttached File-=>Added fill_matrix_empty_array.cset, #36500

    Back to the top


    Powered by Savane 3.1-cleanup1