       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:=
ElementVF = Compile[{{elm1, _Real, 2}, {elm2, _Real, 2}},
Module[{VecAbs, CrossP, area1, area2},

VecAbs[v_] := Sqrt[Plus @@ (v^2)];
CrossP[v1_, v2_] :=
{v1[]*v2[] - v1[]*v2[], v1[]*v2[] -
v1[]*v2[], v1[]*v2[] - v1[]*v2[]};

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

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

In:=
ElementVF[Kreisring[200, 100, 0][], Mantel[200, 0, 40][]]
CompiledFunction::"cfex":
"External evaluation error at instruction 18 proceeding with \
uncompiled evaluation."
Out=
{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