When you want to interpolate a function (match its values on some grid points and approximate it off grid) you:

- Generate a matrix with evaluations of basis function on the grid and find a linear combination of those that fit the original function
- Generate a matrix with evaluations of basis function on arbitrary points in the domain and multiply it with the coefficients of the linear combination

My question: Is there, or why is there no package, that generates those matrices using a macro. Or going even one step further: after determining the coefficients of the linear combination generates code with these coefficients hard coded, and then compiling it.

As an example, Hornerâ€™s method of evaluating polynomials coded up as a macro is extremely fast, the same could be done for Chebyshev polynomials, or splines, etc.

For the first variant, it is relevant how fast a compiled for-loop (e.g. see BasisMatrices) runs compared to a macro that already â€śexpandedâ€ť these two loops. For the second variant, it is relevant how fast a BLAS matrix-vector multiplication is compared to its â€śexpandedâ€ť version (maybe this could also save some memory allocations?).