Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1998

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

Search the Archive

Re: compiled functions

  • To:
  • Subject: [mg10797] Re: compiled functions
  • From: Paul Abbott <>
  • Date: Thu, 5 Feb 1998 00:58:40 -0500
  • Organization: University of Western Australia
  • References: <6asasb$>

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]]]


Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907  AUSTRALIA                   

            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