MathGroup Archive 1999

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

Search the Archive

Compiled Function Problem


Hello NG

This function calculates the area of two 4 sides Polygons. It works woll
in its uncompiled form, but not in compiled form.

It seems that the function Cross ditn't work in compiled functions, so I
rewrote it.


In[10]:=
ElementVF = Compile[{{elm1, _Real, 2}, {elm2, _Real, 2}}, 
    Module[{VecAbs, CrossP, area1, area2},
      
      VecAbs[v_] := Sqrt[Plus @@ (v^2)]; 
      CrossP[v1_, v2_] := 
       {v1[[2]]*v2[[3]] - v1[[3]]*v2[[2]], v1[[3]]*v2[[1]] -
v1[[1]]*v2[[3]], v1[[1]]*v2[[2]] - v1[[2]]*v2[[1]]}; 

      area1 = (VecAbs[CrossP[elm1[[2]] - elm1[[1]], elm1[[3]] -
elm1[[1]]]] + 
          VecAbs[CrossP[elm1[[2]] - elm1[[4]], elm1[[3]] -
elm1[[4]]]])/2; 

      area2 = (VecAbs[CrossP[elm2[[2]] - elm2[[1]], elm2[[3]] -
elm2[[1]]]] + 
          VecAbs[CrossP[elm2[[2]] - elm2[[4]], elm2[[3]] -
elm2[[4]]]])/2; {area1, area2}]]; 


In[11]:=
ElementVF[Kreisring[200, 100, 0][[1]], Mantel[200, 0, 40][[1]]]
CompiledFunction::"cfex": 
    "External evaluation error at instruction 18 proceeding with \
uncompiled evaluation."
Out[12]=
{67.5118,65.4236}

-- 
Beat Zahnd
Engineering School Biel, Switzerland
http://www.isbiel.ch/~zahnb/


  • Prev by Date: problems printing in Mathematica 3
  • Next by Date: TOUGH Question
  • Previous by thread: Re: problems printing in Mathematica 3
  • Next by thread: TOUGH Question