From b68679d4d2416b99ec3291b53b2ef3735a387f58 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Thu, 9 Apr 2026 07:55:32 -0400 Subject: [PATCH] Update FastTanhSinhQuadratureExt for v2.1 API: tol -> rtol/atol FastTanhSinhQuadrature v2.1 renamed the `tol` keyword to `rtol`/`atol` in `quad()`. Update the extension and algorithm struct accordingly, and drop v1 compat. Co-Authored-By: Chris Rackauckas Co-Authored-By: Claude Opus 4.6 (1M context) --- Project.toml | 2 +- ext/IntegralsFastTanhSinhQuadratureExt.jl | 14 ++++++-------- src/algorithms_extension.jl | 14 ++++++++------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Project.toml b/Project.toml index cc0abf03..46b71c33 100644 --- a/Project.toml +++ b/Project.toml @@ -56,7 +56,7 @@ DifferentiationInterface = "0.7" Distributions = "0.25.87" ExplicitImports = "1.14.0" FastGaussQuadrature = "0.5,1" -FastTanhSinhQuadrature = "1, 2.1" +FastTanhSinhQuadrature = "2.1" FiniteDiff = "2.12" ForwardDiff = "0.10.36, 1" HAdaptiveIntegration = "0.2, 1.0" diff --git a/ext/IntegralsFastTanhSinhQuadratureExt.jl b/ext/IntegralsFastTanhSinhQuadratureExt.jl index e717d2ec..6ff19e86 100644 --- a/ext/IntegralsFastTanhSinhQuadratureExt.jl +++ b/ext/IntegralsFastTanhSinhQuadratureExt.jl @@ -17,11 +17,9 @@ function Integrals.__solvebp_call( @assert f isa IntegralFunction "FastTanhSinhQuadratureJL does not support BatchIntegralFunction" @assert !isinplace(prob) "FastTanhSinhQuadratureJL does not support in-place integrands" - # Determine the effective tolerance - tol = alg.tol - if reltol !== nothing - tol = reltol - end + # Determine the effective tolerances + _rtol = reltol !== nothing ? reltol : alg.rtol + _atol = abstol !== nothing ? abstol : alg.atol max_levels = alg.max_levels # Determine dimensionality @@ -32,19 +30,19 @@ function Integrals.__solvebp_call( _lb = lb isa Number ? lb : only(lb) _ub = ub isa Number ? ub : only(ub) _f = x -> f.f(x, p) - val = quad(_f, _lb, _ub; tol = tol, max_levels = max_levels) + val = quad(_f, _lb, _ub; rtol = _rtol, atol = _atol, max_levels = max_levels) elseif dim == 2 # 2D integration - use Vectors which quad() converts to SVector internally _lb = collect(lb) _ub = collect(ub) _f = (x, y) -> f.f([x, y], p) - val = quad(_f, _lb, _ub; tol = tol, max_levels = max_levels) + val = quad(_f, _lb, _ub; rtol = _rtol, atol = _atol, max_levels = max_levels) elseif dim == 3 # 3D integration - use Vectors which quad() converts to SVector internally _lb = collect(lb) _ub = collect(ub) _f = (x, y, z) -> f.f([x, y, z], p) - val = quad(_f, _lb, _ub; tol = tol, max_levels = max_levels) + val = quad(_f, _lb, _ub; rtol = _rtol, atol = _atol, max_levels = max_levels) else error("FastTanhSinhQuadratureJL only supports 1D, 2D, and 3D integration. Got dimension = $dim") end diff --git a/src/algorithms_extension.jl b/src/algorithms_extension.jl index 81d5dbcf..5231e479 100644 --- a/src/algorithms_extension.jl +++ b/src/algorithms_extension.jl @@ -328,7 +328,7 @@ function HAdaptiveIntegrationJL(; kws...) end """ - FastTanhSinhQuadratureJL(; tol = 1e-12, max_levels = 10) + FastTanhSinhQuadratureJL(; rtol = 1e-12, atol = 0.0, max_levels = 10) One-dimensional adaptive Tanh-Sinh (double exponential) quadrature from FastTanhSinhQuadrature.jl. This method uses a double exponential transformation that provides excellent convergence properties, @@ -336,7 +336,8 @@ especially for integrands with endpoint singularities or infinite derivatives at ## Keyword Arguments - - `tol`: Relative tolerance for convergence (default: `1e-12`) + - `rtol`: Relative tolerance for convergence (default: `1e-12`) + - `atol`: Absolute tolerance for convergence (default: `0.0`) - `max_levels`: Maximum number of refinement levels in adaptive integration (default: `10`) ## Limitations @@ -360,12 +361,13 @@ publisher={Research Institute for Mathematical Sciences} } ``` """ -struct FastTanhSinhQuadratureJL{T} <: AbstractIntegralExtensionAlgorithm - tol::T +struct FastTanhSinhQuadratureJL{T, S} <: AbstractIntegralExtensionAlgorithm + rtol::T + atol::S max_levels::Int end -function FastTanhSinhQuadratureJL(; tol = 1.0e-12, max_levels = 10) +function FastTanhSinhQuadratureJL(; rtol = 1.0e-12, atol = 0.0, max_levels = 10) isnothing(Base.get_extension(@__MODULE__, :IntegralsFastTanhSinhQuadratureExt)) && error("FastTanhSinhQuadratureJL requires `using FastTanhSinhQuadrature`") - return FastTanhSinhQuadratureJL(tol, max_levels) + return FastTanhSinhQuadratureJL(rtol, atol, max_levels) end