Converting old NR arrays to NR3.
John Knowles
08-21-2008, 10:50 PM
I would like to convert my current code which relies on the 1-offset NR system for vectors and matrices to the new NR convention of zero offset. Is there an efficient way to avoid rewriting all my loops and assignments?
Thanks
John
Bill Press
08-23-2008, 11:56 PM
Well, I'm not sure exactly what you want to do here. The last time NR had 1-offset vectors/matrices was in the 1992 C version. I hope you don't want to keep using code from that old book!
If the issue is that you have legacy code that takes old NR vectors/matrices as arguments, and you want to mix it with new code or NR3 routines, that is probably doable by adding a bit of structure to the NRvector and NRmatrix class definitions. (Or this could be done with a derived class.)
The idea would be to add a pointer (vector) or pointer to array of pointers (matrix) to the class, and then point it -- with the old nutty unit offsets -- to the data in the new classes. Then, you would send these pointers to your legacy routines.
Hope this helps.
Cheers,
Bill P.