Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use SizedArray for non-isbits types #61

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.0'
- '1.6'
- '1'
# - 'nightly'
os:
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ QuadGK = "1fd47b50-473d-5c70-9696-f719f8f3bcdc"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"

[compat]
julia = "1"
julia = "1.6"
araujoms marked this conversation as resolved.
Show resolved Hide resolved
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"

Expand Down
4 changes: 2 additions & 2 deletions src/HCubature.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/genz-malik.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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] .= λ
Expand All @@ -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
Expand Down Expand Up @@ -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₂)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading