MathGroup Archive 1998

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

Search the Archive

Re: compiled functions


  • To: mathgroup@smc.vnet.net
  • Subject: [mg10797] Re: compiled functions
  • From: Paul Abbott <paul@physics.uwa.edu.au>
  • Date: Thu, 5 Feb 1998 00:58:40 -0500
  • Organization: University of Western Australia
  • References: <6asasb$fc3@smc.vnet.net>

Zahnd Beat wrote:

> Can me anyone say what I must do wenn I use a self declared function in
> a compiled function?
> 
> In[6]:=
> f[vec_] := Sqrt[Plus @@ (vec^2)]
> 
> In[12]:=
> c = Compile[{{a, _Real, 1},  {b, _Real, 1}}, a/f[a]*f[b]];

Compile is HoldAll:

In[1]:= Attributes[Compile]
Out[3]= {HoldAll,Protected}

so you need to wrap Evaluate around a/f[a]*f[b], i.e.,

	c = Compile[{{a, _Real, 1},  {b, _Real, 1}}, Evaluate[a/f[a]*f[b]]]

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul@physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________



  • Prev by Date: Re: Need integration help!
  • Next by Date: Re: PDEs & Mathematica.
  • Prev by thread: Re: an spanish student...
  • Next by thread: Re: Re: Cell bracket <-> Inline