Description
Following this discussion on julia-users: https://groups.google.com/forum/#!topic/julia-users/V-meqUZtb7k
I find the fact that sum(A,1)
and A[1,:]
have different shapes in 0.5 counter intuitive. I am not aware of other languages for which the equivalent expressions have different shapes. It leads to unexpected results when computing e.g. A[1,:] ./ sum(A,1)
. At least in the case of sum
, it seems like sum(A,1)
should be equivalent to A[1,:] + A[2,:] + A[3,:] + ...
However, as @timholy pointed out, this behavior can be useful for broadcasting with expressions like A ./ sum(A,1)
.
For me, having the default slicing and array reduction behavior be consistent seems the natural choice, meaning that sum(A,1)
should drop the first dimension. But I understand the attractiveness of not dropping dimensions for broadcasting. What are others' thoughts?