Skip to content

Commit

Permalink
Change to using extension packages
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRackauckas committed Nov 2, 2023
1 parent 77f0e83 commit 24fce57
Show file tree
Hide file tree
Showing 12 changed files with 187 additions and 431 deletions.
10 changes: 9 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,24 @@ SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"

[weakdeps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Cuba = "8a292aeb-7a57-582c-b821-06e4c11590b1"
Cubature = "667455a9-e2ce-5579-9412-b964f529a492"
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[extensions]
IntegralsCubaExt = "Cuba"
IntegralsCubatureExt = "Cubature"
IntegralsFastGaussQuadratureExt = "FastGaussQuadrature"
IntegralsForwardDiffExt = "ForwardDiff"
IntegralsZygoteExt = ["Zygote", "ChainRulesCore"]

[compat]
ChainRulesCore = "0.10.7, 1"
CommonSolve = "0.2"
Cuba = "2"
Cubature = "1"
Distributions = "0.23, 0.24, 0.25"
FastGaussQuadrature = "0.5"
ForwardDiff = "0.10"
Expand All @@ -41,6 +47,8 @@ julia = "1.6"

[extras]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Cuba = "8a292aeb-7a57-582c-b821-06e4c11590b1"
Cubature = "667455a9-e2ce-5579-9412-b964f529a492"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
FiniteDiff = "6a86dc24-6348-571c-b903-95158fe2bd41"
Expand All @@ -53,4 +61,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["SciMLSensitivity", "StaticArrays", "FiniteDiff", "Pkg", "SafeTestsets", "Test", "Distributions", "ForwardDiff", "Zygote", "ChainRulesCore", "FastGaussQuadrature"]
test = ["SciMLSensitivity", "StaticArrays", "FiniteDiff", "Pkg", "SafeTestsets", "Test", "Distributions", "ForwardDiff", "Zygote", "ChainRulesCore", "FastGaussQuadrature", "Cuba", "Cubature"]
134 changes: 2 additions & 132 deletions lib/IntegralsCuba/src/IntegralsCuba.jl → ext/IntegralsCubaExt.jl
Original file line number Diff line number Diff line change
@@ -1,136 +1,8 @@
module IntegralsCuba
module IntegralsCubaExt

using Integrals, Cuba
import Integrals: transformation_if_inf, scale_x, scale_x!

abstract type AbstractCubaAlgorithm <: SciMLBase.AbstractIntegralAlgorithm end
"""
CubaVegas()
Multidimensional adaptive Monte Carlo integration from Cuba.jl.
Importance sampling is used to reduce variance.
## References
@article{lepage1978new,
title={A new algorithm for adaptive multidimensional integration},
author={Lepage, G Peter},
journal={Journal of Computational Physics},
volume={27},
number={2},
pages={192--203},
year={1978},
publisher={Elsevier}
}
"""
struct CubaVegas <: AbstractCubaAlgorithm
flags::Int
seed::Int
minevals::Int
nstart::Int
nincrease::Int
gridno::Int
end
"""
CubaSUAVE()
Multidimensional adaptive Monte Carlo integration from Cuba.jl.
Suave stands for subregion-adaptive VEGAS.
Importance sampling and subdivision are thus used to reduce variance.
## References
@article{hahn2005cuba,
title={Cuba—a library for multidimensional numerical integration},
author={Hahn, Thomas},
journal={Computer Physics Communications},
volume={168},
number={2},
pages={78--95},
year={2005},
publisher={Elsevier}
}
"""
struct CubaSUAVE{R} <: AbstractCubaAlgorithm where {R <: Real}
flags::Int
seed::Int
minevals::Int
nnew::Int
nmin::Int
flatness::R
end
"""
CubaDivonne()
Multidimensional adaptive Monte Carlo integration from Cuba.jl.
Stratified sampling is used to reduce variance.
## References
@article{friedman1981nested,
title={A nested partitioning procedure for numerical multiple integration},
author={Friedman, Jerome H and Wright, Margaret H},
journal={ACM Transactions on Mathematical Software (TOMS)},
volume={7},
number={1},
pages={76--92},
year={1981},
publisher={ACM New York, NY, USA}
}
"""
struct CubaDivonne{R1, R2, R3} <:
AbstractCubaAlgorithm where {R1 <: Real, R2 <: Real, R3 <: Real}
flags::Int
seed::Int
minevals::Int
key1::Int
key2::Int
key3::Int
maxpass::Int
border::R1
maxchisq::R2
mindeviation::R3
end
"""
CubaCuhre()
Multidimensional h-adaptive integration from Cuba.jl.
## References
@article{berntsen1991adaptive,
title={An adaptive algorithm for the approximate calculation of multiple integrals},
author={Berntsen, Jarle and Espelid, Terje O and Genz, Alan},
journal={ACM Transactions on Mathematical Software (TOMS)},
volume={17},
number={4},
pages={437--451},
year={1991},
publisher={ACM New York, NY, USA}
}
"""
struct CubaCuhre <: AbstractCubaAlgorithm
flags::Int
minevals::Int
key::Int
end

function CubaVegas(; flags = 0, seed = 0, minevals = 0, nstart = 1000, nincrease = 500,
gridno = 0)
CubaVegas(flags, seed, minevals, nstart, nincrease, gridno)
end
function CubaSUAVE(; flags = 0, seed = 0, minevals = 0, nnew = 1000, nmin = 2,
flatness = 25.0)
CubaSUAVE(flags, seed, minevals, nnew, nmin, flatness)
end
function CubaDivonne(; flags = 0, seed = 0, minevals = 0,
key1 = 47, key2 = 1, key3 = 1, maxpass = 5, border = 0.0,
maxchisq = 10.0, mindeviation = 0.25)
CubaDivonne(flags, seed, minevals, key1, key2, key3, maxpass, border, maxchisq,
mindeviation)
end
CubaCuhre(; flags = 0, minevals = 0, key = 0) = CubaCuhre(flags, minevals, key)

function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgorithm,
sensealg,
domain, p;
Expand Down Expand Up @@ -243,6 +115,4 @@ function Integrals.__solvebp_call(prob::IntegralProblem, alg::AbstractCubaAlgori
chi = out.probability, retcode = ReturnCode.Success)
end

export CubaVegas, CubaSUAVE, CubaDivonne, CubaCuhre

end
end
19 changes: 0 additions & 19 deletions lib/IntegralsCuba/LICENSE

This file was deleted.

19 changes: 0 additions & 19 deletions lib/IntegralsCuba/Project.toml

This file was deleted.

1 change: 0 additions & 1 deletion lib/IntegralsCuba/test/runtests.jl

This file was deleted.

19 changes: 0 additions & 19 deletions lib/IntegralsCubature/LICENSE

This file was deleted.

19 changes: 0 additions & 19 deletions lib/IntegralsCubature/Project.toml

This file was deleted.

Loading

0 comments on commit 24fce57

Please sign in to comment.