Re: Multiple parameters for ZEROFCN [message #78898] |
Mon, 02 January 2012 18:48  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
One problem with the built-in IDL functions based on IMSL or Numerical Recipes is that they don't accept _EXTRA keyword to supply additional parameters to user-supplied function.
One ugly but efficient workaround is to use a common block in your user function and the calling procedure to pass and modify the Y parameter.
Alternatively, you could find your zeros using
http://idlastro.gsfc.nasa.gov/ftp/pro/math/zbrent.pro
which does accept _EXTRA keywords (so your Y parameter would need to be accepted as a keyword). A couple of notes:
1. ZBRENT requires one to first bracket the location of the zeros.
2. I'm not sure that the function you supplied has any zero -- as opposed to discontinuities.
--Wayne
|
|
|
Re: Multiple parameters for ZEROFCN [message #78987 is a reply to message #78898] |
Sat, 14 January 2012 04:27  |
Rick Walton
Messages: 3 Registered: November 2011
|
Junior Member |
|
|
On Jan 3, 3:48 am, wlandsman <wlands...@gmail.com> wrote:
> One problem with the built-in IDL functions based on IMSL or Numerical Recipes is that they don't accept _EXTRA keyword to supply additional parameters to user-supplied function.
>
> One ugly but efficient workaround is to use a common block in your user function and the calling procedure to pass and modify the Y parameter.
>
> Alternatively, you could find your zeros usinghttp://idlastro.gsfc.nasa.gov/ftp/pro/math/zbrent.pro
> which does accept _EXTRA keywords (so your Y parameter would need to be accepted as a keyword). A couple of notes:
>
> 1. ZBRENT requires one to first bracket the location of the zeros.
> 2. I'm not sure that the function you supplied has any zero -- as opposed to discontinuities.
>
> --Wayne
Hi Wayne,
Thanks a lot for your response. The common block idea sounds like it
would be the way forward for me as I need to remain in PV wave for
consistency with other programs. I'm not familiar with how the
calling procedure to pass and modify a parameter using the common
block in PV wave. Would you be able to provide an example of how to
do this? I have pasted a small section of my program and function to
work with. It would be much appreciated.
FUNCTION, f, x
RETURN, ((sinh((1.4 +x-0.25)/(0.4))/(sinh((x-0.25)/0.4)))-Y
END
FOR i = 0, N-1 DO BEGIN
Y(i)=C(i)/D(i)
EPIresult(i)=ZEROFCN("F")
ENDFOR
END
Best wishes,
Rick
|
|
|