[SciPy-User] Cubic splines - MATLAB vs Scipy.interpolate
Charles R Harris
Tue Sep 27 14:32:30 CDT 2011
On Tue, Sep 27, 2011 at 1:04 PM, Jaidev Deshpande <
> *The big question*: Why does the MATLAB function spline operate faster
> than the cubic spline alternatives in Scipy, especially splrep and splev ?
> *The context*: I'm working on an algorithm that bottlenecks on spline
> Some functions in Scipy return an interpolation *object function *depending
> on the input data which needs to be evaluated independently over the whole
> So I used 'lower order' functions like splrep and splev. Even that was too
> Then I tried to write my own code for cubic splines, generating and solving
> a system of 4N simultaneous equations for interpolation between N+1 points.
> No matter what I do, the code is quite slow. How come the MATLAB function
> spline operate so fast? What am I missing? What can I do to speed it up?
I suspect it is because the scipy routines you reference are based on
b-splines, which are needed for least squares fits. Simple cubic spline
interpolation through a give set of points tends to be faster and I believe
that is what the Matlab spline function does. To get b-splines in Matlab you
need one of the toolboxes, it doesn't come with the core. I don't think
scipy has a simple cubic spline interpolation, but I may be wrong.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User