- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I'm using the data fitting functions of MKL for cubic spline interpolation (DF_PP_CUBIC, DF_PP_DEFAULT) using a not-a-knot condition (DF_BC_NOT_A_KNOT). In theory at least 4 samples are needed to perform this kind of interpolation, which is the unique cubic interpolation polynomial in this case.
My question is: What is the result of the MKL routine in case of 3 samples, which can also be executed without error code? Is this undefined behavior?
The MATLAB routine interp1 performs a simple quadratic polynomial interpolation for example. But this result differs from MKL's.
Thanks for clarification
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mario,
To construct a default cubic spline with not-a-knot boundary conditions, you need:
- array of N breakpoints
- array of N function values in the respective breakpoints
- array of N-2 2nd derivatives in the internal breakpoints
In other words, this type of spline requires at least three {breakpoints, function values} and one 2nd derivative.
Please, let me know, if it answers your question
Best regards,
Pavel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Pavel,
to be more explicit:
Let (x_i)_i be the N breakpoints for i=0,...,N-1 and S_i the spline over the interval [x_i, x_{i+1}].
For N >= 4 and not-a-knot boundary condition there is no need for additional required data given by the user. There is no need for second derivatives.
For example: In case of N = 4 there are three splines S_0, S_1, and S_2 with each having 4 searched coefficients.
- In sum there are 12 searched coefficients.
- The interpolation condition S(x_i) = y_i leads to 4 equations.
- The continuity condition leads to 2 equations.
- The continuity condition of the first derivative leads to 2 equations.
- The continuity condition of the second derivative leads to 2 equations.
- The not-a-knot condition S_0'''(x_1) = S_1'''(x_1) and S_1'''(x_2) = S_2'''(x_2) leads to 2 equations.
- In sum there are 12 equations which leads to a unique solution.
Of course, a given second derivative would help in case of N=3 since the two not-a-knot conditions degenerate to one. In fact the MKL routine computes for N=3 interpolated values which are plausible. But how is MKL doing this since I haven't configured data to compensate the degenerated not-a-knot condition?
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mario,
Let me provide additional details.
Default cubic spline is a piecewise polynomial spline of the fourth order. Coefficients of this spline are calculated using breakpoints, function values and 2nd derivatives. That is, the default cubic spline supports only DF_IC_2ND_DER internal conditions.
The list of boundary conditions supported by this spline is as follows:
- Not-a-knot
- 1st left derivative + 1st right derivative
- 1st left derivative + 2nd right derivative
- 2nd left derivative + 1st right derivative
- 2nd left derivative + 2nd right derivative
- Periodic
Intel MKL documentation does not provide additional level of details about this spline, and we will address it in the future releases.
Please have a look at the “dfscubicsplineint2der.c” example that demonstrates how to construct default cubic spline.
MATLAB’s documentation appears not to provide information about cubic spline’s type used underneath interp1 function.
We however assume that the natural cubic spline with not-a-knot boundary conditions might be a possible option here.
Intel MKL default cubic spline differs from the natural cubic spline, so you can expect different interpolation results.
Can you check spline construction and interpolation results with Intel MKL natural cubic spline for your interpolation problem?
Alternatively, you can provide a code sample that demonstrates discussed problem and reference results that you expect in this example, so we will be able to analyze it on our side.
Best regards,
Pavel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mario, Which version of MKL do you use right now?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I use MKL Version 2019.0.1 Build 20180928.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page