forum.alglib.net

ALGLIB forum
It is currently Mon Dec 23, 2024 4:55 am

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  [ 6 posts ] 
Author Message
 Post subject: spline1dbuildlinear
PostPosted: Mon Jan 30, 2017 5:21 am 
Offline

Joined: Tue Jan 17, 2017 11:16 pm
Posts: 10
Dear Sergey,

I also have another query in regards to the spline1dbuildlinear(AX, AY,spline) function.

As I understand that the function currently only accepts array of physical values, if I have X nodes = [0, 1/12, 3/12, 1/2, 1, 2, 5, 10,15, 20] and Y[i] = X[i]*log(p(X[i],a,b,var,r0)), how do I store the values of Y[i] as array to apply to the spline1dbuildlinear(AX, AY,spline) function ?

Your help is much appreciated. Many thanks.

Cheers,
Van


Top
 Profile  
 
 Post subject: Re: spline1dbuildlinear
PostPosted: Mon Jan 30, 2017 10:11 am 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
You should calculate Y[] using formula given by you and pass these values to spline constructor. It is the only way to build spline - to specify exact numerical values. It can't be built using some symbolic expression like yours.


Top
 Profile  
 
 Post subject: Re: spline1dbuildlinear
PostPosted: Mon Jan 30, 2017 11:23 am 
Offline

Joined: Tue Jan 17, 2017 11:16 pm
Posts: 10
Dear Sergey,

I try to build it like this and it works. However, it looks clumsy.

Y[0] = pow(X[0],1)*log(p(X[0],a,b,var,r0));
Y[1] = pow(X[1],1)*log(p(X[1],a,b,var,r0));
Y[2] = pow(X[2],1)*log(p(X[2],a,b,var,r0));
Y[3] = pow(X[3],1)*log(p(X[3],a,b,var,r0));
Y[4] = pow(X[4],1)*log(p(X[4],a,b,var,r0));
Y[5] = pow(X[5],1)*log(p(X[5],a,b,var,r0));
Y[6] = pow(X[6],1)*log(p(X[6],a,b,var,r0));
Y[7] = pow(X[7],1)*log(p(X[7],a,b,var,r0));
Y[8] = pow(X[8],1)*log(p(X[8],a,b,var,r0));
Y[9] = pow(X[9],1)*log(p(X[9],a,b,var,r0));

Is there a better was=y to handle this?

Cheers,
Van


Top
 Profile  
 
 Post subject: Re: spline1dbuildlinear
PostPosted: Mon Jan 30, 2017 3:05 pm 
Offline
Site Admin

Joined: Fri May 07, 2010 7:06 am
Posts: 927
...are you talking about for() loop? :)


Top
 Profile  
 
 Post subject: Re: spline1dbuildlinear
PostPosted: Tue Jan 31, 2017 4:36 am 
Offline

Joined: Tue Jan 17, 2017 11:16 pm
Posts: 10
Dear Sergey,

Thanks for the response.

I did this in a for() loop. However, how do I code the for() loop in the spline1dbuildlinear (Array X, Array Y) for Y?

X[i] = [0 1/12, 1/4, ....20];
for (i =0; i < 10; i++){
Y[i] = pow(X[i],0)*log(B(X[i],a,b,c));
}

Many thanks.
Cheers,
Van


Top
 Profile  
 
 Post subject: Re: spline1dbuildlinear
PostPosted: Tue Jan 31, 2017 11:19 am 
Offline

Joined: Tue Jan 17, 2017 11:16 pm
Posts: 10
Hi Sergey,

Its all good until next time. I put the function in the for() loop.

for (int n = 0; n<3; n++){

for (int i=0;i<10;i++){
Y[i] = pow(X[i],n)*log(p(X[i],a,b,var,r0));
//cout << setprecision(11)<< Y[i] << ",";
}

AY.setcontent(Y.size(), &(Y[0]));

alglib::spline1dbuildcubic(AX, AY,spline); //alglib building the linear spline
cout << spline1dintegrate(spline,X[9]) << ", ";

}
Thanks again.
Cheers,
Van


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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