Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Reducing memory requirements for tiled matrices
Replies: 5   Last Post: Nov 14, 2012 11:27 AM

 Messages: [ Previous | Next ]
 Roger Stafford Posts: 5,929 Registered: 12/7/04
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

Date Subject Author
11/13/12 Harry Commin
11/13/12 Roger Stafford
11/14/12 Roger Stafford
11/14/12 Harry Commin
11/14/12 Steven Lord
11/14/12 Roger Stafford