Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
86ef836
Enhance CI workflow for C++ with benchmarks
alexandrehoffmann Jul 24, 2026
5c16782
Enable demo builds in CI configuration
alexandrehoffmann Jul 24, 2026
6d02a97
Add installation of clang-15 and libfmt-dev
alexandrehoffmann Jul 24, 2026
651d1d3
Use typename for dependent type definitions
alexandrehoffmann Jul 24, 2026
f9e51b9
Use typename for dependent type definitions
alexandrehoffmann Jul 24, 2026
1012e0f
Use typename for dependent type declarations
alexandrehoffmann Jul 24, 2026
25ba669
Fix type aliasing in GaussLegendreAdaptiveQuadrature
alexandrehoffmann Jul 24, 2026
ce6dc76
Update compiler versions in CI workflow
alexandrehoffmann Jul 24, 2026
2289ee4
Modify CI workflow for compiler updates and benchmarks
alexandrehoffmann Jul 24, 2026
b5ea732
Add adaptQuadrature function template declaration
alexandrehoffmann Jul 24, 2026
ecbf6fd
Refactor integrate method to use addaptQuadrature
alexandrehoffmann Jul 24, 2026
830df5b
Refactor adaptive quadrature implementation
alexandrehoffmann Jul 24, 2026
ea5bfad
Remove duplicate output message for quadrature
alexandrehoffmann Jul 24, 2026
12c500d
Fix parameter name in addaptQuadrature method
alexandrehoffmann Jul 24, 2026
c817cd2
Refactor variable declaration for estimated error
alexandrehoffmann Jul 24, 2026
af3fbac
Potential fix for pull request finding
alexandrehoffmann Jul 24, 2026
5d0eae0
Potential fix for pull request finding
alexandrehoffmann Jul 24, 2026
afe3eee
Potential fix for pull request finding
alexandrehoffmann Jul 24, 2026
f54b823
Implement integrateWithHints method for quadrature
alexandrehoffmann Jul 24, 2026
2165495
Add integrateWithHints method declaration
alexandrehoffmann Jul 24, 2026
dc2e603
corrected integrateWithHints template declaration
alexandrehoffmann Jul 24, 2026
d0ad859
Add assertion for sigma in AdaptiveQuadratureBase_impl
alexandrehoffmann Jul 24, 2026
133f4f0
Merge pull request #1 from alexandrehoffmann/integrate_with_hints
alexandrehoffmann Jul 24, 2026
5df074b
Refactor integral estimation and error handling
alexandrehoffmann Jul 24, 2026
e4bf178
Restore isnan guard in remapAndIntegrate to handle NaN/Inf at endpoints
Copilot Jul 24, 2026
20bbfdd
Fix integration limits in AdaptiveQuadratureBase_impl.hpp
alexandrehoffmann Jul 24, 2026
a50c81f
Merge pull request #2 from alexandrehoffmann/perfs
alexandrehoffmann Jul 24, 2026
34028cf
Change integrate function parameter to rvalue reference
alexandrehoffmann Jul 24, 2026
14f34a9
Change function parameter type to rvalue reference
alexandrehoffmann Jul 24, 2026
ac6d11c
Change function parameter from const& to &&
alexandrehoffmann Jul 24, 2026
fe08501
Change integrate function parameter to rvalue reference
alexandrehoffmann Jul 24, 2026
0a17d59
Change function parameter type from const& to &&
alexandrehoffmann Jul 24, 2026
8d3f3fd
Change Function parameter to rvalue reference
alexandrehoffmann Jul 24, 2026
b8670f9
Change function parameter types to rvalue references
alexandrehoffmann Jul 24, 2026
30a2fcf
Change function parameter from const reference to rvalue reference
alexandrehoffmann Jul 24, 2026
fac7039
Change function parameter types to rvalue references
alexandrehoffmann Jul 24, 2026
b0991c6
Change Function parameter to rvalue reference in methods
alexandrehoffmann Jul 24, 2026
d2d4f51
Change function parameter from const& to &&
alexandrehoffmann Jul 24, 2026
256d392
Change function parameter from const& to &&
alexandrehoffmann Jul 24, 2026
6b193a4
Change function parameter types to rvalue references
alexandrehoffmann Jul 24, 2026
5054a53
Change function parameter from const& to &&
alexandrehoffmann Jul 24, 2026
e45d8b5
Fix inner_product range in GaussLaguerreQuadrature
alexandrehoffmann Jul 24, 2026
7cfb75e
Fix lambda capture in GaussLaguerreQuadrature methods
alexandrehoffmann Jul 24, 2026
e86d628
Fix inner_product call to use fx.begin()
alexandrehoffmann Jul 24, 2026
740eb24
Refactor integration logic for clarity and safety
alexandrehoffmann Jul 24, 2026
94f9aab
Use std::forward in estimateIntegral function
alexandrehoffmann Jul 24, 2026
c86ba24
Merge pull request #3 from alexandrehoffmann/rvalue_ref
alexandrehoffmann Jul 24, 2026
bdf8d2b
Refactor adaptive quadrature interval handling
alexandrehoffmann Jul 24, 2026
691c650
Fix interval handling in AdaptiveQuadratureBase_impl
alexandrehoffmann Jul 24, 2026
158a069
Potential fix for pull request finding
alexandrehoffmann Jul 24, 2026
e4c634b
Fix loop condition in interval insertion logic
alexandrehoffmann Jul 24, 2026
b6fb906
Fix loop condition to use m_intervals size
alexandrehoffmann Jul 24, 2026
5211b3b
Change scal to constexpr for better optimization
alexandrehoffmann Jul 24, 2026
d0bc7c6
Add early guard in integrateWithHints for empty mu
Copilot Jul 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: C/C++ CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
strategy:
matrix:
os: [ubuntu-latest]
compiler: [g++-14, clang++-18]
build_type: [Debug, Release]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- name: Install toolchain and dependencies
run: |
sudo apt-get update
sudo apt-get install -y g++-14 clang-18 libfmt-dev

- name: Configure & build
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_COMPILER=${{ matrix.compiler }} \
-DLNIT_BUILD_DEMO=ON \
-DLNIT_BUILD_BENCHMARK=ON
cmake --build build --parallel

benchmark:
# only track regressions from main; PRs/forks shouldn't push to gh-pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Install toolchain and dependencies
run: |
sudo apt-get update
sudo apt-get install -y g++-14 libfmt-dev

- name: Configure & build benchmarks
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_COMPILER=g++-14 \
-DLNIT_BUILD_BENCHMARK=ON
cmake --build build --parallel

- name: Run benchmarks
run: |
./build/benchmark/benchmark_addaptiveQuadratures --benchmark_format=json --benchmark_out=bench_addaptiveQuadratures_result.json
./build/benchmark/benchmark_LevermoreLikePDF --benchmark_format=json --benchmark_out=bench_LevermoreLikePDF_result.json

- name: Store adaptive quadratures benchmark & detect regressions
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'googlecpp'
name: 'Adaptive Quadratures'
output-file-path: bench_addaptiveQuadratures_result.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
alert-threshold: '150%'
comment-on-alert: true
fail-on-alert: true

- name: Store Levermore-like PDF benchmark & detect regressions
uses: benchmark-action/github-action-benchmark@v1
with:
tool: 'googlecpp'
name: 'Levermore-like PDF'
output-file-path: bench_LevermoreLikePDF_result.json
github-token: ${{ secrets.GITHUB_TOKEN }}
auto-push: true
alert-threshold: '150%'
comment-on-alert: true
fail-on-alert: true
20 changes: 12 additions & 8 deletions include/LNIT/AdaptiveQuadratures/AdaptiveQuadratureBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class AdaptiveQuadratureBase
*
* @return Pair (integral, estimated error).
*/
template<class Function> constexpr std::pair<LongScalar, LongScalar> estimateIntegral(const Function& f, const Scalar& xmin, const Scalar& xmax) { return derived().estimateIntegralImpl(f, xmin, xmax); }
template<class Function> constexpr std::pair<LongScalar, LongScalar> estimateIntegral(Function&& f, const Scalar& xmin, const Scalar& xmax) { return derived().estimateIntegralImpl(std::forward<Function>(f), xmin, xmax); }

/**
* @brief Perform adaptive quadrature on [xmin, xmax].
Expand All @@ -75,8 +75,10 @@ class AdaptiveQuadratureBase
* @param xmax Upper bound of interval.
* @return Approximation of the integral.
*/
template<class Function> LongScalar integrate(const Function& f, const Scalar& xmin, const Scalar& xmax);

template<class Function> LongScalar integrate(Function&& f, const Scalar& xmin, const Scalar& xmax);

template<class Function> LongScalar integrateWithHints(Function&& f, const std::span<const Scalar> mu, const Scalar& sigma);

/**
* @brief Perform adaptive quadrature on (-inf, xmax].
*
Expand All @@ -92,7 +94,7 @@ class AdaptiveQuadratureBase
* @param xmax Upper bound of interval.
* @return Approximation of the integral.
*/
template<class Function> LongScalar integrateLeftInfinite(const Function& f, const Scalar& xmax);
template<class Function> LongScalar integrateLeftInfinite(Function&& f, const Scalar& xmax);

/**
* @brief Perform adaptive quadrature on [xmin, inf).
Expand All @@ -109,7 +111,7 @@ class AdaptiveQuadratureBase
* @param xmax Upper bound of interval.
* @return Approximation of the integral.
*/
template<class Function> LongScalar integrateRightInfinite(const Function& f, const Scalar& xmin);
template<class Function> LongScalar integrateRightInfinite(Function&& f, const Scalar& xmin);

/**
* @brief Perform adaptive quadrature on (-inf, inf).
Expand All @@ -124,7 +126,7 @@ class AdaptiveQuadratureBase
* \f]
* Finally addapt the quadrature over [xmin, xmax].
*/
template<class Function> LongScalar integrate(const Function& f);
template<class Function> LongScalar integrate(Function&& f);

/**
* @brief Perform adaptive quadrature on (-inf, inf) using a coordinate-remapping technique.
Expand All @@ -139,9 +141,9 @@ class AdaptiveQuadratureBase
* \int_{-1}^{1} f(x(t))\frac{1 + t^2}{(1 - t^2)^2} dt.
* \f]
*/
template<class Function> LongScalar remapAndIntegrate(const Function& f);
template<class Function> LongScalar remapAndIntegrate(Function&& f);

template<class Function> std::invoke_result_t<Function, Scalar> integrateWithoutAdaptation(const Function& f) const;
template<class Function> std::invoke_result_t<Function, Scalar> integrateWithoutAdaptation(Function&& f) const;

constexpr Size getMaxIt() const { return m_maxIt; } ///< @brief Maximum iterations allowed.
constexpr Size getNits() const { return m_it; } ///< @brief Number of iterations performed.
Expand All @@ -168,6 +170,8 @@ class AdaptiveQuadratureBase

constexpr std::span<const Interval> getSubIntervals() const { return m_intervals; }
private:
template<class Function> LongScalar adaptQuadrature(Function&& func);

std::vector<Interval> m_intervals;
std::vector<LongScalar> m_subIntergrals;
std::vector<LongScalar> m_subIntergralsErr;
Expand Down
Loading