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; }
152 double at(
double x )
const;
230 double at(
double x )
const;
267 double at(
double x )
const;
341 double at(
int x )
const;
Centered and scaled B-Spline function, evaluated at run time.
virtual void setScale(float scale)
scale
bool centered() const
is centered ?
bool shifted() const
is shifted ?
BSpline & operator=(const BSpline &other)
virtual double operator()(double x) const
Compute value.
virtual double at(double x) const
spline value at point x
BSpline(unsigned order=3, float scale=1., bool shifted=false)
float scale() const
spline scale
unsigned order() const
Get parameters { spline order.
virtual void setCentered(bool centered)
centered
virtual const Point2dd & support() const
Get the inferior and superior boundaries of the function support (i.e.
virtual double derivative(double x, unsigned n=1) const
n-th derivative of the spline at point x
virtual void setSupport()
BSpline(const BSpline &other)
virtual void setShifted(bool shifted)
shifted
virtual void reset(unsigned order=3, float scale=1., bool shifted=false)
Set parameters { (Re)set all parameters.
virtual void setOrder(unsigned order)
order
Discrete B-Splines B-Spline pre sampled only on integral values.
virtual void setScale(float scale)
scale
virtual double operator()(int x) const
Get value.
virtual void reset(unsigned order=3, float scale=1., bool shifted=false)
Set parameters Be aware that a call to reset, setOrder, setNbDer and setLength will trigger a realloc...
DiscreteBSpline & operator=(const DiscreteBSpline &other)
virtual double at(int x) const
virtual void setCentered(bool centered=true)
centered
DiscreteBSpline(const DiscreteBSpline &other)
std::vector< double > _values
DiscreteBSpline(unsigned order=3, float scale=1., bool shifted=false)
Constructor/Destructor/Copy.
virtual void setShifted(bool shifted=true)
shifted
virtual void setOrder(unsigned order)
order
virtual ~DiscreteBSpline()
*Centered and *scaled B-Spline function, evaluated at run time.
virtual double at(double x) const
Compute valuespline value at point x.
FastBSpline(const FastBSpline &other)
FastBSpline(unsigned order=3, float scale=1., bool shifted=false)
virtual double derivative(double x, unsigned n=1) const
n-th derivative of the spline at point x
FastBSpline & operator=(const FastBSpline &other)
Pre-computed B-Spline values In the "order 0" case, the array is not used (the analytical expression ...
TabulBSpline & operator=(const TabulBSpline &other)
virtual void setOrder(unsigned order)
order
void setArray(unsigned nder, size_t length)
std::vector< std::vector< double > > _values
size_t index(double x) const
TabulBSpline(const TabulBSpline &other)
virtual unsigned nder() const
Get parametersnumber of derivative stored.
virtual double at(double x) const
Get valuespline value at point x.
virtual void setNbDer(unsigned nder)
number of derivative stored
bool is_valid(size_t index) const
TabulBSpline(unsigned order=3, unsigned nder=1, float scale=1., bool shifted=false, size_t length=std::numeric_limits< unsigned short >::max() - 1)
virtual size_t length() const
array length
virtual double derivative(double x, unsigned n=1) const
n-th derivative of the spline at point x
virtual void reset(unsigned order=3, unsigned nder=1, float scale=1., bool shifted=false, size_t length=std::numeric_limits< unsigned short >::max() - 1)
Set parameters Be aware that a call to reset, setOrder, setNbDer and setLength will trigger a realloc...
virtual void setLength(size_t length)
array length
static double spline(double value)
1D B-Spline functions centered on 0, recursively evaluated at run time.
static double derivative2(double x)
static double at(double x)
static double derivative(double x)
static double spline(double x)