Faster Version of canonical eval
There is a only-numpy implementation of canonical_eval, which seems to be faster than the current (jit compiled) version:
>>> import numpy as np
>>> import minterpy as mp
>>> import timeit
>>> def numpy_canonical_eval(pts,exponents, coeffs):
>>> return np.dot(np.prod(np.power(pts[:,None,:],exponents[None,:,:]),axis=-1),coeffs)
For my machine, it then looks like:
>>> mi = mp.MultiIndex.from_degree(4,6,3)
>>> m = mi.exponents
>>> c = np.random.random(len(mi))
>>> poly = mp.CanonicalPolynomial(c,mi)
>>> N = 3000
>>> a = np.arange(mi.spatial_dimension*N,dtype=float).reshape(N,mi.spatial_dimension) + 10
>>> assert np.allclose(numpy_canonical_eval(a,m,c),poly(a))
>>> %timeit numpy_canonical_eval(a,m,c)
252 ms ± 3.84 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
>>> %timeit poly(a)
503 ms ± 3.75 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
So maybe we shall use the numpy version?