Hi,
here is what’s confuse me:
a=[1,3,5]
b=[2,4,6]
[a b]
3×2 Array{Int64,2}:
1 2
3 4
5 6
reshape([1 2 3 4 5 6],2,3)
2×3 Array{Int64,2}:
1 3 5
2 4 6
[[1 2], [3 4], [5 6]]
Matrix{Int64}[3]
1×2 Array{Int64,2}:
1 2
1×2 Array{Int64,2}:
3 4
1×2 Array{Int64,2}:
5 6
[[1,2], [3,4], [5,6]]
Vector{Int64}[3]
Int64[2]
1
2
Int64[2]
3
4
Int64[2]
5
6
We can see they are all different but some are the same
Array{Int64, 1} == Vector{Int64}
true
Array{Int64, 2} == Matrix{Int64}
true
Now I am trying to use permutations and I got some strange stuff:
[a b][[1 3 2]]
1×3 Array{Int64,2}:
1 5 3
[a b][[1,3,2]]
Int64[3]
1
5
3
[[1 2], [3 4], [5 6]][[1 3 2]]
1×3 Array{Array{Int64,2},2}:
[1 2] [5 6] [3 4]
[[1 2], [3 4], [5 6]][[1,3,2]]
Matrix{Int64}[3]
1×2 Array{Int64,2}:
1 2
1×2 Array{Int64,2}:
5 6
1×2 Array{Int64,2}:
3 4
[[1,2], [3,4], [5,6]][[1 3 2]]
1×3 Array{Array{Int64,1},2}:
[1, 2] [5, 6] [3, 4]
[[1,2], [3,4], [5,6]][[1,3,2]]
Vector{Int64}[3]
Int64[2]
1
2
Int64[2]
5
6
Int64[2]
3
4
So I am trying to applies the permutation [1,3,2] (switching the two last elements) and we clearly see that my way of doing it doesn’t work with the “Array type” but only with the Matrix and Vector type.
Is that a normal behavior that this way of permuting doesn’t work with the Array type when the dim is > 1 and return instead a 1dim object?
Is there a fast way to convert those type from one to another?
Is there a better way to applies permutations to Array type?
Is there any function similar the (hcat,vcat,…) but who return a Matrix or a Vector type?
thx you