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

compare a periodic b-spline with a sine More...

#include <iostream>
#include <assert.h>
#include <vspline/vspline.h>

Go to the source code of this file.

Functions

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

Detailed Description

compare a periodic b-spline with a sine

This is a simple example using a periodic b-spline over just two values: 1 and -1. This spline is used to approximate a sine function. You pass the spline's desired degree on the command line. Next you enter a number (interpreted as degrees) and the program will output the sine and the 'splinus' of the given angle. As you can see when playing with higher degrees, the higher the spline's degree, the closer the match with the sine. So apart from serving as a very simple demonstration of using a 1D periodic b-spline, it teaches us that a periodic b-spline can approximate a sine. To show off, we use long double as the spline's data type. This program also shows a bit of functional programming magic, putting together the 'splinus' functor from several of vspline's functional bulding blocks.

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

Definition in file splinus.cc.

Function Documentation

◆ main()

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

Definition at line 56 of file splinus.cc.