Skip to content
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

Add Gaussian quadrature methods #126

Closed
4 tasks
gomezzz opened this issue Aug 20, 2021 · 4 comments · Fixed by #141
Closed
4 tasks

Add Gaussian quadrature methods #126

gomezzz opened this issue Aug 20, 2021 · 4 comments · Fixed by #141
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@gomezzz
Copy link
Collaborator

gomezzz commented Aug 20, 2021

Feature

Desired Behavior / Functionality

Currently, torchquad only implements Newton-Cotes formulas as deterministic integration methods. A logical next step would be Gaussian quadrature methods.

What Needs to Be Done

  • Decide on integrators to implement (e.g. Gauss-Legendre
  • Implement integrator in integration folder, should inherit from BaseIntegrator
  • Add docs for it
  • Add tests for it, orient at Newton-Cotes tests

How Can It Be Tested

With new tests!

@gomezzz gomezzz added documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Aug 20, 2021
@elastufka
Copy link
Contributor

Hello, I'm interested in a Torch implementation of Gauss-Legendre quadrature. The code here seems clear enough so I'll see what I can do based on the examples of the existing integrators.

If you have any thoughts on potential pitfalls in such an implementation, or just remarks on things to look out for in general, I'd appreciate it! Or if you know of someone who's already started work on this, even better.

@gomezzz
Copy link
Collaborator Author

gomezzz commented Apr 7, 2022

@elastufka Great to hear! I would suggest to branch out from #137 because this introduces quite some changes in the codebase (and by following the other integrators there your implementation will also support torch, TF, jax and numpy :) )

We'll be merging #137 shortly. Nobody has started work on this to my knowledge. If you want more feedback on implementing feel free to post some thoughts where you want to add things etc.

Thanks!

@elastufka
Copy link
Contributor

@gomezzz Okay, I will do that.

So far everything seems pretty straightforward. One thing that wasn't quite clear from the documentation/code - are the inputs x to the integrals preferentially tensors, or numpy arrays?

@gomezzz
Copy link
Collaborator Author

gomezzz commented Apr 8, 2022

One thing that wasn't quite clear from the documentation/code - are the inputs x to the integrals preferentially tensors, or numpy arrays?

Well the integrand function is user-defined, so inside the user could convert (will break gradient flow though). Internally, torchquad will in the new version generate the data type matching the framework. so torch.tensor , np.array etc.

There are new examples in the docs to illustrate how it works with other frameworks

Making it cross-framework compatible with autoray is very similar to just writing torch. Have a look here, e.g. https://github.com/FHof/torchquad/blob/develop/torchquad/integration/boole.py

Basically you just use anp.sum(...) instead of torch.sum(...) and from autoray import numpy as anp

@elastufka elastufka mentioned this issue Apr 21, 2022
1 task
@gomezzz gomezzz closed this as completed May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants