bugGNU Octave - Bugs: bug #30521, Error in diag function for complex...

 
 

bug #30521: Error in diag function for complex numbers

Submitter:  Jaime Ferrer <ferrer>
Submitted:  Thu 22 Jul 2010 04:12:25 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  highegg
Originator Name:  Open/Closed:  * Closed
Release:  * 3.2.2 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 23 Jul 2010 06:38:10 AM UTC, comment #2: 

The first part actually uncovers another bug and only because of that it seems to work. I've fixed both of these.
http://hg.savannah.gnu.org/hgweb/octave/rev/83896a06adaf
http://hg.savannah.gnu.org/hgweb/octave/rev/7fa044155982

thanks for reporting.

Jaroslav Hajek <highegg>
Fri 23 Jul 2010 01:05:57 AM UTC, comment #1: 

The behavior is slightly better in the development version of Octave (3.3.51) in that the first two parts work.  However, the third step is still broken.

m1 = [0.1+2i]
m2 = diag(m1)
m3 = diag(m2)

typeinfo(m1)
typeinfo(m2)
typeinfo(m3)
-------------------------
Results
m1 =    0.1000 + 2.0000i
m2 =  0.10000 + 2.00000i
m3 =  0.10000

ans = complex matrix
ans = complex scalar
ans = scalar

From the documentation, diag is designed to work on a vector to produce a matrix or on a matrix to produce a vector.  I'm guessing that there's no test to see if the input is "complex scalar" and handle that case.  At least for a scalar input, it returns a scalar output and that should probably be the default for complex inputs as well.

Rik <rik5>
Group administrator
Thu 22 Jul 2010 04:12:25 PM UTC, original submission:  

If you use diag to convert a complex vector to a diagonal complex matrix, the function crashes if the vector has dim=1
Example:
g=[0.1+2i]
h=diag(g)
hh=diag(h)

Result:
g =  0.10000 + 2.00000i
h =  0.10000
hh =  0.10000

Jaime Ferrer <ferrer>

 

(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 highegg (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by ferrer (Submitted the item)
  • -email is unavailable- added by ferrer
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-07-23 highegg StatusConfirmed Fixed
        Assigned toNone highegg
        Open/ClosedOpen Closed
    2010-07-23 rik5 StatusNone Confirmed
    2010-07-22 ferrer Carbon-Copy- Added ferrer

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code