bugGNU Octave - Bugs: bug #36099, diag(1,N,M) produces NaNs

 
 

bug #36099: diag(1,N,M) produces NaNs

Submitter:  None
Submitted:  Thu 05 Apr 2012 12:25:50 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  jordigh
Originator Name:  Twan van Laarhoven Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.6.1
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 17 Apr 2012 03:56:59 PM UTC, comment #4: 

I also checked in the following change on the stable branch so that filling will work correctly for three-arg diag function calls with cell array arguments:

http://hg.savannah.gnu.org/hgweb/octave/rev/5bb5fcffa29d

You will still have to wait for 3.8.0 to get the fixes to make diag actually return diagonal matrix objects for real and complex values in the three-arg case.  But I think 3.6.2 will at least return correctly formed full matrix objects.

John W. Eaton <jwe>
Group administrator
Thu 12 Apr 2012 08:29:46 PM UTC, comment #3: 

I checked in the following changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/e8e86ae3abbc

This fix will appear in Octave 3.8.0.

John W. Eaton <jwe>
Group administrator
Thu 05 Apr 2012 06:14:52 PM UTC, comment #2: 

This is a duplicate of bug #35946.

However, you've pointed out something else I hadn't noticed. It's not returning a diagonal matrix type. It seems the problem goes deeper than I had thought. I'm investigating it now.

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Thu 05 Apr 2012 02:16:23 PM UTC, comment #1: 

Probable cause seems to be:
+verbose+
return Array<ST> (dim_vector (1, 1), scalar).diag (k);
-verbose-
The diag() function of Array produces a dense matrix instead of DiagMatrix object. I think an MArray<ST> should be used instead.

That would also fix the issue that a dense matrix is produced, while it shouldn't be:
+verbose+
octave:1> length(diag([1,2],1e5,1e5))
ans =  100000
octave:2> length(diag([1],1e5,1e5))
error: memory exhausted or requested size too large for range of Octave's index type -- trying to return to prompt
-verbose-

This doesn't explain why Array::diag or Array::resize messes things up, though.

Twan van Laarhoven <twanvl>
Thu 05 Apr 2012 12:25:50 PM UTC, original submission:  


octave:1> OCTAVE_VERSION
ans = 3.6.1

octave:2> diag([1],3,3)
ans =

   1.00000   0.00000   0.00000
       NaN   0.00000   0.00000
   0.00000   0.00000   0.00000


Expected result is

expected> diag([1],3,3)
ans =

   1.00000   0.00000   0.00000
   0.00000   0.00000   0.00000
   0.00000   0.00000   0.00000


On a slightly related note: diag(1,3,3)(1,2)=1.0556e-316, instead of exactly 0.

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 jwe (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by twanvl (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
    2012-04-12 jwe StatusDuplicate Fixed
        Open/ClosedOpen Closed
    2012-04-05 jordigh StatusNone Duplicate
        Assigned toNone jordigh

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code