vspline 1.1.0
Generic C++11 Code for Uniform B-Splines
Typedefs | Enumerations | Functions
eval.cc File Reference

simple demonstration of creation and evaluation of a b-spline More...

#include <iostream>
#include <iomanip>
#include <ctime>
#include <chrono>
#include <vspline/vspline.h>

Go to the source code of this file.

Typedefs

typedef double dtype
 
typedef double rc_type
 

Enumerations

enum  { vsize = vspline::vector_traits<dtype>::vsize }
 

Functions

template<class ev_type >
void speed_test (ev_type &ev, std::size_t nr_ev)
 
int main (int argc, char *argv[])
 

Detailed Description

simple demonstration of creation and evaluation of a b-spline

takes a set of knot point values from std::cin, calculates a 1D b-spline over them, and evaluates it at coordinates taken from std::cin. The output shows how the coordinate is split into integral and real part and the result of evaluating the spline at this point. Note how the coordinate is automatically folded into the defined range.

Two evaluations are demonstrated, using unvectorized and vectorized input/output.

Since this is a convenient place to add code for testing evaluation speed, you may pass a number on the command line. eval.cc will then perform as many evaluations and print the time it took. The evaluations will be distributed to several threads, so there is quite a bit of overhead; pass numbers from 1000000 up to get realistic timings.

compile: ./examples.sh eval.cc

compare speed test results from different compilers/back-ends, using 'echo' to provide the arguments normally taken from cin. This invocation runs the test with a periodic degree-19 spline over knot points 0 and 1 and only shows the name of the binary and the result of the speed test:

for f in eval++; do echo $f;echo 19 2 0 1 . .5 | ./$f 100000000 | grep took; done

this will produce output like: hwy_eval_clang++ 100000000 evaluations took 2229 ms hwy_eval_g++ 100000000 evaluations took 2527 ms stds_eval_clang++ 100000000 evaluations took 3401 ms stds_eval_g++ 100000000 evaluations took 2351 ms vc_eval_clang++ 100000000 evaluations took 3281 ms vc_eval_g++ 100000000 evaluations took 3385 ms vs_eval_clang++ 100000000 evaluations took 3883 ms vs_eval_g++ 100000000 evaluations took 5479 ms

note how both the back-end and the compiler make a difference, highway and clang++ currently coming out on top on my system. This is a moving target, as both the back-ends and the compilers evolve.

Definition in file eval.cc.

Typedef Documentation

◆ dtype

typedef double dtype

Definition at line 93 of file eval.cc.

◆ rc_type

typedef double rc_type

Definition at line 94 of file eval.cc.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
vsize 

Definition at line 96 of file eval.cc.

Function Documentation

◆ main()

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

Definition at line 112 of file eval.cc.

◆ speed_test()

template<class ev_type >
void speed_test ( ev_type ev,
std::size_t  nr_ev 
)

Definition at line 103 of file eval.cc.