sum
documentation does not give a complexity guarantee. It is a different thing to defend the documentation ofBase.last
to not haveO(1)
as a requirement, and defend that this requirement is to be ignored before Julia 2.0, in which it can be changed.- The expected complexity of
sum
is O(n-1
Base.+
operations for theeltype
) wheren
is the number of elements in the container.sum(diagonal_mat)
andsum(ordinary_dense_matrice)
both follow such complexity. What isN
in your example? The length of one dimension of the container? This does not seem standard.
I don’t see why
last
should not simply be expected to ‘return the last element of an iterator’, complexity be damned.
Well, I already give why I think so in this thread, and you are not addressing it. So I believe this is rhetorical.