forum.alglib.net

ALGLIB forum
 It is currently Tue Aug 09, 2022 10:18 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.

 Page 1 of 1 [ 6 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: spline1dbuildlinearPosted: Mon Jan 30, 2017 5:21 am

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

 Post subject: Re: spline1dbuildlinearPosted: Mon Jan 30, 2017 10:11 am

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

 Post subject: Re: spline1dbuildlinearPosted: Mon Jan 30, 2017 11:23 am

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

 Post subject: Re: spline1dbuildlinearPosted: Mon Jan 30, 2017 3:05 pm

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

Top

 Post subject: Re: spline1dbuildlinearPosted: Tue Jan 31, 2017 4:36 am

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

 Post subject: Re: spline1dbuildlinearPosted: Tue Jan 31, 2017 11:19 am

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

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 6 posts ]

 All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

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

Search for: