|
From: | David Bateman |
Subject: | Re: Kronecker products as objects? |
Date: | Wed, 24 Mar 2010 19:51:45 +0100 |
User-agent: | Mozilla-Thunderbird 2.0.0.22 (X11/20090706) |
Soren Hauberg wrote:
function retval = double (KP) if (isempty (KP.full)) KP.full = kron (KP.A, KP.B); endif retval = KP.full; endfunctionthen use the double function in the places you used full in your code. In that way your knonprod object can be pretty much agnostics whether its treating full or sparse matrices internally.But then I can't handle complex matrices, right? I am unsure about the 'double'. Is it supposed to convert back into either a sparse or a full matrix or should it just ensure that that the matrices are double, i.e.
Complex values are of the class "double". You don't loose the complexity of a value with the "double" method. You need to use "real" for that ;-) ...
Yes that will work fine if you don't want to cache the values and it should replace your use of "full" in various places.. The full function is to return a full rather than sparse matrix.function retval = double (KP) retval = kronprod (double (KP.A), double (KP.B)); endfunction
D.
[Prev in Thread] | Current Thread | [Next in Thread] |