Go to the documentation of this file.
26 if(
this==&a_from)
return *
this;
32 const double&
X()
const {
return fX;}
33 const double&
Y()
const {
return fY;}
34 double &
X() {
return fX;}
35 double &
Y() {
return fY;}
49 if(
this==&a_from)
return *
this;
57 double &
B() {
return fB;}
58 double &
C() {
return fC;}
59 double &
D() {
return fD;}
60 double eval(
double x)
const {
double dx=x-
fX;
return (
fY+dx*(
fB+dx*(
fC+dx*
fD)));}
70 quintic_poly(
double x,
double y,
double b,
double c,
double d,
double e,
double f)
77 if(
this==&a_from)
return *
this;
87 double &
B() {
return fB;}
88 double &
C() {
return fC;}
89 double &
D() {
return fD;}
90 double &
E() {
return fE;}
91 double &
F() {
return fF;}
108 base_spline(std::ostream& a_out,
double delta,
double xmin,
double xmax,
size_t np,
bool step)
117 if(
this==&a_from)
return *
this;
149 cubic(std::ostream& a_out,
size_t a_n,
double a_x[],
double a_y[],
double a_valbeg = 0,
double a_valend = 0)
154 m_out <<
"tools::spline::cubic : a_np is null." << std::endl;
160 for (
size_t i=0; i<a_n; ++i) {
161 fPoly[i].X() = a_x[i];
162 fPoly[i].Y() = a_y[i];
172 if(
this==&a_from)
return *
this;
186 if ( (
fNp > 1) && (klow >= (
fNp-1))) klow =
fNp-2;
187 return fPoly[klow].eval(x);
196 if ( i & 1 && x + 0.5 == T(i) ) i--;
199 if ( i & 1 && x - 0.5 == T(i) ) i++;
206 int klow=0, khig=
fNp-1;
211 else if(x>=
fXmax) klow=khig;
216 if (x <
fPoly[klow].X())
217 klow = mx<int>(klow-1,0);
218 else if (klow < khig) {
219 if (x >
fPoly[klow+1].X()) ++klow;
225 while((khig-klow)>1) {
226 khalf = (klow+khig)/2;
227 if(x>
fPoly[khalf].X()) klow=khalf;
232 if( (x<
fPoly[klow].X()) || (
fPoly[klow+1].X()<x) ) {
233 m_out <<
"tools::spline::cubic::find_x : Binary search failed"
234 <<
" x(" << klow <<
") = " <<
fPoly[klow].X() <<
" < x= " << x
235 <<
" < x(" << klow+1 <<
") = " <<
fPoly[klow+1].X() <<
"."
275 double divdf1,divdf3,dtau,g=0;
283 {
for (
size_t m=1; m<
fNp ; ++m) {
313 bool forward_gauss_elimination =
true;
318 {
for (
int m=1; m<l; ++m) {
346 forward_gauss_elimination =
false;
364 forward_gauss_elimination =
false;
368 forward_gauss_elimination =
false;
377 if(forward_gauss_elimination) {
389 for (
size_t i=1; i<
fNp; ++i) {
391 divdf1 = (
fPoly[i].Y() -
fPoly[i-1].Y())/dtau;
392 divdf3 =
fPoly[i-1].B() +
fPoly[i].B() - 2.*divdf1;
393 fPoly[i-1].C() = (divdf1 -
fPoly[i-1].B() - divdf3)/dtau;
394 fPoly[i-1].D() = (divdf3/dtau)/dtau;
420 quintic(std::ostream& a_out,
size_t a_n ,
double a_x[],
double a_y[])
423 m_out <<
"tools::spline::quintic : a_np is null." << std::endl;
429 for (
size_t i=0; i<a_n; ++i) {
430 fPoly[i].X() = a_x[i];
431 fPoly[i].Y() = a_y[i];
438 if(
this==&a_from)
return *
this;
461 while((khig-klow)>1) {
462 khalf = (klow+khig)/2;
463 if(x>
fPoly[khalf].X()) klow=khalf;
469 if( (x<
fPoly[klow].X()) || (
fPoly[klow+1].X()<x) ) {
470 m_out <<
"tools::spline::quintic::find_x : Binary search failed"
471 <<
" x(" << klow <<
") = " <<
fPoly[klow].X() <<
" < x= " << x
472 <<
" < x(" << klow+1<<
") = " <<
fPoly[klow+1].X() <<
"."
547 double pqqr, p, q, r, s, t, u, v,
548 b1, p2, p3, q2, q3, r2, pq, pr, qr;
550 if (
fNp <= 2)
return;
561 if (q)
fPoly[1].D() = q*6.*q2/(qr*qr);
562 else fPoly[1].D() = 0;
565 for (i = 1; i < m; ++i) {
578 fPoly[i+1].D() = q3*6./(qr*qr);
579 fPoly[i].D() += (q+q)*(pr*15.*pr+(p+r)*q
581 ((p2+r2)*8.+pr*21.+q2+q2))/(pqqr*pqqr);
582 fPoly[i-1].D() += q3*6./(pq*pq);
583 fPoly[i].E() = q2*(p*qr+pq*3.*(qr+r+r))/(pqqr*qr);
584 fPoly[i-1].E() += q2*(r*pq+qr*3.*(pq+p+p))/(pqqr*pq);
585 fPoly[i-1].F() = q3/pqqr;
590 if (r)
fPoly[m-1].D() += r*6.*r2/(qr*qr);
595 for (i = 1; i <
fNp; ++i) {
604 for (i = 2; i <
fNp; ++i) {
622 for (i = 2; i < m; ++i) {
635 for (i=
fNp-3; i > 0; --i)
651 if (q)
fPoly[0].F() = v/q;
652 else fPoly[0].F() = 0;
653 for (i = 1; i < m; ++i) {
656 if (i != m-1) r =
fPoly[i+2].X()-
fPoly[i+1].X();
669 if (q)
fPoly[i].F() = v/q;
674 p3-(v+
fPoly[i].E())*q3)/pq;
685 s =
fPoly[0].F()*p*p*p;