From 80e202d0bfd76e718390186dce38558a3ad723a1 Mon Sep 17 00:00:00 2001 From: araujoms Date: Sat, 24 Feb 2024 11:49:41 +0100 Subject: [PATCH 1/3] use SizedArray for non-isbits types --- Project.toml | 2 +- src/HCubature.jl | 4 ++-- src/genz-malik.jl | 6 +++--- test/runtests.jl | 6 ++++++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Project.toml b/Project.toml index e83e460..15f9876 100644 --- a/Project.toml +++ b/Project.toml @@ -14,7 +14,7 @@ julia = "1" Combinatorics = "1.0" DataStructures = "0.15, 0.16, 0.17, 0.18" QuadGK = "2" -StaticArrays = "0.8, 0.9, 0.10, 0.11, 0.12, 1" +StaticArrays = "1.6.4" LinearAlgebra = "<0.0.1, 1" Test = "<0.0.1, 1" diff --git a/src/HCubature.jl b/src/HCubature.jl index ea77d85..74c5465 100644 --- a/src/HCubature.jl +++ b/src/HCubature.jl @@ -114,8 +114,8 @@ function hcubature_(f::F, a::SVector{n,T}, b::SVector{n,T}, norm, rtol_, atol, m push!(boxes, firstbox) - ma = MVector(a) - mb = MVector(b) + ma = Base.copymutable(a) + mb = Base.copymutable(b) if initdiv > 1 # initial box divided by initdiv along each dimension skip = true # skip the first box, which we already added diff --git a/src/genz-malik.jl b/src/genz-malik.jl index 3c0af85..a4e55d3 100644 --- a/src/genz-malik.jl +++ b/src/genz-malik.jl @@ -12,7 +12,7 @@ with k components equal to λ and other components equal to zero. function combos(k::Integer, λ::T, ::Val{n}) where {n, T<:Number} combos = Combinatorics.combinations(1:n, k) p = Vector{SVector{n,T}}(undef, length(combos)) - v = MVector{n,T}(undef) + v = similar(SVector{n,T}) for (i,c) in enumerate(combos) v .= 0 v[c] .= λ @@ -32,7 +32,7 @@ function signcombos(k::Integer, λ::T, ::Val{n}) where {n, T<:Number} combos = Combinatorics.combinations(1:n, k) twoᵏ = 1 << k p = Vector{SVector{n,T}}(undef, length(combos) * twoᵏ) - v = MVector{n,T}(undef) + v = similar(SVector{n,T}) for (i,c) in enumerate(combos) j = (i-1)*twoᵏ + 1 v .= 0 @@ -124,7 +124,7 @@ function (g::GenzMalik{n,T})(f::F, a::SVector{n}, b::SVector{n}, norm=norm) wher f₃ = zero(f₁) twelvef₁ = 12f₁ maxdivdiff = zero(norm(f₁)) - divdiff = MVector{n,typeof(maxdivdiff)}(undef) + divdiff = similar(SVector{n,typeof(maxdivdiff)}) for i = 1:n p₂ = Δ .* g.p[1][i] f₂ᵢ = f(c + p₂) + f(c - p₂) diff --git a/test/runtests.jl b/test/runtests.jl index 02b7510..fe0e03e 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -104,3 +104,9 @@ end @test hquadrature(x -> 1.0, 1, -1)[1] ≈ -2 @test hcubature(x -> 1.0, [-1,1], [1,-1])[1] ≈ -4 end + +@testset "issue 60" begin + T = BigFloat + @test hquadrature(x -> exp(-x^2), T(0), T(1); rtol = 1e-20)[1] ≈ 0.7468241328124270254 + @test hcubature(x -> exp(-x[1]^2), T.((0,0)), T.((1,1)); rtol = 1e-20)[1] ≈ 0.7468241328124270254 +end From 14e11c4ce195fc914c64a23a5104a2ad77a44bbe Mon Sep 17 00:00:00 2001 From: araujoms Date: Sun, 25 Feb 2024 21:47:47 +0100 Subject: [PATCH 2/3] change minimum julia version from 1.0 to 1.6 --- .github/workflows/CI.yml | 2 +- Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 03d9778..6bd3f05 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: version: - - '1.0' + - '1.6' - '1' # - 'nightly' os: diff --git a/Project.toml b/Project.toml index 15f9876..75c5e1e 100644 --- a/Project.toml +++ b/Project.toml @@ -10,7 +10,7 @@ QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc" StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" [compat] -julia = "1" +julia = "1.6" Combinatorics = "1.0" DataStructures = "0.15, 0.16, 0.17, 0.18" QuadGK = "2" From f158c02bd46b8988ce1a0e7ed65783f16433b1aa Mon Sep 17 00:00:00 2001 From: araujoms Date: Sun, 25 Feb 2024 22:17:44 +0100 Subject: [PATCH 3/3] bump version to 1.6.0 --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 75c5e1e..7bab427 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "HCubature" uuid = "19dc6840-f33b-545b-b366-655c7e3ffd49" -version = "1.5.2" +version = "1.6.0" [deps] Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"