Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Advice on Compile

  • To: mathgroup at smc.vnet.net
  • Subject: [mg112441] Advice on Compile
  • From: "Niels R. Walet" <niels.walet at manchester.ac.uk>
  • Date: Wed, 15 Sep 2010 20:02:35 -0400 (EDT)

I am trying to write the following code (simplified, Mathematica 7.0.2)
setZu[subs_] :=
 Block[{Zmint}, Zmint = Evaluate[EFRp[q] /. subs]; Clear[Zmn];
  Zmn = Compile[{{k, _Real}},
    NIntegrate[Evaluate[Zmint], {q, 0, k}]];]
I call
setZu[EFRp -> Function[{q}, q^2/(1 + q^2)^2]]
and than
Zmn[1.]
gives an error (because Zmint has not been expanded).
Of course I can move the assigment on Zmint within the compile, but it 
leads to ugly code, and I am not sure how efficient the compile is (does 
it do the substitution every time, or is it "compiled out"?). In real 
life the integrals I calculate are extremely expensive, and give me the 
coefficients for an ODE I try to solve, so extreme efficiency would be 
appreciated: I want to compile the expression with the substitution 
done, not the substitution process itself.
Any light on this issue would be appreciated.
Niels

-- 
Prof. Niels R. Walet                   Phone:  +44(0)1613063693
School of Physics and Astronomy        Fax:    +44(0)1613064303
The University of Manchester           Mobile: +44(0)7905438934
Manchester, M13 9PL,  UK               room 7.7, Schuster Building
email: Niels.Walet at manchester.ac.uk 
web:   http://www.theory.physics.manchester.ac.uk/~mccsnrw



  • Prev by Date: Re: How to rescale the x-axis in an nonlinear way?
  • Next by Date: Re: Generalizing Complement to handle multiple occurrences
  • Previous by thread: Re: New Version 3 Presentations
  • Next by thread: Re: Advice on Compile