Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
Re: Passing function to function called by qromb etc.?
In article <399ad505$1@cs.colorado.edu>, jwilson@shifty.cs.colorado.edu (John Wilson) wrote: > I would like to numerically integrate f(x) * x in IDL. This is coming > up within another function which takes the function f as one of its > parameters. What I would like to do is define a function xfx which > computes f(x) * x for a given x and call qromb with the function > xfx with a parameter of the function f. However, I cannot figure out > how to do this. > > I thought of > function xfx,x,func=f > return, call_function(func,x) * x > end > > foo=qromb(xfx,a,b,func='bar') > > but that does not work. What I really need is a capability like the > bind argument facility of the STL. > How about this ugly solution? function xfx,x common func return,call_function(func,x)*x end common func func = 'bar' foo = qromb(xfx,a,b) A while back in the "Top Ten IDL Requests" thread, I made a wish that the IDL implementations of Numerical Recipes routines that call user-supplied functions (QROMB, LMFIT) would allow vector calls to the user functions. I should have also added that the user should have the ability to pass keywords directly to the user-supplied function. I haven't tried it but both these capabilities are available in Mati Meron's procedure ROMBERG at ftp://cars3.uchicago.edu/midl/romberg.pro I have similar capabilities for QSIMP and QTRAP at http://idlastro.gsfc.nasa.gov/ftp/pro/math/ Wayne Landsman landsman@mpb.gsfc.nasa.gov Sent via Deja.com http://www.deja.com/ Before you buy.