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

spline1dbuildlinear
http://forum.alglib.net/viewtopic.php?f=2&t=3789
Page 1 of 1

Author:  vpham [ Mon Jan 30, 2017 5:21 am ]
Post subject:  spline1dbuildlinear

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

Author:  Sergey.Bochkanov [ Mon Jan 30, 2017 10:11 am ]
Post subject:  Re: spline1dbuildlinear

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.

Author:  vpham [ Mon Jan 30, 2017 11:23 am ]
Post subject:  Re: spline1dbuildlinear

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

Author:  Sergey.Bochkanov [ Mon Jan 30, 2017 3:05 pm ]
Post subject:  Re: spline1dbuildlinear

...are you talking about for() loop? :)

Author:  vpham [ Tue Jan 31, 2017 4:36 am ]
Post subject:  Re: spline1dbuildlinear

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

Author:  vpham [ Tue Jan 31, 2017 11:19 am ]
Post subject:  Re: spline1dbuildlinear

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

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