75#include <vigra/accumulator.hxx> 
   76#include <vigra/multi_math.hxx> 
   79int main ( 
int argc , 
char * argv[] )
 
   83    std::cerr << 
"pass the spline's degree, the number of iterations"  
   85              << 
"and optionally the supersampling factor" 
   90  int degree = std::atoi ( argv[1] ) ;
 
   92  assert ( degree >= 0 && degree <= vspline_constants::max_degree ) ;
 
   94  int iterations = 1 + std::atoi ( argv[2] ) ;
 
   98  long double widen = 2.0 ;
 
  101    widen = atof ( argv[3] ) ;
 
  103  assert ( widen >= 1.0 ) ;
 
  105  int wsz = sz * widen ;
 
  107  vigra::MultiArray < 1 , long double > original ( wsz ) ;
 
  108  vigra::MultiArray < 1 , long double > target ( wsz ) ;
 
  113  std::random_device rd ;
 
  114  std::mt19937 gen ( rd() ) ;
 
  116  std::uniform_real_distribution<> dis ( -1 , 1 ) ;
 
  117  for ( 
int x = 0 ; x < sz ; x++ )
 
  118    original [ x ] = dis ( gen ) ;
 
  129  vigra::MultiArrayView < 1 , long double > initial
 
  130    ( vigra::Shape1(sz) , original.data() ) ;
 
  134  bsp.prefilter ( initial ) ;
 
  144  for ( 
int x = 0 ; x < wsz ; x++ )
 
  145    target [ x ] = ev ( (
long double) ( x ) / (
long double) ( widen ) ) ;
 
  169  bspw.prefilter ( original ) ;
 
  184  auto periodic_ev = gate + evw ;
 
  189  long double cumulated_offset = 0.0 ;
 
  191  for ( 
int n = 0 ; n < iterations ; n++ )
 
  193    using namespace vigra::multi_math ;
 
  194    using namespace vigra::acc;
 
  200    long double offset = 1000.0 * dis ( gen ) ;
 
  207    if ( n == iterations - 1 )
 
  208      offset = - cumulated_offset ;
 
  210    cumulated_offset += offset ;
 
  212    if ( n > ( iterations - 10 ) )
 
  213      std::cout << 
"iteration " << n << 
" offset " << offset
 
  214                << 
" cumulated offset " << cumulated_offset << std::endl ;
 
  221    for ( 
int x = 0 ; x < wsz ; x++ )
 
  223      auto arg = x + offset ;
 
  224      target [ x ] = periodic_ev ( arg ) ;
 
  233    bspw.prefilter ( target ) ;
 
  240    vigra::MultiArray < 1 , long double > error_array
 
  241      ( vigra::multi_math::squaredNorm ( target - original ) ) ;
 
  243    AccumulatorChain < long double , Select < Mean, Maximum > > ac ;
 
  244    extractFeatures ( error_array.begin() , error_array.end() , ac ) ;
 
  246    if ( n > ( iterations - 10 ) )
 
  248      if ( n == iterations - 1 )
 
  249        std::cout << 
"final result, evaluating at original unit steps" 
  251      std::cout << 
"signal difference Mean:    " 
  252                << sqrt(get<Mean>(ac)) << std::endl;
 
  253      std::cout << 
"signal difference Maximum: " 
  254                << sqrt(get<Maximum>(ac)) << std::endl;
 
vspline::evaluator< coordinate_type, float > ev_type
 
class evaluator encodes evaluation of a spline-like object. This is a generalization of b-spline eval...
 
int main(int argc, char *argv[])
 
vspline::periodic_gate< rc_type, _vsize > periodic(rc_type lower, rc_type upper)
factory function to create a periodic_gate type functor given a lower and upper limit for the allowed...
 
class bspline now builds on class bspline_base, adding coefficient storage, while bspline_base provid...
 
includes all headers from vspline (most of them indirectly)