-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH Add N-D fitting and evaluation methods to the chebyshev.py and polynomial.py library #6071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
You should squash the commits and follow the guidelines in |
@@ -1411,6 +1412,111 @@ def chebgrid3d(x, y, z, c): | ||
return c | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add the new functions to __all__
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And also in the module documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. This is done. I have updated the files to according to your comments.
I like this in general. The tests are a bit skimpy and some of my style comments apply more generally. Once this is settled, it should be extended to the remaining polynomials, although power series will be a bit of an exception. I've thought a bit about making classes for some of this similar to the Polynomial etc. classes but with fewer features. Two other generalization that might be useful in practice are vector valued functions and gradients and Jacobians. If you have any thoughts along those lines I'd like to hear them. |
I'm curious if you actually have a use case for the > 3d case? |
105c7e7
to
125cbcc
Compare
The second commit should be a bit more specific and begin with Now begins the drudgery. We try to keep all 6 polynomials in sync, so functions added to one also need to be added to the remaining 5 and tested. Yep, it's a PITA ;) |
If this goes in, it will also need a mention in |
If `c` has fewer than N dimensions, ones are implicitly appended to its | ||
shape to make it N-D. The shape of the result will be c.shape[3:] + | ||
x1.shape. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs .. versionadded:: 1.11.0
here, followed by a blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grep for other examples.
2caf7d5
to
0bf9fb3
Compare
Added .. versionadded:: 1.11.0. and updated doc/release/1.11.0-notes.rst |
@pbrod, I think you have to update your master and rebase, it seems to me you created a new 1.11 release notes file. This already exists. |
f7b3b43
to
a4ad7b5
Compare
Ok. Thanks. |
Added: chebvalnd, chebgridnd, chebfitnd, chebfitfunc, chebvandernd polvalnd, polygridnd, polyfitnd, polyfitfunc, polyvandernd Also added supporting tests
☔ The latest upstream changes (presumably #6688) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #7735) made this pull request unmergeable. Please resolve the merge conflicts. |
For what it's worth, I was just thinking about trying to implement something like this. I'm also interested in evaluation for N>3, i.e. x,y,z,t; or state spaces, etc. What is the current status of this PR? |
IIRC, it was in decent shape. I was thinking of taking a further look at it in the next few days. |
Looking at this more closely, I'm not sure if it does what I'm looking for. Essentially, I'm after something like a MultiVariatePolynomial helper class, with things like derivatives, integrals, +, *, etc. |
@pbrod This is old but I still think this is useful. Want to pursue this? |
@woodscn I agree that that would be useful. If you are motivated in that direction you may want to put together a PR. |
@pbrod Are you still working on this? looks valuable if you can solve the confict 😄 |
There is another attempt at expanding polynomial fitting to ND in #14151 |
I am closing this as #14151 does the same and more. |
Currently there are no functions in chebyshev.py that do N-dimensional fitting for N>1 This submission is a attempt to fill the above mentioned gap and complements the efforts in numpy#14151. The multidimensional interpolation method implemented here uses the 1D Discrete Cosine Transform (DCT) instead of the vandermonde method. This is a reimplementation of the chebfitfunc function found in numpy#6071. The accuracy of the new interpolation method is better than the old one especially for polynomials of high degrees. Also added domain as input to chebinterpolate in order to interpolate the function over any input domain. Added test_2d_approximation for testing interpolation of a 2D function. Replaced all references to the missing chebfromfunction with chebinterpolate.
Currently there are no functions in chebyshev.py that do N-dimensional fitting for N>1 This submission is a attempt to fill the above mentioned gap and complements the efforts in numpy#14151. The multidimensional interpolation method implemented here uses the 1D Discrete Cosine Transform (DCT) instead of the vandermonde method. This is a reimplementation of the chebfitfunc function found in numpy#6071. The accuracy of the new interpolation method is better than the old one especially for polynomials of high degrees. Also added domain as input to chebinterpolate in order to interpolate the function over any input domain. Added test_2d_approximation for testing interpolation of a 2D function. Replaced all references to the missing chebfromfunction with chebinterpolate.
Currently there are no functions in chebyshev.py that do N-dimensional fitting for N>1 This submission is a attempt to fill the above mentioned gap and complements the efforts in numpy#14151. The multidimensional interpolation method implemented here uses the 1D Discrete Cosine Transform (DCT) instead of the vandermonde method. This is a reimplementation of the chebfitfunc function found in numpy#6071. The accuracy of the new interpolation method is better than the old one especially for polynomials of high degrees. Also added domain as input to chebinterpolate in order to interpolate the function over any input domain. Added test_2d_approximation for testing interpolation of a 2D function. Replaced all references to the missing chebfromfunction with chebinterpolate.
Currently there are no functions in chebyshev.py that do N-dimensional fitting for N>1 This submission is a attempt to fill the above mentioned gap and complements the efforts in numpy#14151. The multidimensional interpolation method implemented here uses the 1D Discrete Cosine Transform (DCT) instead of the vandermonde method. This is a reimplementation of the chebfitfunc function found in numpy#6071. The accuracy of the new interpolation method is better than the old one especially for polynomials of high degrees. Also added domain as input to chebinterpolate in order to interpolate the function over any input domain. Added test_2d_approximation for testing interpolation of a 2D function. Replaced all references to the missing chebfromfunction with chebinterpolate. Made doctest of chebinterpolate more robust.
Currently there are no functions in chebyshev.py that do N-dimensional fitting for N>1 This submission is a attempt to fill the above mentioned gap and complements the efforts in numpy#14151. The multidimensional interpolation method implemented here uses the 1D Discrete Cosine Transform (DCT) instead of the vandermonde method. This is a reimplementation of the chebfitfunc function found in numpy#6071. The accuracy of the new interpolation method is better than the old one especially for polynomials of high degrees. Also added domain as input to chebinterpolate in order to interpolate the function over any input domain. Added test_2d_approximation for testing interpolation of a 2D function. Replaced all references to the missing chebfromfunction with chebinterpolate. Made doctest of chebinterpolate more robust.
Currently there are no functions in chebyshev.py/ polynomial.py that do
This submission is a first implementation to fill the above mentioned gap.
Functions added to chebyshev.py and polynomial.py are:
chebvalnd, chebgridnd, chebfitnd, chebfitfunc, chebvandernd
polyvalnd, polygridnd, polyfitnd, polyfitfunc, polyvandernd
and supporting tests
Examples on use
Visualize the significant coefficients
Evaluate on finer grid
Compute residuals
and plot them