Cspline in math::interpolator

Dear All!

I have ROOT 5.17/05 (trunk@20369)
My version contains Math::Interpolator class that doesn’t have CSpline interpolation type.
Math/InterpolationTypes.h header file contains following note:
Note: Cspline interpolations exist in GSL, but are not yet implemented here
Could you tell me if the last ROOT version has this feature? if no, when are “Interpolator” maintainers going to improve that little shortcoming?
If it’s not possible in the nearest future, what interpolator class would you advise me for cubic spline interpolation having any kind of integration method (tspline3 doesn’t have this feature in my version…)?

Thanks for your attention,

Hello Dmitry,

the Cubic spline interpolation type is available since a while. I am sorry the documentation is wrong and I will fix.
The enumeration type is:

ROOT::Math::Interpolation::CSPLINE for cubic spline and
ROOT::Math::Interpolation::CSPLINE_PERIODIC for peridic splines.

Thank you for reporting this

Best Regards


That’s great! Thank you!

If it wont take a lot of your time could you answer the other (silly) question about interpolators.

I need to make a global Math::interpolator in my program. It will be used in many functions including main(). Some functions use only Eval and Integ methods of this object, and one of them must recalculate spline points according to external parameters.

The problem is that i cant call constructor for this global object for void vectors (that are also global in my program) to fill them and call spline constructor later.
As a result of this i have to construct spline object in each of my functions from global vectors though potentially it could be done once. But this possibly decreases a performance of my program.

The second problem is that interpolator constructing via pointers is private in interpolator class (i could potentially use it for my purposes). Documentation explains that because of “interpolator copying is non trivial”. Could you clear this moment and if it’s possible to give me some advise on my problems - how do i make a kind of global interpolator object?

Thanks in advance!

Hello Dmitry,

If I understood you well, you would like to call a constructor specifying the methods once and then in each funciton, intialize it with the data vectors (x and y) to interpolate.
This could be done, it requires a simple modification of the class, but I would need to know in advance the size of the data point vectors.
In this way the allocation of the interpolation object can be done once.

Having instead a dummy constructor which does nothing, will not gain you very much.

The copy constructor (and assignment operator) for this class is disabled since the class contains a pointer which by itself contains all the interpolation objects and it is therefore not trivial to copy.
It is not clear to me what why you need to call the copy constructor.

So, in conclusion, if this helps you, I could add this new constructor

Interpolator(unsigned int size, Interpolation::Type type)

and a method

SetData(vector<double> & x, vector<double> & y)

Please let me know and thank you for your useful feedback,

Best Regards


Yes, this is what i mean.

but I would need to know in advance the size of the data point vectors.
In this way the allocation of the interpolation object can be done once.[/quote]

Do you want to know the exact number of points or their maximum number? My case is very simple - I have to solve some ODE system with variable time step and then interpolate this solution for minuit subroutine. So I can estimate some upper limit of such points number but it’s impossible to predict its exact value…

Neither to me :slight_smile: I’m not familiar with all these techniques, so i expected you will tell me about it :slight_smile:

Now I think that your idea about
SetData(vector & x, vector & y)
method would be great for my purpose if you clear that moment above…

Thank you!

Unfortunatly the GSL algorithm are designed in a way that the exact number is needed. An interpolation object is then initialized with that size.

I am putting anyway in the code the possibility to set the data in the Interpolation class later. If the number of points given in the constructor dos not match the data vector sizes, then a new object will be constructed.
Eventually it is possible to specify only the method (using 0 for the size).
These new changes are now in the root svn trunk.

Best Regards


Thanks for your patience, Lorenzo.
I’ll play with these additions (data setting and zero size interpolator constructor) these holidays. I think this will help me.
Anyway it’s not clear for me what errors (if any) I can expect from refreshed “interpolator” if I:

  1. create this object with vector size calculated “in advance” as an upper limit.
  2. make that vectors greater than estimated points number.