Numerical Recipes is non-portable code

Rob Carriere rob at kaa.eng.ohio-state.edu
Fri Sep 2 11:45:03 AEST 1988


In some article in a chain so long ``rn'' chokes on it, gwyn at smoke.ARPA 
(Doug Gwyn) writes:
> [ that I write that ]:
>>Trivial refutation time!  Surely it is obvious that ``numerical
>>problems'' forms a (large) superset of ``array/matrix code'' as far as
>>numerical analysis is concerned?
>Trivial indeed!  If the code does not involve arrays/matrices,
>the issue of 0-based or 1-based indexing doesn't even arise.

Well... I was going to apologize for the tone of my last posting, but
you're sure not making it any easier.  Guess I still will though, I
short-changed you yesterday, so I'll overpay you today.  So, please
consider that my last posting was affected by 3 days high on emotions
and low on sleep, making my temper about a mile shorter than it should
have been, and please accept my apologies for the tone of that
posting.  Peace now?

As for your refutation of my refutation, it should have been clear
from the following paragraph in the posting that I meant code other
than the generic invert-matrix, do-svd etc stuff.  Most of those can
indeed be written base 1 or base 0 without any difference.  There are
however problems (of a more specialized nature, and the arrays do not
necessarily model vectors or matrices) where the base does make a
difference.  I should know, I write the stuff!

Several people have suggested that for these cases one either carries
the address arithmatic through the code, or accesses the arrays
through a function that does the arithmatic for you.  The first
approach has the disadvantage that even using special lay-out tricks
the readability of the resulting code drops to just about zero (again,
this is experience, not just unwillingness to try).  Both approaches
have the disadvantage that they introduce inefficiencies into the
code.  Since I am talking about things that eventually are going to be
somewhere in a real-time system, efficiency is worth more than ``gee,
it'd be neat if it were a little faster''; it is access this array
5000 times per second or the voice link dies/ the plant blows up/ the
missile flies the other way/ fill in your favorite disaster here.

Rob Carriere
It's long, but I hope it clears the dust a little. *



*
Yup, it's a broom!



More information about the Comp.lang.c mailing list