Compiled Function Problem
- To: mathgroup at smc.vnet.net
- Subject: [mg18265] Compiled Function Problem
- From: Zahnd Beat <zahnb at hta-bi.bfh.ch>
- Date: Thu, 24 Jun 1999 14:24:50 -0400
- Organization: Engineering School Biel
- Sender: owner-wri-mathgroup at wolfram.com
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/