RK4 and IDL's array truncation [message #75209] |
Tue, 22 February 2011 07:29 |
Bill Nel
Messages: 31 Registered: October 2010
|
Member |
|
|
I should know better by now, but I spent two days tracking down a
mysterious problem with RK4, IDL's Runga-Kutta integration routine.
RK4 calls a user-supplied function, passing it two variables, X and
Y.
Result = RK4( Y, Dydx, X, H, Derivs [, /DOUBLE] )
X is a scalar, but Y can be an array. The problem is that when Y is a
scalar (or a one-element array), RK4 calls your user-supplied function
with a *one-element array*, and IDL silently truncates math operations
involving arrays to the shorter array. (Normally I do argument-
checking that would have caught the problem, but I skipped it this
time, since the user-supplied function is called hundreds of thousands
of times.)
I'm posting just in case somebody else runs into mysterious problems
with RK4, but also to ask,
does anybody actually make use of array truncation? (And why you would
want to?) I've always considered it a huge mistake in the language,
and something ITTVIS should eliminate, even it would be painful for
them.
|
|
|