Hi
I've run into some array issues that I suspect are quite easy, but I
haven't found answers on Uncle Google or in the docs.
In the example below I would like to do the following (more elegant):
- Create the array of arrays A where the size of the inner arrays are
determined by the input 'dims...'.
Creating the D array seems cumbersome.
- Create the array B with a block structure defined by the array I.
The Kronecker product is automatically a Float even though both factors are
Int's and Float doesn't seem to work as indices; is there a better way to
circumvent this than ifloor?
- repmath/reshape seems to like tuples, but not arrays as the new
dimensions.
Is there a way to convert between tuples and arrays?
Thanks,
Robert
function example(dims...)
D = Array(Int, 2)
D[1] = dims[1]
D[2] = dims[2]
A = [zeros(2^l*D[1], 2^l*D[2]) for l = 0:2]
# Not working:
#A = [zeros(2^l*dims) for l = 0:2]
J = [1 3 ; 2 4]
I = ifloor(kron(J, ones(2,2)))
K = rand(4)
B = K[I]
C = zeros( prod(D) )
C = reshape(C, dims)
# Not working:
#C = reshape(C, D)
end