Rvalue ref#3
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the numerical integration/quadrature APIs to accept callables via forwarding references (Function&&) instead of const Function&, enabling use of mutable call operators and avoiding unnecessary const-qualification constraints across fixed and adaptive quadrature implementations.
Changes:
- Switched multiple
integrate*/estimateIntegral*entry points fromconst Function&toFunction&&. - Propagated the new callable-passing style through adaptive quadrature base/derived implementations and some internal forwarding sites.
- Simplified a couple of return paths (introducing local
retvariables) while adjusting forwarding.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| include/LNIT/GaussLaguerreQuadrature.hpp | Updates semi-infinite integration API to take Function&&. |
| include/LNIT/GaussLaguerreQuadrature_impl.hpp | Updates implementations to match Function&& callable passing. |
| include/LNIT/GaussHermiteQuadrature.hpp | Updates Hermite quadrature integrate API to take Function&&. |
| include/LNIT/GaussHermiteQuadrature_impl.hpp | Updates implementation to match Function&& callable passing. |
| include/LNIT/AdaptiveQuadratures/GLCCAdaptiveQuadrature.hpp | Updates derived adaptive quadrature hooks to take Function&&. |
| include/LNIT/AdaptiveQuadratures/GLCCAdaptiveQuadrature_impl.hpp | Updates GL/CC adaptive implementations to match Function&&. |
| include/LNIT/AdaptiveQuadratures/GaussLegendreAdaptiveQuadrature.hpp | Updates derived adaptive quadrature hooks to take Function&&. |
| include/LNIT/AdaptiveQuadratures/GaussLegendreAdaptiveQuadrature_impl.hpp | Updates Gauss-Legendre adaptive implementations to match Function&&. |
| include/LNIT/AdaptiveQuadratures/ClenshawCurtisHybridAdaptiveQuadrature.hpp | Updates derived adaptive quadrature hooks to take Function&&. |
| include/LNIT/AdaptiveQuadratures/ClenshawCurtisHybridAdaptiveQuadrature_impl.hpp | Updates hybrid adaptive implementations to match Function&&. |
| include/LNIT/AdaptiveQuadratures/ClenshawCurtisAdaptiveQuadrature.hpp | Updates derived adaptive quadrature hooks to take Function&&. |
| include/LNIT/AdaptiveQuadratures/ClenshawCurtisAdaptiveQuadrature_impl.hpp | Updates Clenshaw-Curtis adaptive implementations to match Function&&. |
| include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase.hpp | Updates public adaptive quadrature APIs to take Function&&. |
| include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp | Updates base implementations to forward Function&& through adaptive execution paths. |
Comments suppressed due to low confidence (3)
include/LNIT/GaussLaguerreQuadrature_impl.hpp:25
std::inner_productis started fromfx.end(), which dereferences the end iterator/sentinel and results in undefined behavior (and incorrect integrals). The third argument should be the beginning of the transformed range.
This issue also appears on line 32 of the same file.
constexpr LongScalar GaussLaguerreQuadrature<Scalar, LongScalar>::integrateLeftInfinite(Function&& f, const Scalar& a) const
{
const auto fx = s_xi | std::views::transform([&f, &a](const Scalar& x) -> LongScalar
{
return f(a - x);
include/LNIT/GaussLaguerreQuadrature_impl.hpp:36
std::inner_productis started fromfx.end(), which dereferences the end iterator/sentinel and results in undefined behavior (and incorrect integrals). The third argument should be the beginning of the transformed range.
constexpr LongScalar GaussLaguerreQuadrature<Scalar, LongScalar>::integrateRightInfinite(Function&& f, const Scalar& a) const
{
const auto fx = s_xi | std::views::transform([&f, &a](const Scalar& x) -> LongScalar
{
return f(x + a);
include/LNIT/GaussHermiteQuadrature_impl.hpp:29
std::inner_productis started fromfx.end(), which dereferences the end iterator/sentinel and results in undefined behavior (and incorrect integrals). The third argument should be the beginning of the transformed range.
constexpr LongScalar GaussHermiteQuadrature<Scalar, LongScalar>::integrate(Function&& f) const
{
const auto fx = s_xi | std::views::transform([&f](const Scalar& x) -> LongScalar
{
return f(x);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (4)
include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:185
- This uses
std::forwardbut the file does not include<utility>, which is wherestd::forwardis declared. To keep this header self-contained, either add<utility>or avoidstd::forwardhere.
return adaptQuadrature(std::forward<Function>(f));
include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:203
- This uses
std::forwardbut the file does not include<utility>, which is wherestd::forwardis declared. To keep this header self-contained, either add<utility>or avoidstd::forwardhere.
return isfinite(leftIntegral) ? integrate(std::forward<Function>(f), xmin, xmax) : NumTraits<LongScalar>::NaN;
include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:223
- This uses
std::forwardbut the file does not include<utility>, which is wherestd::forwardis declared. To keep this header self-contained, either add<utility>or avoidstd::forwardhere.
? integrate(std::forward<Function>(f), xmin, xmax)
: NumTraits<LongScalar>::NaN;
include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:246
- This uses
std::forwardbut the file does not include<utility>, which is wherestd::forwardis declared. To keep this header self-contained, either add<utility>or avoidstd::forwardhere.
? integrateRightInfinite(std::forward<Function>(f), xmin)
: NumTraits<LongScalar>::NaN;
No description provided.