From 5531f32614d5dac37f78451f9d4f288a602636c9 Mon Sep 17 00:00:00 2001 From: lxvm Date: Mon, 12 Feb 2024 10:54:42 -0500 Subject: [PATCH 1/3] add test --- test/runtests.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 05908a6..02b7510 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -99,3 +99,8 @@ end buffer = hcubature_buffer(f,a,b) @test @inferred(hcubature(f,a,b;buffer=buffer))[1] ≈ (1+im)*sin(1)^2 end + +@testset "issue 23" begin + @test hquadrature(x -> 1.0, 1, -1)[1] ≈ -2 + @test hcubature(x -> 1.0, [-1,1], [1,-1])[1] ≈ -4 +end From 9a3d4dc759ac8d276f3d91108456e93454cf3f1c Mon Sep 17 00:00:00 2001 From: lxvm Date: Mon, 12 Feb 2024 10:54:55 -0500 Subject: [PATCH 2/3] allow sign in gauss-kronrod --- src/gauss-kronrod.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gauss-kronrod.jl b/src/gauss-kronrod.jl index 1651b55..6db1b37 100644 --- a/src/gauss-kronrod.jl +++ b/src/gauss-kronrod.jl @@ -40,8 +40,7 @@ function (g::GaussKronrod{T})(f::F, a_::SVector{1}, b_::SVector{1}, norm=norm) w I′ += fx * g.wg[i>>1] end end - V = abs(Δ) - I *= V - I′ *= V + I *= Δ + I′ *= Δ return I, norm(I - I′), 1 end From 5e260f0360e2c942edbc93365dfd34bc8558c3ab Mon Sep 17 00:00:00 2001 From: lxvm Date: Mon, 12 Feb 2024 10:55:10 -0500 Subject: [PATCH 3/3] allow sign in genz-malik --- src/genz-malik.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/genz-malik.jl b/src/genz-malik.jl index c4881f0..3c0af85 100644 --- a/src/genz-malik.jl +++ b/src/genz-malik.jl @@ -115,7 +115,7 @@ to subdivide next. """ function (g::GenzMalik{n,T})(f::F, a::SVector{n}, b::SVector{n}, norm=norm) where {F, n,T} c = T(0.5).*(a.+b) - Δ = T(0.5).*abs.(b.-a) + Δ = T(0.5).*(b.-a) V = prod(Δ) f₁ = f(c) @@ -158,7 +158,7 @@ function (g::GenzMalik{n,T})(f::F, a::SVector{n}, b::SVector{n}, norm=norm) wher if (δ = divdiff[i] - maxdivdiff) > δf kdivide = i maxdivdiff = divdiff[i] - elseif abs(δ) <= δf && Δ[i] > Δ[kdivide] + elseif abs(δ) <= δf && abs(Δ[i]) > abs(Δ[kdivide]) kdivide = i end end