Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1998
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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

compiled functions



Hy

Can me anyone say what I must do wenn I use a self declared function in
a compiled function?

Example:

In[6]:=
f[vec_] := Sqrt[Plus @@ (vec^2)]

In[12]:=
c = Compile[{{a, _Real, 1},  {b, _Real, 1}}, a/f[a]*f[b]];

In[13]:=
c[{1, 1, 0}, {1, 0, 0}]

Results in some error messages and returns a correct but symbolical
answer

In[14]:=
c = Compile[{{a, _Real, 1}, {b, _Real, 1}}, a/Sqrt[Plus @@
(a^2)]*Sqrt[Plus @@ (b^2)]]

Same function, but without function f

In[15]:=
c[{1, 1, 0}, {1, 0, 0}]

Correct answer:

Out[15]=
{0.707107,0.707107,0.}


Beat Zahnd
Engineering School Biel
Switzerland

http://www.isbiel.ch/~zahnb/



  • Prev by Date: Re: Complex -> List does not work
  • Next by Date: Re: strange behaviour
  • Prev by thread: Re: List Manipulation (2)
  • Next by thread: Derivative of implicit function