MathGroup Archive 2003

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

Search the Archive

Compile Module w/ Function inside?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42225] Compile Module w/ Function inside?
  • From: frankeye at cox.net (Frank Iannarilli)
  • Date: Tue, 24 Jun 2003 01:27:13 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Hi,


I'm trying to speedup a Module.  Poking about, I've learned that a
significant impediment to fast Compile'd code is the referencing of
global or otherwise external functions within the Compile'd Module
(indeed, one can check to see if the compiled opcode string is
"pure").

As my present Module *does* external function referencing, I wish to
bring these functions inside the Module, defining them using
Function[].  (Believe me, "in-lining" my functions' code within the
Module, every place they need to be invoked, is not an option). 
Surely defining (pure) Functions inside Modules is allowed in general
(e.g., outside Compile[]), but I can't find an arrangement that is
Compile'able.

Here is an example that goes nowhere, i.e., can be evaluated
(foo[3.]=6.), but does not use compiled code:

foo = Compile[{x}, Module[{q = Function[p, p*2.]},
       q[x]], {{q[_], _Real}, {Function[___], _Real}}]

In: foo[3.]

CompiledFunction::cfse: Compiled expression Function[p,p 2.] should be
a \
machine-size real number.

Out:  6. 

Any means/hope to achieve my objective?


Thanks!


  • Prev by Date: Re: solved in a non algebraic way?
  • Next by Date: Re: Equation problem
  • Previous by thread: Re: NDSolve documentation
  • Next by thread: Re: Compile Module w/ Function inside?