junderwood
07-01-2003, 08:23 AM
Hi
[this question refers specifically to the C version of NR, and possibly the C++ version, though I've never used that]
Am I correct in thinking that a function requiring a vector input (eg. the ODE solvers) could actually be passed a 2D matrix (as allocated using the funcs in nrutil.c) by passing the address &array[0][0] since the 2D arrays are contiguous chunks of memory? Of course the number of vector elements would need to be calculated correctly. I know that for 0 offset arrays and vectors this is true, I'm just wondering if the unti offset for 2D arrays destroys the contiguous nature of the memory area?
Thanks,
Jonathan
[this question refers specifically to the C version of NR, and possibly the C++ version, though I've never used that]
Am I correct in thinking that a function requiring a vector input (eg. the ODE solvers) could actually be passed a 2D matrix (as allocated using the funcs in nrutil.c) by passing the address &array[0][0] since the 2D arrays are contiguous chunks of memory? Of course the number of vector elements would need to be calculated correctly. I know that for 0 offset arrays and vectors this is true, I'm just wondering if the unti offset for 2D arrays destroys the contiguous nature of the memory area?
Thanks,
Jonathan