'Numerical Recipes in Java™!'
i was/am under the impression that it was either FORTRAN or C++ in HPC/scientific computing arena :)edit-001 : slight clarification.
'Numerical Recipes in Java™!'
i was/am under the impression that it was either FORTRAN or C++ in HPC/scientific computing arena :)edit-001 : slight clarification.
This shows us that the war between 1-based and 0-based indexing was not decided for a long time.
This doesn't fit my recollection of having the C edition with a foreword that described how hard and error prone it was to convert everything from 1-based to 0-based. Maybe my memory plays tricks on me. I'm sure I had the C edition and not the C++ edition and this was before 2000.
[1] http://apps.nrbook.com/c/index.html
[2] http://numerical.recipes/forum/showthread.php?t=65&highlight...
- Ed Post, Real Programmers Don't Use Pascal
I agree (based on Dijkstra's arguments, I'm not smart enough to come up with my own) that 0-based indexing is the more logical, general choice, but 1-based indexing is more convenient for about 99% of the code written in Fortran, Matlab or Julia.
You could make the same argument for octal literals over the scary hex numbers with letters mixed in. 1-based indexing was invented by mathematicians using conventional notation without fully appreciating the problems it causes in computing systems. There is no reason to continue the insanity.
No, it's not. There is no universally preferred indexing in mathematics. The indexing scheme that is "natural" changes with the particular application.
There are of course instances when 0-based indexing makes more sense [1], [2]. But, there are cases when starting at 1 is more natural, as well [3]. Moreover, there are instances where starting with negative indices is more natural, say with the coefficients of the truncated Fourier series, or with the weights of a finite difference operator or of a cross-correlation operator.
Fortran supports all these conventions, which allows for a more direct translation of the mathematics to code.
[1]: https://en.wikipedia.org/wiki/Geometric_series#Formula
[2]: https://en.wikipedia.org/wiki/Taylor_series#Definition
[3]: https://en.wikipedia.org/wiki/Harmonic_series_(mathematics)
http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EW...
Here's some more grist to the mill, currently on the HN front page:
This is only the case for 1..N, not for I..J, when 'I' is not one. In this general case, the number of elements is 'J-I' if using zero-based numbering and exclusive upper bounds, which is more convenient. Zero-base also simplifies index arithmetic with modulo operations, such as when you are mapping between different index spaces.
Julia, as far as I understand, consciously mimicked Matlab there, to facilitate transition.
I have worked with customers that are heavy users of either IMSL or Alea:
http://www.roguewave.com/products-services/imsl-numerical-li...
http://quantalea.azurewebsites.net/
Mostly used on their in-house desktop solutions for data manipulation.