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

 
 

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

Submitted by:  None
Submitted on:  Thu 12 May 2011 03:14:02 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Performance
Status: FixedAssigned to: Jordi Gutiérrez Hermoso <jordigh>
Originator Name: Originator Email: -unavailable-
Open/Closed: ClosedRelease: 3.2.4
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project AdministratorIn charge of this item.
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>
Project AdministratorIn charge of this item.
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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jordigh (Posted a comment)
  • -unavailable- added by None (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 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 02 Aug 2011 04:49:48 PM UTCjordighStatusNeed Info=>Fixed
      Open/ClosedOpen=>Closed
    Mon 01 Aug 2011 08:17:42 PM UTCjordighStatusNone=>Need Info
      Assigned toNone=>jordigh

    Back to the top


    Powered by Savane 3.1-cleanup1