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 --QuadratureFunction-- QuadratureRule #176

Merged
merged 7 commits into from
Sep 17, 2023

Conversation

lxvm
Copy link
Collaborator

@lxvm lxvm commented Sep 16, 2023

Hi,

This pr adds a QuadratureFunction algorithm that allows the user to pass in a function that returns nodes, x, and weights, w, and computes sum(w .* f.(x)). This could serve as a backend for other integration algorithms we would like to support, such as the trapezoidal rule and FastGaussQuadrature.jl rules.

@lxvm lxvm mentioned this pull request Sep 17, 2023
4 tasks
@@ -12,10 +12,12 @@ The following algorithms are available:
- `CubaDivonne`: Divonne from Cuba.jl. Requires `using IntegralsCuba`. Works only for `>1`-dimensional integrations.
- `CubaCuhre`: Cuhre from Cuba.jl. Requires `using IntegralsCuba`. Works only for `>1`-dimensional integrations.
- `GaussLegendre`: Uses Gauss-Legendre quadrature with nodes and weights from FastGaussQuadrature.jl.
- `QuadratureFunction`: Accepts a user-defined function that returns nodes and weights.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so sure of the naming on this, and also it sounds more like a function than an algorithm. Maybe GeneralQuadrature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or QuadratureRule, i.e. similar to TrapezoidalRule?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think GeneralQuadrature would sound too similar to this work https://github.com/JoshuaTetzner/GeneralizedGaussianQuadrature.jl

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a repo with 0 stars, I'm not worried about people knowing that. I'm more worried that people know ODEFunction, SDEFunction, NonlinearFunction, BVPFunction, etc. as a standard in SciML for the SciMLFunction interface https://docs.sciml.ai/SciMLBase/stable/interfaces/SciMLFunctions/, but here it's breaking the rule.

I think QuadratureRule sounds good.

@ChrisRackauckas
Copy link
Member

This looks great. Only some bikeshedding on the naming and I think this is good to go.

@IlianPihlajamaa
Copy link
Contributor

Would it be good to also support vector-valued integrands? Right now you assert nout==1 in the evalrule function.

@lxvm lxvm changed the title add QuadratureFunction add __QuadratureFunction__ QuadratureRule Sep 17, 2023
@lxvm lxvm changed the title add __QuadratureFunction__ QuadratureRule add **QuadratureFunction** QuadratureRule Sep 17, 2023
@lxvm lxvm changed the title add **QuadratureFunction** QuadratureRule add --QuadratureFunction-- QuadratureRule Sep 17, 2023
@lxvm
Copy link
Collaborator Author

lxvm commented Sep 17, 2023

Would it be good to also support vector-valued integrands? Right now you assert nout==1 in the evalrule function.

Thanks, I removed the check.

@lxvm
Copy link
Collaborator Author

lxvm commented Sep 17, 2023

I renamed to QuadratureRule and rebased onto master. @ChrisRackauckas does this look ready?

src/quadrules.jl Outdated Show resolved Hide resolved
maxiters = nothing)
prob = build_problem(cache)
if isinplace(prob)
error("QuadratureRule does not support inplace integrands.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason it doesn't? That seems like it should be possible. I guess open an issue on this as something to do later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't know the element type of the output array to allocate. This will be fixed by the IntegralFunction PR

@ChrisRackauckas ChrisRackauckas merged commit 72c848e into SciML:master Sep 17, 2023
5 checks passed
@lxvm lxvm deleted the quadrule branch December 30, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants