Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
6586 Discussions

## How to tranfer saved "scoeff" to 'dfdInterpolate1D' to calculate interpolated results?

Beginner
256 Views

Dear all,

In curve fitting, suppose I already have "scoeff" from previous data fitting and the data fitting task  is already deleted.

How can I pass the saved "scoeff" to "dfdInterpolate1D" later to calculate interpolated results whenever necessary ?  Can it be simpler and don't need to supply x and y,  and don't need to calculate "scoeff" again?

Thank you very much!

8 Replies
Employee
256 Views

Hi Bin,

Thank you for posting.

We will take a look and will get back to you.

Best regards,

Khang

Employee
256 Views

Hi Bin,

The saved "coeff" can be passed using the df?EditPPSpline1D function as the “scoeff” parameter.

X and Y data shall be set to the Data Fitting task. This data is used during interpolation.

Hope this helps!

Khang

Beginner
256 Views

Thank you! Khang

But I think the df?EditPPSpline1D function will generate a new "coeff" from X and Y data. And my saved "coeff" will be replaced.

Is that right?

How to make the interpolation task to use my "coeff" instead of the new "coeff" generated from that X and Y data?

Thank you very much!I

Employee
256 Views

Hi Bin,

two different scenarios for interpolation routine are supported by Intel® MKL Data Fitting library:

Scenario 1.

• Create new Data Fitting task
• Set all spline’s parameters and pointer to the memory storage as a “scoeff” parameter by df?EditPPSpline1D function
• Call df?Construct1D function to construct spline. Spline’s coefficients are saved to the “scoeff” memory storage
• Call df?Interpolate1D function to run spline-based interpolation

Scenario 2.

• Create new Data Fitting task
• Set spline’s parameters and pointer to the precomputed spline coefficients as “scoeff” parameter by df?EditPPSpline1D function (without spline reconstruction)
• Call df?Interpolate1D function to run spline-based interpolation

For your case the second described interpolation scenario can be used to utilize precomputed splines’ coefficients.

Feel free to ask in case of any questions.

Best regards,

Pavel.

Beginner
256 Views

Dear Sir,

Can I ask more questions?  Which spline data-fitting function can generate similar results with the MATLAB function 'spline'?

Because when I modified MKL example 'dfdcubicspline_interp.c' and used the same data with MATLAB function 'spline', I got different spline coefficients “scoeff”.

Which function should I use or what parameters should I use to be comparable to MATLAB function 'spline'?

Thank you very much!

Employee
256 Views

Hi Bin,

Spline’s coefficients are highly depend on the spline’s type and spline’s boundary conditions.

MATLAB’s documentation appears not to provide information about spline’s type used underneath “spline” function.

We however assume that natural cubic spline with not-a-knot boundary conditions might be possible option.

To construct natural cubic splines with not-a-knot boundary conditions, please call the editor of the Data Fitting task and then construct the spline as shown below:

df?EditPPSpline1D( task, DF_PP_CUBIC, DF_PP_NATURAL, DF_BC_NOT_A_KNOT, 0, DF_NO_IC, 0, scoeff, scoeffhint);

Best regards,
Pavel.

Beginner
256 Views

Dear Pavel,

I want to ask a question, can I pack different parameters together as y vector, and get different coeff for several curves on one task?  For example, I want to do data fitting for x vs y1, x vs y2, x vs y3, can I pack the data of y1, y2 and y3 together as a vector y, and obtain three curves at the same time ?  Do you have examples for these multiple curve fitting?

Thank you very much!

Dyakov, Pavel (Intel) wrote:

Best regards,
Pavel.

Employee
256 Views

Hi Bin,

Data Fitting tasks support simultaneous work with the different curves, e.g. you can construct the splines for y1, y2, y3 sets at the same time.
Functions' values can be packed "set by set" to the vector y.  Please find the example:

int i, j;
double freq;
for( i = 0; i < ny; i++ )
{
freq = (i + 1);
for( j = 0; j < nx; j++ )
{
y[i*nx+j]= sin(x*freq);
}
}

Where:                nx – size of partition x
ny – function dimension

This approach is also demonstrated in dfdlinearspline example (with ny = 2).