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

Code to calculate b-spline basis function values at half unit steps, and prefilter poles. More...

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

Go to the source code of this file.

Macros

#define degree_limit   46
 
#define mpf_bits   512
 

Functions

mpq_class & access_table (int degree, int x2)
 
void _fill_basis_table (int x2, int degree)
 
void fill_basis_table ()
 
template<typename dtype >
void newton (dtype &result, dtype x, int ncoeff, dtype *pcoeff)
 
void calculate_prefilter_poles (std::vector< mpf_class > &res, int degree)
 
void forward (mpf_class *x, int size, mpf_class pole)
 
void backward (mpf_class *x, int size, mpf_class pole)
 
void test (int size, const std::vector< mpf_class > &poles, int degree)
 
vspline::xlf_type get_xlf (const mpf_class &_x)
 
void ldforward (vspline::xlf_type *x, int size, vspline::xlf_type pole)
 
void ldbackward (vspline::xlf_type *x, int size, vspline::xlf_type pole)
 
void ldtest (int size, const std::vector< mpf_class > &poles, int degree)
 
int main (int argc, char *argv[])
 

Variables

mpq_class basis_table [degree_limit][degree_limit+1]
 

Detailed Description

Code to calculate b-spline basis function values at half unit steps, and prefilter poles.

These calculations are done using GNU GSL, BLAS and GNU GMP which are not used in other parts of vspline. this file also has code to verify that the precomputed data in <vspline/poles.h> are valid. TODO make that a separate program

In contrast to my previous implementation of generating the precomputed values (prefilter_poles.cc, now gone), I don't compute the values one-by-one using recursive functions, but instead build them layer by layer, each layer using it's predecessor. This makes the process very fast, even for large spline degrees.

In my tests, I found that with the very precise basis function values obtained with GMP, I could get GSL to provide raw values for the prefilter poles up to degree 45, above which it would miss roots. So this is where I set the limit, and I think it's unlikely anyone would ever want more than degree 45. If they do, they'll have to find other polynomial root code.

compile: g++ -O3 -std=gnu++11 bootstrap.cc -obootstrap \ -lgmpxx -lgmp -lgsl -lblas -pthread

run by simply issuing './bootstrap' on the command line. you may want to redirect output to a file. The output should be equal to the values in vspline/poles.h

Definition in file bootstrap.cc.

Macro Definition Documentation

◆ degree_limit

#define degree_limit   46

Definition at line 89 of file bootstrap.cc.

◆ mpf_bits

#define mpf_bits   512

Definition at line 93 of file bootstrap.cc.

Function Documentation

◆ _fill_basis_table()

void _fill_basis_table ( int  x2,
int  degree 
)

Definition at line 147 of file bootstrap.cc.

◆ access_table()

mpq_class & access_table ( int  degree,
int  x2 
)

Definition at line 118 of file bootstrap.cc.

◆ backward()

void backward ( mpf_class *  x,
int  size,
mpf_class  pole 
)

Definition at line 369 of file bootstrap.cc.

◆ calculate_prefilter_poles()

void calculate_prefilter_poles ( std::vector< mpf_class > &  res,
int  degree 
)

Definition at line 231 of file bootstrap.cc.

◆ fill_basis_table()

void fill_basis_table ( )

Definition at line 168 of file bootstrap.cc.

◆ forward()

void forward ( mpf_class *  x,
int  size,
mpf_class  pole 
)

Definition at line 355 of file bootstrap.cc.

◆ get_xlf()

vspline::xlf_type get_xlf ( const mpf_class &  _x)

Definition at line 447 of file bootstrap.cc.

◆ ldbackward()

void ldbackward ( vspline::xlf_type x,
int  size,
vspline::xlf_type  pole 
)

Definition at line 484 of file bootstrap.cc.

◆ ldforward()

void ldforward ( vspline::xlf_type x,
int  size,
vspline::xlf_type  pole 
)

Definition at line 472 of file bootstrap.cc.

◆ ldtest()

void ldtest ( int  size,
const std::vector< mpf_class > &  poles,
int  degree 
)

Definition at line 496 of file bootstrap.cc.

◆ main()

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

Definition at line 564 of file bootstrap.cc.

◆ newton()

template<typename dtype >
void newton ( dtype result,
dtype  x,
int  ncoeff,
dtype pcoeff 
)

Definition at line 186 of file bootstrap.cc.

◆ test()

void test ( int  size,
const std::vector< mpf_class > &  poles,
int  degree 
)

Definition at line 388 of file bootstrap.cc.

Variable Documentation

◆ basis_table

mpq_class basis_table[degree_limit][degree_limit+1]

Definition at line 111 of file bootstrap.cc.