bugGNU Octave - Bugs: bug #33301, rand() and orth() not fully MatLab...

 
 

bug #33301: rand() and orth() not fully MatLab compatible

Submitter:  None
Submitted:  Thu 12 May 2011 03:14:02 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Performance
Status:  Fixed Assigned to:  jordigh
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.2.4
Operating System:  * Microsoft Windows Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 02 Aug 2011 04:49:28 PM UTC, comment #3: 

Upon some investigation, this is indeed an Octave bug. rand's docstring says it should behave like eye, and eye does treat negative dimensions as zero. orth wasn't even checking its arguments and associated functions like svd do return empty arrays, so I modified orth to do the same.

I asked around, and it seems Matlab is kinda stupid about empty matrices to orth and works the way it does out of fluke. Apparently orth(ones(0,1)) isn't an error but orth(ones(1,0)) is. I made both of those return an empty matrix in Octave, null works the same way.

Thanks. Patched in these two csets:

     http://hg.savannah.gnu.org/hgweb/octave/rev/d7a91b3fb7f9
     http://hg.savannah.gnu.org/hgweb/octave/rev/f7a8d1dafda3

These are on the default branch, so you either need to build it yourself or wait for the 3.6 release to see the fix.

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Tue 02 Aug 2011 01:38:40 PM UTC, comment #2: 

For rand() the behaviour is documented. http://www.mathworks.com/help/techdoc/ref/rand.html: "The size inputs m, n, p, ... should be nonnegative integers. Negative integers are treated as 0."

For orth(), Matlab does not document what happens if the input is empty. If you do not want to change it in octave, I would suggest to put in an explicit error() statement to make it clearer for the user.

Anonymous
Mon 01 Aug 2011 08:17:42 PM UTC, comment #1: 

I'm not sure this is a bug. It could easily be patched, but shouldn't libraries like PARAFAC be the ones to fix their code instead? If Matlab documents this usage, I'll patch it. Otherwise it seems like relying on a Matlab bug that doesn't check for correctness of the arguments.

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Thu 12 May 2011 03:14:02 PM UTC, original submission:  

In Matlab, rand() with negative dimensions yields an empty matrix, while it produces an error in Octave (both on 3.2 and 3.4 releases)

> rand(5,-2)

error: resize: Invalid resizing operation or ambiguous assignment to an out-of-bounds array element.
Matlab result: Empty matrix 5-by-0

In Matlab, orth() with an empty matrix as argument yields an empty matrix. In Octave, it produces an error.

> orth([])

error: A(I): Index exceeds matrix dimension.
error: called from:
error:   C:\Program Files\Octave\share\octave\3.2.4\m\linear-algebra\orth.m at line 57, column 6
Matlab result: empty matrix []

In a way, doing such things is useless of course, but toolboxes like PARAFAC do it, consequently are broken when run on Octave and I had to debug quite a while to fix it.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jordigh (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-08-02 jordigh StatusNeed Info Fixed
        Open/ClosedOpen Closed
    2011-08-01 jordigh StatusNone Need Info
        Assigned toNone jordigh

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code