There are many interpolation libraries in Boost, but all of them are one-dimensional interpolations. Is there a way I can try to make them work for 2-dimensional interpolation?
By default one uses the interpolation for 1-dimension like this
#include <iostream>
#include <boost/math/interpolators/cardinal_cubic_b_spline.hpp>
#include <vector>
int main(int argc, char *argv[])
{
//f is the data
std::vector<double> f{0.01, -0.02, 0.3, 0.8, 1.9, -8.78, -22.6};
//the start of the functions domain
double x0 = 0;
//step size
double dx = 0.01;
boost::math::interpolators::cardinal_cubic_b_spline<double> spline(f.begin(), f.end(), x0, dx);
//find the interpolant at a point
double y = spline(0.055);
std::cout << y << std::endl;
return 0;
}
This example is taken from their official documentation.
Can I do 2-dimensional interpolation using Boost? Can you suggest any other header-only template-based C++ library that can help me accomplish this job?
In the search for 2d interpolation function, I came across
- https://www.alglib.net, but this library has its own implementation of arrays. My code uses the STL vector library to store data, so using this means I'll have to change a lot of my codebase.

