Skip to content

Commit

Permalink
use SizedArray for non-isbits types (#61)
Browse files Browse the repository at this point in the history
* use SizedArray for non-isbits types

* change minimum julia version from 1.0 to 1.6

* bump version to 1.6.0
  • Loading branch information
araujoms authored Feb 25, 2024
1 parent e3f1db4 commit 0e8470d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
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
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -10,11 +10,11 @@ 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"
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

2 comments on commit 0e8470d

@stevengj
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/101643

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.6.0 -m "<description of version>" 0e8470d64aa00b1a015228f08449f7124f1d6b07
git push origin v1.6.0

Please sign in to comment.