sumdocumentation does not give a complexity guarantee. It is a different thing to defend the documentation ofBase.lastto 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
sumis O(n-1Base.+operations for theeltype) wherenis the number of elements in the container.sum(diagonal_mat)andsum(ordinary_dense_matrice)both follow such complexity. What isNin your example? The length of one dimension of the container? This does not seem standard.
I don’t see why
lastshould 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.