Re: Compile Module w/ Function inside?
- To: mathgroup at smc.vnet.net
- Subject: [mg42296] Re: Compile Module w/ Function inside?
- From: Paul Abbott <paul at physics.uwa.edu.au>
- Date: Fri, 27 Jun 2003 06:31:23 -0400 (EDT)
- Organization: The University of Western Australia
- References: <bdbdoj$28a$1@smc.vnet.net> <bdef69$dj0$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
In article <bdef69$dj0$1 at smc.vnet.net>,
frankeye at cox.net (Frank Iannarilli) wrote:
> scwoods at taz.qinetiq.com (Simon Woods) wrote in message
> news:<bdbdoj$28a$1 at smc.vnet.net>...
> > Try this:
> >
> > foo = With[{q = Function[p,2*p]},Compile[{x},q[x]]]
> >
> > Not sure if this is what you wanted - I think the With function
> > replaces q with the pure function before Compiling, effectively doing
> > the "in-lining" for you.
> >
> > Simon.
>
> Hip-Hip-Horay!! Thank you, Simon! This works! foo is a Compile'd
> function using "pure" opcodes.
>
Alternatively, you can use
foo = Module[{q = Function[p, p 2.]}, Compile[{x}, Evaluate[q[x]]]]
Cheers,
Paul
--
Paul Abbott Phone: +61 8 9380 2734
School of Physics, M013 Fax: +61 8 9380 1014
The University of Western Australia (CRICOS Provider No 00126G)
35 Stirling Highway
Crawley WA 6009 mailto:paul at physics.uwa.edu.au
AUSTRALIA http://physics.uwa.edu.au/~paul