bugGNU Octave - Bugs: bug #36932, linear indexing assignment removes...

 
 

bug #36932: linear indexing assignment removes Diagonal property from matrix

Submitter:  Rik <rik5>
Submitted:  Mon 23 Jul 2012 08:35:13 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Assigned to:  jordigh
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 17 Nov 2015 05:29:15 AM UTC, comment #2: 

This is 3.5 years old, but I just fixed it with this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/cd1bd06974d8).  Closing report.

Rik <rik5>
Group administrator
Mon 23 Jul 2012 10:09:25 PM UTC, comment #1: 

The complex->real thing seems to be a red herring. The problem is the linear indexing:


octave:1> a = diag([1 2 3]); a(1) = 5
a =

   5   0   0
   0   2   0
   0   0   3

octave:2> a = diag([1 2 3]); a(1,1) = 5
a =

Diagonal Matrix

   5   0   0
   0   2   0
   0   0   3


The offending code is here:

http://hg.savannah.gnu.org/hgweb/octave/file/74c7265c057a/src/ov-base-diag.cc#l118

As you can see, it's checking for indexing of type a(i,i) to preserve diagonality, but it's not checking any other possible indexing types that could make sense (e.g. a(i,i,1) or a(i) where i = n^2).

I think I can handle this problem myself.

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Mon 23 Jul 2012 08:35:13 PM UTC, original submission:  

As a result of narrowing, the Diagonal property of a matrix is lost and the result is cast to a full matrix which unnecessarily increases storage requirements.

Example code:


a = diag ([1+i 2 3])
a =

Diagonal Matrix

   1 + 1i        0        0
        0   2 + 0i        0
        0        0   3 + 0i

octave:8> whos a
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
   c    a           3x3                         48  double

Total is 9 elements using 48 bytes

a(1) = 1
a =

   1   0   0
   0   2   0
   0   0   3

octave:12> whos a
Variables in the current scope:

   Attr Name        Size                     Bytes  Class
   ==== ====        ====                     =====  =====
        a           3x3                         72  double

Total is 9 elements using 72 bytes


Rik <rik5>
Group administrator

 

(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 rik5 (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-11-17 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2012-07-23 jordigh Summarylinear indexing assignment Diagonal property from matrix linear indexing assignment removes Diagonal property from matrix
    2012-07-23 jordigh StatusNone Confirmed
        Assigned toNone jordigh
        SummaryAutomatic complex-&gt;real narrowing removes Diagonal property from matrix linear indexing assignment Diagonal property from matrix

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code