Re: When to use Compile[]
- To: mathgroup at smc.vnet.net
- Subject: [mg8753] Re: [mg8720] When to use Compile[]
- From: Mark Evans <evans at gte.net>
- Date: Sat, 20 Sep 1997 22:28:18 -0400
- Organization: None
- Sender: owner-wri-mathgroup at wolfram.com
I have not used Compile[] much at all, but I know this much about it. Compile[] produces a list of opcodes that constitute a lower-level way to run Mathematica. Sometimes Compile[] does not know how to handle particular functions, in which case it leaves them unresolved. In this case, the Mathematica function is called just as if you had typed it on the command line. In this situation, you should reduce the amount of code that you are trying to Compile[] until the result is opcodes only, with no function calls. You can find out whether you have accomplished the feat by looking at the FullForm[] of the Compile[] result. Also remember that Compile[] functions accept only numeric inputs (I think; check the book). So the answer to whether Compile[] handles a particular function which interests you is to try it, then look at the form of the result. If you have nothing but opcodes, then you have a successful compilation. Regards, Mark Evans Luci Ellis wrote: > > Dear MathGroup, > > My Mathematica skills have progressed to the point that I care about > performance tweaking as well as getting the code to work. I would be > grateful for any thoughts group members might have about what functions > work with Compile[] and when it should be used. > > I know that it works for basic numerical operations on numbers and lists of > numbers, for example, the definition for the Jarque-Bera test statistic for > normality (thanks Colin Rose for alerting me to this -- it halved the > Timing result). > > But what about things like Solve and FindMinimum? Or Regress? Are there > occasions where Compiled[] matrix operations will be faster than packages > like LinearRegression? What about list construction functions like FoldList > and NestList? Can you use Compile[]d functions within them? > > Does anyone have any rules of thumb about when to Compile[] and when not > to? The Mathematica Book's coverage of this issue is a bit scanty, other > than it being for numerical functions. > > Thanks in anticipation, > > Luci Ellis > elisha at dot.net.au > > -------------- > Luci Ellis: elisha at dot.net.au > http://www.dot.net.au/~elisha