I am attempting to use cubic Hermite interpolation from the boost library in order to interpolate non-equispaced data. However, implementing the example from the documentation produces the error "C2955: 'boost::math::interpolators::cubic_hermite': use of class template requires template argument list".
Here is my code:
CMakeLists.txt
cmake_minimum_required(VERSION 3.18)
project(CubicHermiteTest LANGUAGES CXX)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
#set(Boost_DEBUG ON)
set(BOOST_ROOT "C:/local/boost_1_76_0/boost" )
set(BOOST_INCLUDEDIR "C:/local/boost_1_76_0" )
set(BOOST_LIBRARYDIR "C:/local/boost_1_76_0/lib64-msvc-14.2" )
find_package(Boost 1.76.0 REQUIRED)
add_executable(CubicHermiteTest
main.cpp
)
target_link_libraries(CubicHermiteTest Boost::boost)
main.cpp
#include <iostream>
#include <vector>
#include <boost/math/interpolators/cubic_hermite.hpp>
int main()
{
std::vector<double> x{1, 5, 9 , 12};
std::vector<double> y{8,17, 4, -3};
std::vector<double> dydx{5, -2, -1,2};
using boost::math::interpolators::cubic_hermite;
auto spline = cubic_hermite(std::move(x), std::move(y), std::move(dydx));
// evaluate at a point:
double z = spline(3.4);
// evaluate derivative at a point:
double zprime = spline.prime(3.4);
std::cout << zprime << '\n';
}
The error is generated when calling cubic_hermite. What could be the reason for the error?