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

*Subject*: [mg2957] RE: [mg2939] "Compile[]" and "InterpolatingFunction" objects*From*: jpk at apex.mpe.FTA-Berlin.de (Jens-Peer Kuska)*Date*: 17 Jan 1996 05:18:16 -0600*Approved*: usenet@wri.com*Distribution*: local*Newsgroups*: wri.mathgroup*Organization*: Wolfram Research, Inc.*Sender*: mj at wri.com

> From mathgroup-adm at smc.vnet.net Sat Jan 13 12:20:47 1996 > From: Jonathan Rich <rich at news.acns.nwu.edu> To: mathgroup at smc.vnet.net > To: mathgroup at smc.vnet.net > Subject: [mg2939] "Compile[]" and "InterpolatingFunction" objects > Organization: Northwestern University, Evanston, IL, US > Content-Length: 1014 > X-Lines: 29 > > 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'. > > 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). > > Thanks for your help on this. > > -- > Jonathan Rich > Geoscience Dept., Northwestern Univ. > > I am *not* informed about the details of the interpolation implementation but a) Mma uses a Newton/Lagrange interpolating formula around the desired point b) this need at least a searching to find the interval where the point lies in c) The compile intstructions have *no* searching command. d) Interpolation is a internal function that means it is compiled with the kernel. This will allway faster than the pseudo compilation by Compile You can try to compile the output InterpolatingPolynomial if You have only 4 or five points. Otherwise the algorithm is mutch more complex. Hope that helps Jens