Hacker News new | ask | show | jobs
by mkl 3311 days ago
> the top left of a matrix A is always A_(1,1)

In maths notation it usually is, yes, but in a zero-based language it's usually a[0, 0] (and I've seen maths and CS papers where it's 0, too). The number of elements in a mxn array is still m*n, but the indices don't go that high. For example, in Python you'd loop through m rows with "for i in range(m)", which will go from 0 to m-1 (actually, you might do "for row in a" and not bother with indices). You hardly ever need to do m-1 manually - if you want the last row it's just a[-1, :].

I'm not saying zero-based is always better, but I haven't seen many situations where one-based is preferable.