pass parameters to a function when calling BROYDEN or NEWTON routines [message #85063] |
Fri, 28 June 2013 07:12  |
Tasos
Messages: 4 Registered: February 2012
|
Junior Member |
|
|
Hi there,
following the example in the BROYDEN reference page in IDL, I first determine the non-linear system of equations by creating a function which then is called by the BROYDEN function. The problem I am facing here is that I would like to pass parameters in the first function while calling the BROYDEN function.
For example:
first determine the equations
FUNCTION broydenfunc, X
...
END
then call the broyden function
result = BROYDEN(X, 'broydenfunc')
So my question again is how I can pass parameters to the BROYDENFUNC function when calling the main BROYDEN function? I would like to keep the BROYDENFUNC in a loop where different parameters are passed every time.
Thanks in advance!
T
|
|
|
Re: pass parameters to a function when calling BROYDEN or NEWTON routines [message #85064 is a reply to message #85063] |
Fri, 28 June 2013 07:22   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Friday, June 28, 2013 4:12:16 PM UTC+2, tas....@gmail.com wrote:
> Hi there,
>
>
>
> following the example in the BROYDEN reference page in IDL, I first determine the non-linear system of equations by creating a function which then is called by the BROYDEN function. The problem I am facing here is that I would like to pass parameters in the first function while calling the BROYDEN function.
>
>
>
> For example:
>
>
>
> first determine the equations
>
> FUNCTION broydenfunc, X
>
> ...
>
> END
>
>
>
> then call the broyden function
>
> result = BROYDEN(X, 'broydenfunc')
>
>
>
> So my question again is how I can pass parameters to the BROYDENFUNC function when calling the main BROYDEN function? I would like to keep the BROYDENFUNC in a loop where different parameters are passed every time.
>
>
>
> Thanks in advance!
>
> T
With a common block?
FUNCTION broydenfunc, X
COMMON broydenfuncParams, p0, p1
...
END
and then call like this:
COMMON broydenfuncParams, p0, p1 ; this should be at the beginning
for i =0,9 do begin
p0=i
p1=i*2
result = BROYDEN(X, 'broydenfunc')
endfor
Hope it helps,
Helder
|
|
|
Re: pass parameters to a function when calling BROYDEN or NEWTON routines [message #85065 is a reply to message #85063] |
Fri, 28 June 2013 07:22  |
Kenneth Bowman
Messages: 86 Registered: November 2006
|
Member |
|
|
On 2013-06-28 14:12:16 +0000, tas.mrgns@gmail.com said:
> Hi there,
>
> following the example in the BROYDEN reference page in IDL, I first
> determine the non-linear system of equations by creating a function
> which then is called by the BROYDEN function. The problem I am facing
> here is that I would like to pass parameters in the first function
> while calling the BROYDEN function.
> For example:
>
> first determine the equations
> FUNCTION broydenfunc, X
> ...
> END
> then call the broyden function
> result = BROYDEN(X, 'broydenfunc')
>
> So my question again is how I can pass parameters to the BROYDENFUNC
> function when calling the main BROYDEN function? I would like to keep
> the BROYDENFUNC in a loop where different parameters are passed every
> time.
>
> Thanks in advance!
> T
The usual way to do this is through a common block.
Ken Bowman
|
|
|