vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
|
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] |
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.
#define degree_limit 46 |
Definition at line 89 of file bootstrap.cc.
#define mpf_bits 512 |
Definition at line 93 of file bootstrap.cc.
void _fill_basis_table | ( | int | x2, |
int | degree | ||
) |
Definition at line 147 of file bootstrap.cc.
mpq_class & access_table | ( | int | degree, |
int | x2 | ||
) |
Definition at line 118 of file bootstrap.cc.
void backward | ( | mpf_class * | x, |
int | size, | ||
mpf_class | pole | ||
) |
Definition at line 369 of file bootstrap.cc.
void calculate_prefilter_poles | ( | std::vector< mpf_class > & | res, |
int | degree | ||
) |
Definition at line 231 of file bootstrap.cc.
void fill_basis_table | ( | ) |
Definition at line 168 of file bootstrap.cc.
void forward | ( | mpf_class * | x, |
int | size, | ||
mpf_class | pole | ||
) |
Definition at line 355 of file bootstrap.cc.
vspline::xlf_type get_xlf | ( | const mpf_class & | _x | ) |
Definition at line 447 of file bootstrap.cc.
void ldbackward | ( | vspline::xlf_type * | x, |
int | size, | ||
vspline::xlf_type | pole | ||
) |
Definition at line 484 of file bootstrap.cc.
void ldforward | ( | vspline::xlf_type * | x, |
int | size, | ||
vspline::xlf_type | pole | ||
) |
Definition at line 472 of file bootstrap.cc.
void ldtest | ( | int | size, |
const std::vector< mpf_class > & | poles, | ||
int | degree | ||
) |
Definition at line 496 of file bootstrap.cc.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 564 of file bootstrap.cc.
Definition at line 186 of file bootstrap.cc.
void test | ( | int | size, |
const std::vector< mpf_class > & | poles, | ||
int | degree | ||
) |
Definition at line 388 of file bootstrap.cc.
mpq_class basis_table[degree_limit][degree_limit+1] |
Definition at line 111 of file bootstrap.cc.