MathGroup Archive 1996

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

Search the Archive

Re: "Compile[]" and "InterpolatingFunction" objects

  • Subject: [mg3012] Re: "Compile[]" and "InterpolatingFunction" objects
  • From: rknapp (Robert Knapp)
  • Date: 22 Jan 1996 06:18:12 -0600
  • Approved:
  • Distribution: local
  • Newsgroups: wri.mathgroup
  • Organization: Wolfram Research, Inc.
  • Sender: mj at

Jonathan Rich wrote:
> I am trying to produce efficient compiled code which evaluates an expression
> that includes "InterpolatingFunction" objects.  So I have two questions:
> 1) Are "InterpolatingFunction" objects Compiled by default?  The Book doesn't
> say although in Appendix A.8 under "InterpolatingFunction" it says
> `See also:  CompiledFunction'.
No.  The reference is not to InterpolatingFunction objects being
compiled, but being similar to CompiledFunction objects in that they
only evaluate for numeric arguments.

> 2)  How do I compile an InterpolatingFunction w/o having the compiled
> pseudocode
> use an external evaluation (pseudocode instruction # 24) for the result of the
> InterpolatingFunction?  Here is a simple example:
> list=Table[{i,i},{i,4}];
> interpFunc=Interpolation[list];
> f1=Compile[{x},Evaluate[interpFunc[x]]];
> f1//InputForm
> In the output you will see that the compiled code uses an external evaluation,
> which defeats the whole purpose of using "Compile[]" (which is to speed up the
> computation--it may be that "Interpolation[]" produces compiled code, but I
> can't find this documented anywhere).
The evaluation of an InterpolatingFunction object with its argument
requires going through the Mathematica evaluator.
InterpolatingFunctions evaluate via internal code, so are not evaluated
by the compiled function interpreter.  Thus, the result of the above
lines is (very slightly) less efficient than the InterpolatingFunction

There are situations where it is of advantage to Compile an
InterpolatingFunction object.  This occurs when either its argument is a
complicated function or you are computing some complicated function of
the result.  

For example:


> Thanks for your help on this.

Substantial changes have been made to the structure of
InterpolatingFunction objects for Version 3.0.  With these changes,
compiling an InterpolatingFunction object will result in the evaluation
being done using only machine numbers, which is substantially faster.

Rob Knapp
> --
> Jonathan Rich
> Geoscience Dept., Northwestern Univ.

  • Prev by Date: Re: "Compile[]" and "InterpolatingFunction" objects
  • Next by Date: Re: Success stories wanted
  • Previous by thread: Re: "Compile[]" and "InterpolatingFunction" objects
  • Next by thread: Speed up Mathematica for Windows 95