Behaviour of `norm(::Vector{<:Vector},p)`

This caught me by surprise:

norm([[1,2],[3,4]],1) == norm([1,2],2)+norm([3,4],2) # == 7.24… ≠ 10

I had expected the norm of the components to be consistent with the norm of the vector.

Is this intentional?

According to the doc here, the norm for a collection is defined as:

\|A\|_p = \left( \sum_{i=1}^n | a_i | ^p \right)^{1/p}

It’s not very clear what | a_i | means in this context, but it’s using norm(a_i,2):

julia> [norm([[1,2],[3,4]],p) == (norm([1,2],2)^p +  norm([3,4],2)^p)^(1/p) for p=1:5]
5-element Array{Bool,1}:
 true
 true
 true
 true
 true

I have no idea what the norm of a collection should be, so I don’t know if that makes sense, but I’m sure someone thought about it before writing the code.

https://github.com/JuliaLang/julia/pull/22945

Coincidental timing. @stevengj gave the answer:

@andreasnoack, we assume that T is a normed space, i.e. it must have norm(x), but it may not have norm(x, p). And once we define it that way for an arbitrary T, we should be consistent and define it that way for vectors of vectors as well.”