Confusing Results When Comparing Arrays in Julia

This behaviour is documented:

If all the indices are scalars, then the result X is a single element from the array A. Otherwise, X is an array with the same number of dimensions as the sum of the dimensionalities of all the indices.
Single- and multi-dimensional Arrays · The Julia Language

That is, if you index with a scalar, its dimensionality is zero. So A[1, :] has dimension 1. That is, it is a Vector{Int} which is an alias for Array{Int, 1}. Now, u is also a Vector{Int}, whereas v is a Matrix{Int} (which is an alias for Array{Int, 2}).

There is no concept of row or column vectors in julia. There are arrays of various sizes. The one-dimensional array is called a Vector, the two-dimensional is called a Matrix. In many linear algebra settings, a Vector is treated as a n x 1 matrix, or a column vector. So that e.g. collect(transpose(u)) is a 1 x 3 matrix.

2 Likes