Proposed new feature or change:
I have a need for a function polyvalnd which is just like polyval, polyval2d, or polyval3d, but that handles arbitrary dimensions. Surprisingly this function does not already exist in Numpy. It is trivial to implement with existing non-public utilities in Numpy, i.e.,
from numpy.polynomial import polyutils as pu
from numpy.polynomial.polynomial import polyval
def polyvalnd(x, c):
"""Evaluate an arbitrary multivariate polynomial."""
return pu._valnd(polyval, c, *x)
Of course there is a decision to make about the signature, because with polyval2d and polyval3d the arguments are passed like this:
polyval2d(x, y, c)
polyval3d(x, y, c)
So we would have to decide which of these we prefer:
polyvalnd(p, q, ..., x, y, z, c) # ordinates first
polyvalnd(c, p, q, ..., x, y, z) # ordinates last
polyvalnd([p, q, ..., x, y, z], c) # ordinates first, in an list
This has been suggested before in #6071, but my needs are much narrower: I don't need N-D Chebyshev polynomials, etc.
My application is that I need some multivariate polynomial test data for a multivariate interpolation scheme that I am working on with a student.
Proposed new feature or change:
I have a need for a function
polyvalndwhich is just likepolyval,polyval2d, orpolyval3d, but that handles arbitrary dimensions. Surprisingly this function does not already exist in Numpy. It is trivial to implement with existing non-public utilities in Numpy, i.e.,Of course there is a decision to make about the signature, because with
polyval2dandpolyval3dthe arguments are passed like this:So we would have to decide which of these we prefer:
This has been suggested before in #6071, but my needs are much narrower: I don't need N-D Chebyshev polynomials, etc.
My application is that I need some multivariate polynomial test data for a multivariate interpolation scheme that I am working on with a student.