forum.alglib.net

ALGLIB forum
It is currently Fri Nov 08, 2024 12:33 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Spline Interpolation Question...
PostPosted: Sat Nov 19, 2011 5:36 pm 
Offline

Joined: Sat Nov 19, 2011 5:27 pm
Posts: 3
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


Last edited by siamaksg on Sun Nov 20, 2011 4:09 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Spline Interpolation seems to have a bug...
PostPosted: Sat Nov 19, 2011 7:58 pm 
Offline

Joined: Sat Nov 19, 2011 5:27 pm
Posts: 3
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


Top
 Profile  
 
 Post subject: Re: Spline Interpolation seems to have a bug...
PostPosted: Sun Nov 20, 2011 11:22 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 925
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.


Top
 Profile  
 
 Post subject: Re: Spline Interpolation Question...
PostPosted: Mon Nov 21, 2011 9:11 am 
Offline

Joined: Sat Nov 19, 2011 5:27 pm
Posts: 3
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group