vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Typedefs | Functions
basis_sample.cc File Reference
#include <deque>
#include <vector>
#include <iostream>
#include <iomanip>
#include <vspline/vspline.h>

Go to the source code of this file.

Typedefs

typedef vspline::basis_functor< long double > bf_type
 basis_sample.cc - access to the b-spline basis functions More...
 

Functions

std::vector< long double > sample_basis (bf_type bfunc, long double x0, long double step, bool normalize=false)
 
int main (int argc, char *argv[])
 

Typedef Documentation

◆ bf_type

typedef vspline::basis_functor< long double > bf_type

basis_sample.cc - access to the b-spline basis functions

Calculate a set of equally-spaced samples of a b-spline basis function This program takes four parameters on the command line:

  • the spline's degree
  • x0, the location of the initial sample
  • step, the distance from one sample to the next
  • normalize - if not zero, result will be normalized These values are fed to 'sample_basis' (see below), which starts by calculating the initial sample and then goes 'both ways' to add more samples. The (optionally normalized) samples are echoed to std::cout. example: basis_sample 3 .05 .25 1 vspline offers access to the b-spline basis functions via a helper object 'basis_functor'. A good part of the calculation of the basis function's value can be done beforehand and only depends on the degree of the basis function. The basis_functor object performs these calculations once when it's created, subsequent evaluations are relatively fast and rely on the initially generated state. For this example, we use long double values - this example is not about speed, but rather about providing precise values. The basis_functor object can also evaluate vectorized data, but in this example we'll only use it's scalar form. 'sample_basis' returns a vector of samples of the basis function if we have the basis function b(x), it returns these values: bf ( x - x0 + step * k ) for all k E N, wherever they are greater than zero. So for X0 = 0 and step = 1, we get the ordinary unit-spaced sampling of the basis function, with x0 != 0 and step == 1 a set of weights as it might be applied to a set of coefficients to evaluate a b-spline, and with step != 1, we get a set of values which follow the shape of the basis function with more or less sample points than the 'normal' unit-spaced sampling. What's surprising is that these non-unit-step samplings (when multiplied with the step width) also are (often very) close to a partition of unity.

Definition at line 76 of file basis_sample.cc.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 125 of file basis_sample.cc.

◆ sample_basis()

std::vector< long double > sample_basis ( bf_type  bfunc,
long double  x0,
long double  step,
bool  normalize = false 
)

Definition at line 78 of file basis_sample.cc.