Skip to content

Cubic interpolation with C++ in Python

License

Notifications You must be signed in to change notification settings

Arsenic-ATG/cubinterpp

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cubinterpp

Cubic interpolation with C++ in Python.

image

Introduction

This C++ header library features tools for piecewise cubic interpolation.

Currently, only 1D interpolation is supported, however, future released are planned to extend the library to higher dimensions.

The library features three kinds of different interpolation types:

  • Monotone cubic interpolation
  • Akima spline interpolation
  • Natural cubic spline interpolation

All classes are templatized and support the STL's vector types.

The accompanying python script in cubinterpp compares the three interpolation types.

Usage

The following instructions show how to build and test the cubinterpp header library in a python environment.

Prerequisites

  • C++ compiler, e.g. gcc
  • cmake: to use the provided cmake configuration
  • pybind11: to compile the library header into a python module
  • mlpyqtgraph: to plot the example's results

Building

To build the header library for usage in Python, it's recommended to use cmake. An appropriate cmake configuration is provided in the main CMakeLists.txt. Prior to compilation, the required external libraries are downloaded automatically using the cmake FetchContent module. Prior to building, make sure cmake is installed and configured with a C++ compiler like e.g. gcc.

Then build using:

cmake build

This should build the library in the build directory and automatically copy the library file cubic_spline.*.so into the cubinterpp directory.

Interpolating and plotting the results

A python program is provided to compare the three interpolation types. Data preparation and visualization is done in python with mlpyqtgraph.

In order to run the python program, it's recommended to install uv and issue:

uv run cubinterpp 

This should install all required python dependencies automatically and run the python program that does the interpolation and plotting, resulting in the comparison plot shown at the top of this document.

License

An MIT style license applies for cubinterpp , see the LICENSE file for more details.

About

Cubic interpolation with C++ in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 82.9%
  • Python 9.5%
  • CMake 7.6%