Hi!
How do I index vector vector of arrays?
Of course, I can easily index them in some cases. But I don’t know how to index them in specific cases.
For example,
A = Vector{Vector{Matrix{Int64}}}()
for i = 1:10
push!(A, i*[[1 2 ; 3 4], [5 6; 7 8]])
end
julia> A
10-element Vector{Vector{Matrix{Int64}}}:
[[1 2; 3 4], [5 6; 7 8]]
[[2 4; 6 8], [10 12; 14 16]]
[[3 6; 9 12], [15 18; 21 24]]
[[4 8; 12 16], [20 24; 28 32]]
⋮
[[8 16; 24 32], [40 48; 56 64]]
[[9 18; 27 36], [45 54; 63 72]]
[[10 20; 30 40], [50 60; 70 80]]
To index the following vector of matrix,
10-element Vector{Matrix{Int64}}:
[1 2; 3 4]
[2 4; 6 8]
[3 6; 9 12]
[4 8; 12 16]
⋮
[8 16; 24 32]
[9 18; 27 36]
[10 20; 30 40]
I did try the following way.
A[:][1]
->
2-element Vector{Matrix{Int64}}:
[1 2; 3 4]
[5 6; 7 8]
A[:,1]
->
10-element Vector{Vector{Matrix{Int64}}}:
[[1 2; 3 4], [5 6; 7 8]]
[[2 4; 6 8], [10 12; 14 16]]
[[3 6; 9 12], [15 18; 21 24]]
[[4 8; 12 16], [20 24; 28 32]]
⋮
[[8 16; 24 32], [40 48; 56 64]]
[[9 18; 27 36], [45 54; 63 72]]
[[10 20; 30 40], [50 60; 70 80]]
reduce(hcat,A)[1,:]
->
10-element Vector{Matrix{Int64}}:
[1 2; 3 4]
[2 4; 6 8]
[3 6; 9 12]
[4 8; 12 16]
⋮
[8 16; 24 32]
[9 18; 27 36]
[10 20; 30 40]
reduce(hcat,A)[1,:] is successful. But if the object is vector of vector of vector of … of vector, then this way is maybe too complicate to index the object.
Is there an easy way to index such a object?