1 #ifndef _GeneralBSpline_Spline_General_h_
2 #define _GeneralBSpline_Spline_General_h_
9 #include <utl/AugerException.h>
15 template <dim_t ADimension,
typename AKnotVector,
typename ABasisFunction>
27 const size_t n = GetSize();
30 for (
size_t i=0;i<n-1;++i)
47 const size_t n = GetSize();
59 return fData[n-1]+(i-(n-1))*dx;
76 Locate(
const double x)
79 const size_t n = GetSize();
80 if (x >= (*
this)[n-1])
140 return derivative == -1 ? Internal(
fKnotPtr->Locate(x),
GetStop(), -1) : 0;
142 return Internal(
fKnotPtr->Locate(x), x, derivative);
151 Internal(
const size_t i,
const double x,
const char derivative)
162 switch (derivative) {
164 const double a = xknot[i];
166 x*(t0 + x*(t1/2 + x*(t2/3 + x*t3/4))) -
167 a*(t0 + a*(t1/2 + a*(t2/3 + a*t3/4)));
170 const double pa = xknot[j];
171 const double pb = xknot[j+1];
173 pb*(t0 + pb*(t1/2 + pb*(t2/3 + pb*t3/4))) -
174 pa*(t0 + pa*(t1/2 + pa*(t2/3 + pa*t3/4)));
179 return t0 + x*(t1 + x*(t2 + x*
t3));
181 return t1 + x*(2*t2 + x*3*
t3);
183 return 2*t2 + x*6*
t3;
202 #define SPLINE_BASIS_POLYNOMAL_FACTORS(ia0, ia1, ia2, ib0, ib1, ib2, ic0, ic1, ic2) \
203 t0 += -xknot(fIndex+ia0)*xknot(fIndex+ia1)*xknot(fIndex+ia2)/((xknot(fIndex+ib0)-xknot(fIndex+ic0))*(xknot(fIndex+ib1)-xknot(fIndex+ic1))*(xknot(fIndex+ib2)-xknot(fIndex+ic2))); \
204 t1 += (xknot(fIndex+ia0)*xknot(fIndex+ia1)+xknot(fIndex+ia0)*xknot(fIndex+ia2)+xknot(fIndex+ia1)*xknot(fIndex+ia2))/((xknot(fIndex+ib0)-xknot(fIndex+ic0))*(xknot(fIndex+ib1)-xknot(fIndex+ic1))*(xknot(fIndex+ib2)-xknot(fIndex+ic2))); \
205 t2 += -(xknot(fIndex+ia0)+xknot(fIndex+ia1)+xknot(fIndex+ia2))/((xknot(fIndex+ib0)-xknot(fIndex+ic0))*(xknot(fIndex+ib1)-xknot(fIndex+ic1))*(xknot(fIndex+ib2)-xknot(fIndex+ic2))); \
206 t3 += 1.0/((xknot(fIndex+ib0)-xknot(fIndex+ic0))*(xknot(fIndex+ib1)-xknot(fIndex+ic1))*(xknot(fIndex+ib2)-xknot(fIndex+ic2)));
227 #undef SPLINE_BASIS_POLYNOMAL_FACTORS
233 template <dim_t ADimension,
typename AKnotVector,
typename ABasisFunction>
234 friend class ::Spline::Function;
double operator[](const size_t i) const
ComputePolynomialFactors(t0, t1, t2, t3, i-fIndex)
Base class for exceptions arising because configuration data are not valid.
std::vector< double > fData
KnotVector(const std::vector< double > &data)
BasisFunction(const KnotVector *const xknot, int j)
#define SPLINE_BASIS_POLYNOMAL_FACTORS(ia0, ia1, ia2, ib0, ib1, ib2, ic0, ic1, ic2)
BasisFunction & operator=(const BasisFunction &other)
void PushBack(const double x)
double operator()(const double x, const char derivative=0) const
else return std::upper_bound(fData.begin(), fData.end(), x)-fData.begin()-1
BasisFunction(const BasisFunction &other)
const KnotVector * fKnotPtr
double operator()(const int i) const