Go to the documentation of this file.Go to the SVN repository for this file.
22 #include <gui/utils/splines/Splines.hh>
72 else if (
a < 0 ) sa = -1;
74 else if (
b < 0 ) sb = -1;
99 real_type h1 = X[1] - X[0];
100 real_type del1 = (Y[1]-Y[0])/h1;
101 real_type dsave = del1;
104 if (
n == 1 ) { Yp[0] = Yp[1] = del1;
return; }
106 real_type h2 = X[2] - X[1];
107 real_type del2 = (Y[2]-Y[1])/h2;
110 real_type hsum = h1 + h2;
111 real_type w1 = (h1 + hsum)/hsum;
112 real_type w2 = -h1/hsum;
113 Yp[0] = w1*del1 + w2*del2;
114 real_type dmin, dmax;
117 }
else if (
signTest(del1,del2) < 0 ) {
124 for ( integer
i = 1;
i <
n; ++
i ) {
130 del2 = (Y[
i+1] - Y[
i])/h2;
137 if ( isZero(del2) )
break;
138 if (
signTest(dsave,del2) < 0 ) ++ierr;
150 real_type drat1 = del1/dmax;
151 real_type drat2 = del2/dmax;
152 Yp[
i] = dmin/(w1*drat1 + w2*drat2);
158 w2 = (h2 + hsum)/hsum;
159 Yp[
n] = w1*del1 + w2*del2;
162 }
else if (
signTest(del1,del2) < 0 ) {
165 if (
abs(Yp[
n]) >
abs(dmax) ) Yp[
n] = dmax;
173 PchipSpline::build() {
174 SPLINE_ASSERT( npts > 1,
175 "PchipSpline::build(): npts = " << npts <<
176 " not enought points" );
181 while ( ++iend < npts && X[iend-1] < X[iend] ) {};
182 pchip( X+ibegin, Y+ibegin, Yp+ibegin, (iend-ibegin)-1 );
184 }
while ( iend < npts );
186 SPLINE_CHECK_NAN(Yp,
"PchipSpline::build(): Yp",npts);
void pchip(real_type const X[], real_type const Y[], real_type Yp[], integer n)
static int signTest(real_type const a, real_type const b)
static real_type min_abs(real_type a, real_type b)
static real_type max_abs(real_type a, real_type b)