treeweave

treeweave turns repeated calls to a costly function into a one-time fit plus fast polynomial evaluation.

#include <treeweave/treeweave.hpp>
auto fn = treeweave::fit([](double s) { double a=0; for(int k=1;k<=1000;++k) a+=std::pow(k,-s); return a; }, 2.0, 10.0, 1e-10);
double y = fn(3.5);   // evaluate a polynomial, not the original function

Call it from C++, header-only or compiled. C, Fortran, Python, Julia, MATLAB/Octave and JavaScript/TypeScript call it through a stable C ABI.

GitHub · Releases · Issues · License (BSD-3-Clause) · Benchmarks dashboard