Sum of squares of elements along dimension dim. If dim is omitted, it defaults to 1 (column-wise sum of squares).
As a special case, if x is a vector and dim is omitted, return the sum of squares of the elements.
This function is conceptually equivalent to computing
sum (x .* conj (x), dim)but it uses less memory and avoids calling conj if x is real.