34 #ifndef AIMSALGO_MATH_BSPLINE_H 35 #define AIMSALGO_MATH_BSPLINE_H 52 template <
unsigned Order>
55 static double at(
double x )
62 if( std::abs(x) >
double(Order+1)/2 )
65 return ( dO()/2. + .5 - x ) / dO()
67 + ( dO()/2. + .5 + x ) / dO()
84 static unsigned order() {
return Order; }
87 static double dO() {
return (
double)Order; }
96 if( -.5 <= value && value < .5 )
102 static unsigned order() {
return 0; }
140 BSpline(
unsigned order = 3,
float scale = 1.,
bool shifted =
false );
149 double operator() (
double x )
const;
152 double at(
double x )
const;
155 double derivative(
double x,
unsigned n = 1 )
const;
168 void reset(
unsigned order = 3,
float scale = 1.,
bool shifted =
false );
171 void setOrder(
unsigned order );
174 void setScale(
float scale );
177 void setShifted(
bool shifted );
180 void setCentered(
bool centered );
186 unsigned order()
const {
return _order; }
188 float scale()
const {
return _scale; }
196 double dO()
const {
return double( _order ); }
197 virtual void setSupport();
230 double at(
double x )
const;
235 double derivative(
double x,
unsigned n = 1 )
const;
257 bool shifted =
false,
267 double at(
double x )
const;
270 double derivative(
double x,
unsigned n = 1 )
const;
282 void reset(
unsigned order = 3,
285 bool shifted =
false,
289 void setOrder(
unsigned order );
292 void setNbDer(
unsigned nder );
295 void setLength(
size_t length );
302 unsigned nder()
const;
305 size_t length()
const;
309 size_t index(
double x )
const;
310 bool is_valid(
size_t index )
const;
311 void setArray(
unsigned nder,
size_t length );
339 double operator() (
int x )
const;
341 double at(
int x )
const;
353 void reset(
unsigned order = 3,
float scale = 1.,
bool shifted =
false );
356 void setOrder(
unsigned order );
359 void setScale(
float scale );
362 void setShifted(
bool shifted =
true );
365 void setCentered(
bool centered =
true );
376 #endif // AIMSALGO_MATH_BSPLINE_H
1D B-Spline functions centered on 0, recursively evaluated at run time.
std::vector< std::vector< double > > _values
static double at(double x)
static double derivative(double x)
float scale() const
spline scale
static double spline(double x)
Pre-computed B-Spline values In the "order 0" case, the array is not used (the analytical expression ...
bool shifted() const
is shifted ?
static double spline(double value)
static double derivative2(double x)
Centered and scaled B-Spline function, evaluated at run time.
unsigned order() const
Get parameters @ { spline order.
std::vector< double > _values
bool centered() const
is centered ?
*Centered and *scaled B-Spline function, evaluated at run time.
Discrete B-Splines B-Spline pre sampled only on integral values.