MatPy question

Jeff Shannon jeff at ccvcorp.com
Wed Nov 21 20:53:17 CET 2001


Glenn R Fulford wrote:

> "Huaiyu Zhu" <huaiyu at gauss.almadan.ibm.com> wrote in message
> news:slrn9vlstk.4ut.huaiyu at gauss.almadan.ibm.com...
> >
> > Mathematicians do not really care about whether the index starts with zero
> > or one.  They just need some index, which could start from 42 if you want.
> > But when they do care, such as defining the axioms of natural numbers,
> they
> > seem to prefer starting from zero as well
>
> On the other hand, most work with matricies has indexing starting from 1.
> Noone uses matrix indices (0,0). Note that MatLab does it's indexing from 1,
> and I thought that nupy is thought of as a replacement for matlab? The whole
> idea of using software to do mathematics is to have a language which feels
> natural to translate the maths into the program.
>
> .  I initially learned
> > programming in Fortran, but when I learned C later it felt much more
> > natural.  I guess some other people might feel the same way too.
> Not me!

For a good explanation of why zero-based indexing is a *very* good idea in
programming, read this lovely explanation by (the much missed) Alex Martelli:

http://groups.google.com/groups?q=g:thl3498076713d&hl=en&selm=9dhrmn0308b%40news1.newsguy.com

(all one line, in case that gets broken...)

It typically does take a little bit to adjust to, but once that adjustment is
made, off-by-one errors are *much* less likely than with 1-based indexing.

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list