Skip to content

Commit

Permalink
Test divonne with xgiven
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Jun 24, 2024
1 parent 299fac7 commit c415f46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ task:
matrix:
- name: FreeBSD
freebsd_instance:
image_family: freebsd-13-1
image_family: freebsd-13-3
env:
matrix:
- JULIA_VERSION: 1
Expand Down Expand Up @@ -41,5 +41,5 @@ task:
- cirrusjl build
test_script:
- cirrusjl test
coverage_script:
- cirrusjl coverage codecov
# coverage_script:
# - cirrusjl coverage codecov
4 changes: 2 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,9 @@ These optional keywords can be passed only to [`divonne`](@ref):
treated.
- `ngiven` (type: `Integer`, default: `0`): the number of points in
the `xgiven` array
- `ldxgiven` (type: `Integer`, default: `0`): the leading dimension of
- `ldxgiven` (type: `Integer`, default: `ndim`): the leading dimension of
`xgiven`, i.e. the offset between one point and the next in memory
- `xgiven` (type: `AbstractArray{Real}`, default:
- `xgiven` (type: `AbstractMatrix{Real}`, default:
`zeros(Cdouble, ldxgiven, ngiven)`): a list of points where the
integrand might have peaks. Divonne will consider these points when
partitioning the integration region. The idea here is to help the
Expand Down
2 changes: 1 addition & 1 deletion src/divonne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function divonne(integrand::T, ndim::Integer=2, ncomp::Integer=1;
maxpass::Integer=MAXPASS, border::Real=BORDER,
maxchisq::Real=MAXCHISQ,
mindeviation::Real=MINDEVIATION,
ngiven::Integer=NGIVEN, ldxgiven::Integer=LDXGIVEN,
ngiven::Integer=NGIVEN, ldxgiven::Integer=ndim,
xgiven::Array{Cdouble,2}=zeros(Cdouble, ldxgiven,
ngiven),
nextra::Integer=NEXTRA,
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ end
@test_throws ArgumentError suave((x,f) -> f[1] = 1; maxevals=typemax(Int64)÷2 + 1)
end

@testset "divonne with xgiven" begin
# Inspired by https://discourse.julialang.org/t/slow-cubature/116120/20
gauss(x, x₀=0.5, μ=0.0001) = exp(-((x - x₀) / μ) ^ 2)
# Note: the syntax [0.5;;] to define a 1x1 matrix was introduced only in
# Julia v1.7, so we can't use it here.
@test divonne((x, y) -> y[1] = gauss(x[1]); ngiven=1, xgiven=reshape([0.5], 1, 1)).integral[1] 0.0001772453850905516 rtol=6e-6
end

# Make sure these functions don't crash.
Cuba.init(C_NULL, C_NULL)
Cuba.exit(C_NULL, C_NULL)
Expand Down

0 comments on commit c415f46

Please sign in to comment.