Thank you! I'll take a look at that.
On Wednesday, November 12, 2014 10:53:19 AM UTC+1, John Myles White wrote: > > Unfinished FAQ about dots: > https://github.com/JuliaLang/julia/pull/8065#issuecomment-52747406 > > -- John > > On Nov 12, 2014, at 9:14 AM, Robert DJ <[email protected] <javascript:>> > wrote: > > Thanks a lot - this really cleared some thing in my head! > > Using the dims argument as "dims..." had not occurred to me. Can you > explain how the dots work (or point to reference)? > > I realized now that the part about the C matrix was oversimplified here, > but now that I seem to have befriended the tuples it works :-) > > (That Kronecker question was stupid of me; sorry :-)) > > Thanks again! > > On Tuesday, November 11, 2014 4:31:21 PM UTC+1, David Gonzales wrote: >> >> Reworked some of the construction to be more succint: >> >> function example(dims...) >> A = [zeros(2^l*[dims...]...) for l = 0:2] >> @show A >> >> >> J = [1 3 ; 2 4] >> I = kron(J, ones(Int,2,2)) >> K = rand(4) >> B = K[I] >> @show B >> >> >> C = zeros( dims... ) >> @show C >> >> nothing >> end >> >> >> >> This is running on version 0.4-dev+1307 >> >> On Tuesday, November 11, 2014 3:19:38 PM UTC+2, Robert DJ wrote: >>> >>> 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 >>> >>> >
