[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with the octave built-in function "kron"
From: |
Stephen Montgomery-Smith |
Subject: |
Re: problem with the octave built-in function "kron" |
Date: |
Fri, 03 May 2013 11:54:22 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 |
On 05/03/2013 11:33 AM, c. wrote:
>
> On 3 May 2013, at 18:28, Stephen Montgomery-Smith <address@hidden> wrote:
>
>> Use speye instead of eye.
> Unlike Matlab, in Octave eye uses less memory than speye:
>
> ----------------------------------------------------------------
>>> a = eye (7);
>>> b = speye (7);
>>> whos a b
> Variables in the current scope:
>
> Attr Name Size Bytes Class
> ==== ==== ==== ===== =====
> a 7x7 56 double
> b 7x7 116 double
>
> Total is 56 elements using 172 bytes
> ----------------------------------------------------------------
>
> that's because Octave has a special class for diagonal matrices wich allows
> to only store the
> diagonal elements:
>
> ----------------------------------------------------------------
>>> typeinfo (a)
> ans = diagonal matrix
>>> typeinfo (b)
> ans = sparse matrix
>>>
However kron seems to treat diagonal matrices and sparse matrices
differently. Maybe kron should be rewritten to see if both of the
matrices are sparse OR diagonal. Because when I took his code and
changed eye to speye, it worked.
I should add that I tested it using a very old version of octave that
comes with ubuntu linux. Maybe this fix has already been applied in
later versions.