MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Argument typing in Compile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9377] Argument typing in Compile
  • From: Sean Ross <seanross at worldnet.att.net>
  • Date: Sat, 1 Nov 1997 03:34:01 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

With normal mathematica functions, there is a built-in "case" structure
for overloading the definition of a particular symbol.  For example:

f[x_Integer]:=function1;
f[x_Real]:=function2;

This serves the same purpose as an If or a Case structure that tests the
arguments and applies the correct code depending on whether or not x is
Integer or Real.

Now suppose I want to do the same with CompiledFunction objects.

f[x_Real]=Compile[{x,_Real},x^2]  and other permutations where the
symbol f is given an argument list generate an error message that
Compile is protected.

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?

thanks.  Sean



  • Prev by Date: Re: ReplaceAll strange behaviour
  • Next by Date: Re: ReplaceAll strange behaviour
  • Previous by thread: Re: ReplaceAll strange behaviour
  • Next by thread: Re: Argument typing in Compile