forum.alglib.net
http://forum.alglib.net/

Spline Interpolation Question...
http://forum.alglib.net/viewtopic.php?f=2&t=489
Page 1 of 1

Author:  siamaksg [ Sat Nov 19, 2011 5:36 pm ]
Post subject:  Spline Interpolation Question...

Hi,

It seems that Spline Interpolation has some bugs. In Manual, it is written that "Subroutine automatically sorts points, so caller may pass unsorted array.", but I have received some errors each time the input arrays has not been sorted. I tracked the program and also, there was no line to sort arrays in the spline interpolation methods. In specific, there was no call to Tsort class. Please tell me if I am wrong.

with very many thanks for this precious library,
Siamak

Author:  siamaksg [ Sat Nov 19, 2011 7:58 pm ]
Post subject:  Re: Spline Interpolation seems to have a bug...

Also, I have another question. In alglibinternal.cs Line 328, the algorithme checks to determine whether data are sorted or not. But "(double)(x[i-1])>=(double)(x[i])" results in the strict rule that there must not two points with same X coordinates. Since I dont know so much about the Spline interpolation and specifically about these codes, I want to know that is this rule necessary?! in case of yes, what I should do because there lots of data in my dataset that have same X and different Y coordinates.

Thank you so much,
Siamak

Author:  Sergey.Bochkanov [ Sun Nov 20, 2011 11:22 am ]
Post subject:  Re: Spline Interpolation seems to have a bug...

Hello!

Regarding first of your questions - can you tell me name of specific function which fails at unsorted points? What specific errors you have? Maybe it fails because of non-distinct points?

Regarding second one. Yes, this rule is necessary because in the interpolation setting you can't have two points with same X's but different Y's. How can you build spline which passes though both points simultaneously? For example, it is impossible to have spline with S(x=123.456)=0 and S(x=123.456)=1 simultaneously.

Author:  siamaksg [ Mon Nov 21, 2011 9:11 am ]
Post subject:  Re: Spline Interpolation Question...

Hello,

Very many thanks for your response.
I do apologize for my first post, since there was also two points with the same X coordination in my synthetic dataset. Therefore, I thought that the error was related to the sorting problem. When I deleted one of them, everythings went right.
Thank you again for you answer and at the same time for this great library.

For my second Question, the problem was solved. Since I have a dataset looking like a semi-circle, I converted the explicit equation to a paramteric one. Consequently-->

t = number of samples
double[] x = x-coordinate of samples
double[] y = y-coordinate of samples

Since I want to caculate a appoximate first derivative along the curve, I have followed this approach ():

double[] T = {1,2,....,t};
alglib.spline1dgriddiffcubic(T, x, t, 0, 0.0, 0, 0.0, out Dx);
alglib.spline1dgriddiffcubic(T, y, t, 0, 0.0, 0, 0.0, out Dy);

and finally the first derivative is calculated as follows:

D = Dy / Dx; for each of elements

I think it would an advantegous for AlgLib if these procedures (for all spline interpolation methods) become available in the package.

Siamak

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/