|
|
Reducing memory requirements for tiled matrices
Posted:
Nov 14, 2012 2:49 AM
|
|
"Roger Stafford" wrote in message <k7urig$875$1@newscl01ah.mathworks.com>... > ....... Presumably you could use a set of for-loops to directly generate this result and thereby avoid having to store intermediate 'kron' products, ...... - - - - - - - - - The following code uses the for-loop method I mentioned earlier. It will compute your element-by-element product of the two double kronecker products you described using your definitions of N0, Nf, Ns, Mf, and Ms for the sizes involved. The only matrix it creates is 'K' containing the desired result, so it will save you memory space, but at the cost of slower execution than with the use of the 'kron' function.
K = zeros(Nf*Ns*N0,Mf*Ms); for i1 = 1:Nf*N0 for j1 = 1:Mf t = F(i1,j1); for i2 = 1:Ns for j2 = 1:Ms K(i2+Ns*(i1-1),j1+Mf*(j2-1)) = t; end end end end for i1 = 1:Ns*N0 for j1 = 1:Ms t = S(i1,j1); for i2 = 1:Nf for j2 = 1:Mf K(i1+Ns*N0*(i2-1),j2+Mf*(j1-1)) = ... K(i1+Ns*N0*(i2-1),j2+Mf*(j1-1))*t; end end end end
Roger Stafford
|
|