Re: Argument typing in Compile
- To: mathgroup at smc.vnet.net
- Subject: [mg9398] Re: Argument typing in Compile
- From: seanross at worldnet.att.net
- Date: Sun, 2 Nov 1997 01:02:27 -0500
- Sender: owner-wri-mathgroup at wolfram.com
Xah wrote:
>
> At 12:34 AM -0800 1997.11.01, Sean Ross wrote:
> >Does anyone know of a way to define a symbol that will execute one bit
> >of compiled code for certain types of arguments and another bit of
> >compiled code for other arguments without resorting to an explicit If
> >or Case structure?
>
> Hi Sean,
>
> You could use the same technique to define functions that uses Compile.
>
> f[x_Integer]=Compile[...];
> f[x_Real]=Compile[...];
Thanks for the response. As reasonable a suggestion as that is,
Unfortunately, my version of mathematica(3.0.1) doesn't agree with your
logic.
The code:
f[x_Real]=Compile[{x},x^2]
does not EVER return a number no matter what the argument of f is. It
only returns a compiled function object with the argument in place of
the x. That is why I wrote in asking how to do it. Could you please
send a working sample of the code that you are referring to-one that
actually returns a real number.
> The commands Set and SetDelayed are permament versions of Rule and RuleDelayed.
> (with the condition that Rule and RuleDelayed needs to be used in conjunction with Replace or similar commands)
>
Could you elaborate on this statement, perhaps showing an example of
what you mean or how it relates to compiled function objects?