comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Execute and Call_function of complex things
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Execute and Call_function of complex things [message #23526] Thu, 01 February 2001 21:25
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
dirk@uwast.astro.wisc.edu (Dirk Fabian) writes:

> ... Sorry that didn't post.
>
> Ok, once again. This goes in the "why doesn't it work like i think it
> should" category.
>
> Suppose I have an expression which, for the sake of argument, looks
> something like:
>
> exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))
>
> where gauss1 is another function (of x) and p is a set of input
> parameters.
>
> I want to evaluate this function, but can't seem to do it with either
> call_function or execute. I've tried:

Greetings to my alma mater and home state!

Pavel has it all right, so I just wanted to bring it all home.

You should use CALL_FUNCTION when you have a function *name*. You
can't use an expression.

y = call_function('sin', x)

You should use EXECUTE on a complete *statement*. You can't pass any
arguments to an execute command aside from the command itself. Thus
there really are no "local" variables. Any variables that appear in
your statement must already be defined.

If you are using MPFITEXPR, which it looks like you may be doing, then
you have two choices. Choice one is to enclose your expression in a
function named MODEL, and then use MPFITFUN instead, and evaluate your
model with this "Y = MODEL(X, P)". The second choice is to use the
(documented but obscure) MPEVALEXPR which appears within the body of
MPFITEXPR. Like this, "Y = MPEVALEXPR(EXPR, X, P)"

Have fun!
Craig


--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
Re: Execute and Call_function of complex things [message #23527 is a reply to message #23526] Thu, 01 February 2001 16:37 Go to previous message
Pavel A. Romashkin is currently offline  Pavel A. Romashkin
Messages: 531
Registered: November 2000
Senior Member
Dirk Fabian wrote:
>
> model='exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))'
> result=call_function(model,p)

For this to work, a compiled wrapper would be needed:

function model, p
return, exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))
end

result=call_function('model', p)
; Or simply
result = model(p)

> expstring='model=exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))'
> result=call_function(expstring, p)

For this to work, I think Execute is needed:

expstring='result=exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))'
junk = execute(expstring)

Cheers,
Pavel
Re: Execute and Call_function of complex things [message #23529 is a reply to message #23527] Thu, 01 February 2001 14:44 Go to previous message
dirk is currently offline  dirk
Messages: 15
Registered: March 1998
Junior Member
... Sorry that didn't post.

Ok, once again. This goes in the "why doesn't it work like i think it
should" category.

Suppose I have an expression which, for the sake of argument, looks
something like:

exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))

where gauss1 is another function (of x) and p is a set of input
parameters.

I want to evaluate this function, but can't seem to do it with either
call_function or execute. I've tried:

model='exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))'
result=call_function(model,p)

and
expstring='model=exp((-1.)*(0.0 + Gauss1(x,p(0:2)) + Gauss1(x,p(3:5))))'
result=call_function(expstring,p)

to no effect... What am i missing about call_function or execute? Do all
the elements of the evaluated function need to be IDL native? Does the
conversion of a string to a function make anyone else uneasy?

Thanks for any help! - Dirk
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Demo of Shadows
Next Topic: Re: IDL employment in Front Range

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:55:51 PDT 2025

Total time taken to generate the page: 0.00320 seconds