kron with a single sparse matrix- another corner case
augustm
augustmiles at yahoo.com
Fri Jan 4 09:32:44 CST 2008
Octave-3.0.0. on linux 64 bit.
I like to build finite difference operators (with several fields) from sparse
representations of derivative operators, which are then replicated with the
"kron" function.
It is perhaps natural that
kron(full, sparse) gives a sparse result.
However kron promotes to full by defaults. A trivial example creates
an empty sparse matrix and replicates twice using kron.
octave:1> j=sparse( [], [] , [], 10,10) ;
octave:2> whos j
*** local user variables:
Prot Name Size Bytes Class
==== ==== ==== ===== =====
rwd j 10x10 44 double
Total is 0 elements using 44 bytes
octave:3> jj=kron ( [1 0], j );
octave:4> whos jj
*** local user variables:
Prot Name Size Bytes Class
==== ==== ==== ===== =====
rwd jj 10x20 1600 double
Total is 200 elements using 1600 bytes
The work around is to use
jj=kron ( sparse([1 0]), j );
Note Matlab uses the suggested behaviour. This was found on porting over
a code previously run under matlab.
TM, Paris.
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the Bug-octave
mailing list