Dot product and norm for arrays of arrays


#1

Hi all,

I just realized that one can use dot and norm (and vecdot and vecnorm) on objects of type Array{Array{T, N}, 1}. However, their behaviour it’s not clear to me, and I would like to know whether it’s the intended one. For example, in Julia 0.6:

x = [[1.0 2.0 3.0; 4.0 5.0 6.0], [1.0 2.0 3.0]];
norm(x) # = 10.217762598840018
# which one may think is equivalent to
sqrt(dot(x,x)) # = 10.246950765959598, so no
# and in fact
sqrt(norm(x[1])^2+norm(x[2])^2) == norm(x) # = true

So, apparently norm is broadcasted to the two elements of the array, resulting in a matrix norm for the first element, and a vector norm for the second. The two results are then norm-ed. So maybe:

vecnorm(x) == sqrt(dot(x,x)) # = false. What?
vecnorm(x) # = 10.217762598840018, like norm(x)

Is any of this behaviour explained in the documentation?