Newton evaluation with multiple coefficient sets (multiple polynomials at once) is "slow"
I think we've collected enough feedback that evaluating Newton polynomials in minterpy is somehow "slow" (I have no objective number to show, yet, thus the quote mark) that the issue warrants further investigation.
This issue is raised mainly from the evaluation of Lagrange monomials in the context of regression, where basically multiple sets of Newton polynomial coefficients are evaluated at numerous query points. Here, the order of complexity of Newton polynomial evaluation would be at least multiplied by the number of polynomials (i.e., the number of coefficient sets). As the number of monomials can be quite large, this exposes a pain point not typically run into.
Here's a simple test to measure the time:
>>> import minterpy as mp
>>> import numpy as np
>>> mi = mp.MultiIndexSet.from_degree(2, 50, 2) # 2012 monomials
>>> lag_poly = mp.LagrangePolynomial(mi)
>>> %timeit newton_coeffs = mp.get_transformation(lag_poly, mp.NewtonPolynomial).transformation_operator.array_repr_full
22.5 ms ± 1.13 ms per loop (mean ± std. dev. of 7 runs, 1 loop each
>>> newton_poly = mp.NewtonPolynomial(mi, newton_coeffs)
>>> xx = np.random.rand(10000, 2)
>>> %timeit newton_poly(xx) # only from ipython/jupyter shell
2min 33s ± 11.6 s per loop (mean ± std. dev. of 7 runs, 1 loop each)
I have no comparison yet but I feel that the evaluation of this high-degree low-dimensional polynomials (i.e., evaluating 2012 polynomials on 10'000 query points) should be faster than 2.5 minutes. With degree 80 (about double the number of monomials), it takes much much longer to "%timeit", at least on my laptop.
I'm assigning this Issue to me as I already did a preliminary profiling and might have some ideas on how the evaluation can be improved a bit. I still need to do the benchmarking more properly to show and make a better comparison. Hopefully, a merge request with a possible improvement is coming up in the next few days.