#include <EvtPolInt.hh>
Definition at line 31 of file EvtPolInt.hh.
◆ EvtPolInt()
EvtPolInt::EvtPolInt |
( |
vector< double > | xi, |
|
|
vector< double > | yi, |
|
|
double | x ) |
|
inline |
Definition at line 33 of file EvtPolInt.hh.
33 {
35 size = xi.size();
36 vx.clear();
37 vy.clear();
38 for(int i=0;i<size;i++){
39 vx.push_back(xi[i]);
40 vy.push_back(yi[i]);
41 }
42 }
◆ ~EvtPolInt()
virtual EvtPolInt::~EvtPolInt |
( |
| ) |
|
|
inlinevirtual |
◆ geterror()
double EvtPolInt::geterror |
( |
| ) |
|
Definition at line 172 of file EvtPolInt.cc.
172 {
174
175return error;
176}
◆ getvalue()
double EvtPolInt::getvalue |
( |
| ) |
|
Definition at line 165 of file EvtPolInt.cc.
165 {
167
168
169return value;
170}
◆ polynomial()
void EvtPolInt::polynomial |
( |
| ) |
|
Definition at line 23 of file EvtPolInt.cc.
23 {
26 double den,dif,dift,ho,hp,
w;
27
29 vector <double> c(
n),d(
n);
30 dif = fabs(xx-vx[0]);
32 if ((dift = fabs(xx-vx[i]))<dif){
34 dif = dift;
35 }
36 c[i] = vy[i];
37 d[i] = vy[i];
38 }
42 ho = vx[i] -xx;
43 hp = vx[i+m] -xx;
45 if(( den = ho-hp) == 0.0) std::cout<<"Error in routine polint"<<std::endl;
47 d[i] = hp*den;
48 c[i] = ho*den;
49 }
50 y += (dy=(2*(
ns+1)< (
n-m) ? c[
ns+1]: d[
ns--]));
51 }
53 error = dy;
54
55 if(value <0) value = 0;
56 return;
57}
Referenced by geterror(), and getvalue().
◆ ratint()
void EvtPolInt::ratint |
( |
| ) |
|
Definition at line 59 of file EvtPolInt.cc.
60{
62 const double TINY=1.0e-25;
65
67 vector <double> c(
n),d(
n);
68 hh=fabs(xx-vx[0]);
70 h=fabs(xx-vx[i]);
71 if (h == 0.0) {
73 dy=0.0;
74 return;
75 } else if (h < hh) {
77 hh=h;
78 }
79 c[i]=vy[i];
81 }
86 h=vx[i+m]-xx;
89 if (dd == 0.0) std::cout<<"Error in routine ratint"<<std::endl;
91 d[i]=c[i+1]*dd;
93 }
94 y += (dy=(2*(
ns+1) < (
n-m) ? c[
ns+1] : d[
ns--]));
95 }
97 error = dy;
98 if(value <0) value = 0;
99 return;
100}
◆ spline()
vector< double > EvtPolInt::spline |
( |
| ) |
|
Definition at line 102 of file EvtPolInt.cc.
103{
104 vector <double> y2;
105 y2.clear();
106 for(int i=0;i<size;i++){y2.push_back(0.0);}
107 double yp1=0;
108 double ypn=0;
109 int i,k;
110 double p,qn,sig,un;
111
113 vector<double> u;
114 if (yp1 > 0.99e30){
115 u[0]=0.0;
116 y2.push_back(0.0);}
117 else {
118 y2.push_back(-0.5);
119 u[0]=(3.0/(vx[1]-vx[0]))*((vy[1]-vy[0])/(vx[1]-vx[0])-yp1);
120 }
121 for (i=1;i<
n-1;i++) {
122 sig=(vx[i]-vx[i-1])/(vx[i+1]-vx[i-1]);
123 p=sig*y2[i-1]+2.0;
124 double yy2=(sig-1.0)/p;
125 y2.push_back(yy2);
126 u[i]=(vy[i+1]-vy[i])/(vx[i+1]-vx[i]) - (vy[i]-vy[i-1])/(vx[i]-vx[i-1]);
127 u[i]=(6.0*u[i]/(vx[i+1]-vx[i-1])-sig*u[i-1])/p;
128 }
129 if (ypn > 0.99e30)
130 qn=un=0.0;
131 else {
132 qn=0.5;
133 un=(3.0/(vx[
n-1]-vx[
n-2]))*(ypn-(vy[
n-1]-vy[
n-2])/(vx[
n-1]-vx[
n-2]));
134 }
135 y2[
n-1]=(un-qn*u[
n-2])/(qn*y2[
n-2]+1.0);
137 y2[k]=y2[k]*y2[k+1]+u[k];
138 return y2;
139 }
Referenced by splint().
◆ splint()
void EvtPolInt::splint |
( |
| ) |
|
Definition at line 141 of file EvtPolInt.cc.
141 {
142 vector <double> y2a =
spline();
144 int k;
146
148 int klo=0;
150 while (khi-klo > 1) {
151 k=(khi+klo) >> 1;
152 if (vx[k] > xx) khi=k;
153 else klo=k;
154 }
155 h=vx[khi]-vx[klo];
156 if (h == 0.0) std::cout<<"Bad xa input to routine splint"<<std::endl;
157 a=(vx[khi]-xx)/h;
159 y=a*vy[klo]+
b*vy[khi]+((a*a*a-a)*y2a[klo]
160 +(
b*
b*
b-
b)*y2a[khi])*(h*h)/6.0;
162 return;
163}
vector< double > spline()
The documentation for this class was generated from the following files: