Compile Question: mg26177

• To: mathgroup at smc.vnet.net
• Subject: [mg26201] Compile Question: mg26177
• From: Blimbaum Jerry DLPC <BlimbaumJE at ncsc.navy.mil>
• Date: Thu, 30 Nov 2000 22:02:16 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```	Chris wrote:..basically..can't compile the following:

Compile[{{n,_Integer}},
g[{r_,t_}]:=r Cos[n t];
xy=Table[{x,y},{x,-1,1,0.5},{y,-1,1,.5}];
Map[g[#]&,xy,{2}]//N
]

Here are some Timing results for comparison of the solutions offered
to this problem:   I used .001 instead of .5 for the xy Table: I'm using a
P3 600 MHz machine...V4 Mathematica

Table[x Cos[4. y],{x,-1,1,.001},{y,-1,1,.001}];//Timing     = 76.19
seconds

Compile[{{n,_Integer}}, Table[x Cos[n
y],{x,-1,1,.001},{y,-1,1,.001}]];//Timing = 7.96 seconds

Compile[{{n,_Integer},{delta,_Real}}, Table[x Cos[n
y],{x,-1,1,delta},{y,-1,1,delta}]];//Timing = 6.42 seconds  with delta =
.001

Another solution using Map (not shown here) took about 33 seconds..

One reason I took an interest in this problem is that I tried to
solve it..wracked my 'grey cells'...got absolutely nowhere and then saw some
of the simplest solutions offered..thank Heaven for the bright people at
Mathgroup!!!   It's one of the things that makes using Mathematica so
interesting and valuable...

Jerry Blimbaum  NSWC  Panama City, Fl

```

• Prev by Date: Re: New version of Mathematica
• Next by Date: Re: Polar plot with a twist.
• Previous by thread: Newton Raphson fractals
• Next by thread: Problem: Passing Variables within Expressions To Mathematica through JLink