Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
New Contributor I
107 Views

FPE with Data Fitting Akima spline

Hi,

I have found an issue with the Akime spline type in the Data Fitting library that results in a FPE being produced by the MKL library.

It occurs when the Akima spline is constructed with a set of breakpoints that have multiple equal y-values. The library will exit on the call to dfdConstruct1D and exit with a FPE error in _v1DCSAkimaYRowsNoUniformGrid.

It is very repeatable and rather annoying!

Two questions:

  1. Is there a configuration or workaround I can use to get the Akima spline to work in this circumstance?
  2. What other monotone spline methods are available in MKL Data Fitting library that will handle such breakpoint data and that also provide a 2nd-derivative?

 I've attached some dummy sample data that should repeat the FPE error if used to construct an Akima spline.

For reference I am using the BC of f''==0 at both ends of the spline, and DF_NO_HINT used for the y-value hint.

I'm also using the MKL 2019u5 version of the library.

Thanks,

Ewan

 

EDIT:  I'm going to implement a workaround/fudge in my side of the code to try to alleviate the situation for now. In the construction of the spline it's not difficult to drop breakpoints where there are multiple repeated y-values. I partially do this already to avoid multiple repeated x-values. The biggest problem I have here is that with the Akima spline requiring a minimum of 5-breakpoints it's possible that I end up with a breakpoint set that is too small. In that case I'll have to artificially fudge the y-values with some values near the epsilon(double)~1.e-15 to proceed...

0 Kudos
7 Replies
Highlighted
Employee
107 Views

Hi Ewan,

Glad to see new questions from you.

I tried to reproduce the issue for the provided data on Lnx OS.
I received next output without any FPE:

Number of break points : 9

i  x(i)        y(i)
0 -0.104956   +34.183189
1 -0.097253   +28.792177
2 -0.078657   +28.840805
3 -0.060061   +28.875745
4 -0.052358   +28.823694
5 -0.046884   +28.809941
6 -0.033668   +28.878588
7 -0.020453   +29.398327
8 -0.014979   +36.454974

Spline coefficients for Y:

i    Ai            Bi            Ci            Di
0  +34.183189     +0.000000   -272819.296917   +23622478.931320
1  +28.792177     +1.879640   +118.173901   -4228.576767
2  +28.840805     +1.887809    +67.663616   -3664.386070
3  +28.875745     +0.602695   -2202.196951   +161848.947895
4  +28.823694     -4.514244   +575.646246   -38356.042599
5  +28.809941     -1.660048   +1021.526674   -38050.136781
6  +28.878588     +5.403700   +2619.879802   -3998.125460
7  +29.398327    +72.554515   +333366.168696   -20299958.191423

One note: to get such coefficients I set the next boundary conditions:

  • First derivative at the left end as 0
  • Second derivative at the right end as 0

For the “BC of f''==0 at both ends of the spline” spline coefficients are different for the first interval.

I see that the provided data are exactly the same as you sent in the previous forum thread (https://software.intel.com/en-us/comment/1945785). Is that right?

Also what are the other simulation parameters? Are it the same as in https://software.intel.com/en-us/comment/1945785?

  • Is there a configuration or workaround I can use to get the Akima spline to work in this circumstance?

I will try to reproduce the issue first to provide any thoughts about workaround.

  • What other monotone spline methods are available in MKL Data Fitting library that will handle such breakpoint data and that also provide a 2nd-derivative?

Intel MKL supports Default, Natural, Hermite, Bessel, Akima, Hyman cubic splines. More information can be found here: https://software.intel.com/en-us/onemkl-developer-reference-c-mathematical-conventions-for-data-fitt....

 

Feel free to ask more.

Best regards,
Pavel

0 Kudos
Highlighted
New Contributor I
107 Views

Ah, it seems the data upload feature has confused me! The sample data shouldn't be the same as last time, I will try to re-upload the correct sample data below.

Otherwise, yes the parameters are the same as before.

0 Kudos
Highlighted
New Contributor I
107 Views

I also should add, that I found a cheesy workaround.

I originally intended on dropping breakpoints if duplicate y-values exist but that wouldn't work because if I have multiple y-functions then I would have to drop values in all splines.

Instead, I do some simple data modification to add/subtract a tiny value (1.e-15) where duplicate, consecutive y-values occur. I oscillate between adding or subtracting at each consecutive duplicate found.

It really isn't ideal, but it works!

0 Kudos
Highlighted
Moderator
107 Views

 

Ewan,

We have checked the problem with the data you provided into message#3 and still were not able to reproduce the FPE problem on our side. 

We tested with MKL 2019 u5, win10 64 bit, Linux RH7.

The output is below.

The examples of the codes are attached to this thread - test.zip. 

Could you check how our example will work on your side?

 

./a.out
Number of break points : 15

 i  x(i)        y(i)
 0 +0.000000   -12819102618131.500000
 1 +0.000517   -6867900273605.480469
 2 +0.005172   +0.000000
 3 +0.010345   +0.000000
 4 +0.015517   +0.000000
 5 +0.020690   +0.000000
 6 +0.025862   +0.000000
 7 +0.031034   +0.000000
 8 +0.036207   +0.000000
 9 +0.041379   +0.000000
 10 +0.046552   +0.000000
 11 +0.051724   +0.000000
 12 +0.056897   +0.000000
 13 +0.062069   +0.000000
 14 +0.067241   +0.000000
Coefficients are calculated for a polynomial of the form:

Pi(x) = Ai + Bi*(x - x(i)) + Ci*(x - x(i))^2 + Di*(x - x(i))^3
    where x(i) <= x < x(i+1)

Spline coefficients for Y:
 i    Ai            Bi            Ci            Di
 0 -12819102618131.500000   +15877747839639882.000000   -1933.333333   -16341900745603448569856.000000
 1 -6867900273605.480469   +2761477918971477.000000   -235646623607134592.000000   -8729581472540459008.000000
 2   +0.000000     +0.000000     +0.000000     +0.000000
 3   +0.000000     +0.000000     +0.000000     +0.000000
 4   +0.000000     +0.000000     +0.000000     +0.000000
 5   +0.000000     +0.000000     +0.000000     +0.000000
 6   +0.000000     +0.000000     +0.000000     +0.000000
 7   +0.000000     +0.000000     +0.000000     +0.000000
 8   +0.000000     +0.000000     +0.000000     +0.000000
 9   +0.000000     +0.000000     +0.000000     +0.000000
 10   +0.000000     +0.000000     +0.000000     +0.000000
 11   +0.000000     +0.000000     +0.000000     +0.000000
 12   +0.000000     +0.000000     +0.000000     +0.000000
 13   +0.000000     +0.000000     +0.000000     +0.000000

0 Kudos
Highlighted
New Contributor I
107 Views

Hi Gennady,

I can confirm that I can build and repeat the test case you have produced without an FPE.

Checking the configuration of the Akima spline in the test case against that used in my code and I cannot initially see any differences.

Give me a little time to double check my own code, and also see if I can create a small reproducer.

 

0 Kudos
Highlighted
Moderator
107 Views

sure Ewans! Please keep us updated with this thread. 

0 Kudos
Highlighted
New Contributor I
107 Views

Hi,

I finally managed to get a small reproducer for the FPE I encountered with the construction of the Akima spline. As I also found a second FPE with the natural spline construction, I've decided to bundle them into a new thread which can be found here:

https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/850567

Hopefully I can finally resolve this issue this time around!

Ewan

0 Kudos