Skip to content

Rvalue ref#3

Merged
alexandrehoffmann merged 19 commits into
mainfrom
rvalue_ref
Jul 24, 2026
Merged

Rvalue ref#3
alexandrehoffmann merged 19 commits into
mainfrom
rvalue_ref

Conversation

@alexandrehoffmann

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 from const Function& to Function&&.
  • 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 ret variables) 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_product is started from fx.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_product is started from fx.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_product is started from fx.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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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::forward but the file does not include <utility>, which is where std::forward is declared. To keep this header self-contained, either add <utility> or avoid std::forward here.
	return adaptQuadrature(std::forward<Function>(f)); 

include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:203

  • This uses std::forward but the file does not include <utility>, which is where std::forward is declared. To keep this header self-contained, either add <utility> or avoid std::forward here.
	return isfinite(leftIntegral) ? integrate(std::forward<Function>(f), xmin, xmax) : NumTraits<LongScalar>::NaN;

include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:223

  • This uses std::forward but the file does not include <utility>, which is where std::forward is declared. To keep this header self-contained, either add <utility> or avoid std::forward here.
		? integrate(std::forward<Function>(f), xmin, xmax) 
		: NumTraits<LongScalar>::NaN;

include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:246

  • This uses std::forward but the file does not include <utility>, which is where std::forward is declared. To keep this header self-contained, either add <utility> or avoid std::forward here.
		? integrateRightInfinite(std::forward<Function>(f), xmin) 
		: NumTraits<LongScalar>::NaN;

Comment thread include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase.hpp Outdated
Comment thread include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp
@alexandrehoffmann
alexandrehoffmann merged commit c86ba24 into main Jul 24, 2026
5 checks passed
@alexandrehoffmann
alexandrehoffmann deleted the rvalue_ref branch July 24, 2026 14:48
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.

2 participants