Refactor adaptive quadrature interval handling#4
Merged
Conversation
Updated the scaling factor and improved interval handling in the adaptive quadrature implementation. Added checks for finite integrals and adjusted the logic for adding intervals to capture the entire support.
There was a problem hiding this comment.
Pull request overview
Refactors AdaptiveQuadratureBase::integrateWithHints interval construction to better cover the integrand’s support, while also simplifying several integration helpers’ return logic.
Changes:
- Adjusts the peak-neighborhood scaling factor and refactors how hint-based peak intervals are created/merged.
- Adds logic intended to insert “gap” intervals between peak intervals and extends the interval set at the front/back using Gauss–Laguerre estimates.
- Simplifies several functions by returning conditional expressions directly (removing temporary
retvariables).
Comments suppressed due to low confidence (1)
include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase_impl.hpp:153
- The "Second pass" loop inserts into m_intervals while iterating over it, which changes indices and causes the next iteration to compare an inserted gap interval against the following original interval. That makes the assertion fail (gap.second == next.first) and can also lead to incorrect/degenerate intervals. This block also assumes m_intervals is non-empty (mu could be empty), but later code uses front()/back(). Consider rebuilding the expanded interval list in a separate vector and early-returning when no hint intervals were produced.
// Second pass: add interval in between the previously computed intervals
for (size_t i=0; i+1!=m_intervals.size(); ++i)
{
assert(m_intervals[i].second != m_intervals[i+1].first);
m_intervals.emplace(std::next(m_intervals.begin(), i + 1), m_intervals[i].second, m_intervals[i+1].first);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updated the scaling factor and improved interval handling in the adaptive quadrature implementation. Added checks for finite integrals and adjusted the logic for adding intervals to capture the entire support.