vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Functions | Variables
self_test.cc File Reference

test consistency of precomputed data, prefiltering and evaluation More...

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <limits>
#include <numeric>
#include <assert.h>
#include <random>
#include <vspline/vspline.h>

Go to the source code of this file.

Functions

template<typename dtype >
dtype self_test (int degree, dtype threshold, dtype strict_threshold)
 
int main (int argc, char *argv[])
 

Variables

long double circular_test_previous
 

Detailed Description

test consistency of precomputed data, prefiltering and evaluation

the self-test uses three entities: a unit pulse, the reconstruction kernel (which is a unit-spaced sampling of the b-spline basis function's values at integer arguments) and the prefilter. These data have a few fundamental relations we can test:

Performing the tests also assures us that the evaluation machinery with it's 'weight matrix' does what's intended, and that access to the basis function and it's derivatives (see basis_functor) functions correctly.

With rising spline degree, the test is ever more demanding. this is reflected in the maximum error returned for every degree: it rises with the spline degree. With the complex operations involved, seeing a maximal error in the order of magnitude of 1e-12 for working with long doubles seems reasonable enough (on my system).

I assume that the loss of precision with high degrees is mainly due to the filter's overall gain becoming very large. Since the gain is applied as a factor before or during prefiltering and prefiltering has the reverse effect, in the sum we end up having the effect of first multiplying with, then dividing by a very large number, 'crushing' the values to less precision. In bootstrap.cc, I perfom the test with GMP high precision floats and there I can avoid the problem, since the magnitude of the numbers I use there is well beyond the magnitude of the gain occuring with high spline degrees. So the conclusion is that high spline degrees can be used, but may not produce very precise results, since the normal C++ types are hard pressed to cope with the dynamic range covered by the filter.

The most time is spent calculating the basis function values recursively using cdb_bspline_basis, for cross-reference.

compile: clang++ -O3 -std=c++11 self_test.cc -o self_test -pthread

Definition in file self_test.cc.

Function Documentation

◆ main()

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

Definition at line 419 of file self_test.cc.

◆ self_test()

template<typename dtype >
dtype self_test ( int  degree,
dtype  threshold,
dtype  strict_threshold 
)

Definition at line 93 of file self_test.cc.

Variable Documentation

◆ circular_test_previous

long double circular_test_previous

Definition at line 90 of file self_test.cc.