[SciPy-user] Polynomial interpolation

Robert Kern robert.kern@gmail....
Tue Apr 29 13:41:56 CDT 2008


On Tue, Apr 29, 2008 at 11:57 AM, Eike Welk <eike.welk@gmx.net> wrote:
>  The function could look like this:
>
>
>  krogh_interpolator_cache=[]
>
>  def evaluate_krogh_interpolation(all_my_data_x, all_my_data_y,
>                                  x_interp):
>     global krogh_interpolator_cache
>     maxLen = 3
>
>     #search for already existing interpolators
>     for record in krogh_interpolator_cache:
>         x, y, interp = record
>         if (x==all_my_data_x).all() and (y == all_my_data_y).all():
>             return interp(x_interp)
>
>     #limit size of cache
>     if len(krogh_interpolator_cache) >= maxLen:
>         krogh_interpolator_cache = []
>     #create new interpolator
>     newInterpolator = KroghInterpolator(all_my_data_x, all_my_data_y)
>     krogh_interpolator_cache.append((all_my_data_x.copy(),
>                                      all_my_data_y.copy(),
>
>                                      newInterpolator))
>     return newInterpolator(x_interp)

Please, don't spend too much time playing with this. We will not
implement caching here. Caches are something better left for
applications, not general libraries because it requires too much
consideration of details only the application writer knows.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco


More information about the SciPy-user mailing list