No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
607ecdd
... +2 ...
53a46aa
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
1 | 1 | module MultiQuad |
|
2 | 2 | ||
3 | - | using QuadGK, Cuba, Unitful |
|
3 | + | using QuadGK, Cuba, HCubature, Unitful |
|
4 | 4 | ||
5 | 5 | export quad, dblquad, tplquad |
|
6 | 6 | ||
7 | 7 | @doc raw""" |
|
8 | 8 | quad(arg::Function, x1, x2; method = :quadgk, kwargs...) |
|
9 | 9 | ||
10 | 10 | Performs the integral ``\int_{x1}^{x2}f(x)dx`` |
|
11 | + | ||
12 | + | Available integration methods: |
|
13 | + | - `:suave` |
|
14 | + | - `:vegas` |
|
15 | + | - `:quadgk` |
|
16 | + | ||
11 | 17 | See [QuadGK](https://github.com/JuliaMath/QuadGK.jl) and [Cuba.jl](https://giordano.github.io/Cuba.jl/stable/) for all the available keyword arguments. |
|
12 | 18 | ||
13 | 19 | # Examples |
63 | 69 | dblquad(arg::Function, x1, x2, y1::Function, y2::Function; method = :cuhre, kwargs...) |
|
64 | 70 | ||
65 | 71 | Performs the integral ``\int_{x1}^{x2}\int_{y1(x)}^{y2(x)}f(y,x)dydx`` |
|
66 | - | See [Cuba.jl](https://giordano.github.io/Cuba.jl/stable/) for all the available keyword arguments. |
|
72 | + | ||
73 | + | Available integration methods: |
|
74 | + | - `:cuhre` |
|
75 | + | - `:divonne` |
|
76 | + | - `:suave` |
|
77 | + | - `:vegas` |
|
78 | + | - `:hcubature` |
|
79 | + | ||
80 | + | See [Cuba.jl](https://giordano.github.io/Cuba.jl/stable/) for all the available keyword arguments fro the `:cuhre`, `:divonne`, `:suave` and `:vegas` methods. |
|
81 | + | See [HCubature](https://github.com/stevengj/HCubature.jl) for all the available keywords for the `:hcubature` method. |
|
67 | 82 | ||
68 | 83 | # Examples |
|
69 | 84 | ```jldoctest |
98 | 113 | integrate = suave |
|
99 | 114 | elseif method == :vegas |
|
100 | 115 | integrate = vegas |
|
116 | + | elseif method == :hcubature |
|
117 | + | integrate = hcubature |
|
101 | 118 | else |
|
102 | 119 | ex = ErrorException("Integration method $method is not supported!") |
|
103 | 120 | throw(ex) |
110 | 127 | ||
111 | 128 | arg2(a, b) = ustrip(units, (x2 - x1) * arg1(a, (x2 - x1) * b + x1))::Float64 |
|
112 | 129 | ||
113 | - | function integrand(x, f) |
|
114 | - | f[1] = arg2(x[1], x[2]) |
|
115 | - | end |
|
130 | + | if method == :hcubature |
|
131 | + | function integrand(arr) |
|
132 | + | return arg2(arr[1], arr[2]) |
|
133 | + | end |
|
134 | + | ||
135 | + | min_arr = [0, 0] |
|
136 | + | max_arr = [1, 1] |
|
137 | + | result, err = integrate(integrand, min_arr, max_arr; kwargs...) |
|
138 | + | else |
|
139 | + | function integrand2(x, f) |
|
140 | + | f[1] = arg2(x[1], x[2]) |
|
141 | + | end |
|
116 | 142 | ||
117 | - | result, err = integrate(integrand, 2, 1; kwargs...) |
|
143 | + | result, err = integrate(integrand2, 2, 1; kwargs...) |
|
144 | + | end |
|
118 | 145 | ||
119 | 146 | if units == Unitful.NoUnits |
|
120 | 147 | return result[1], err[1] |
127 | 154 | tplquad(arg::Function, x1, x2, y1::Function, y2::Function, z1::Function, z2::Function; method = :cuhre, kwargs...) |
|
128 | 155 | ||
129 | 156 | Performs the integral ``\int_{x1}^{x2}\int_{y1(x)}^{y2(x)}\int_{z1(x,y)}^{z2(x,y)}f(z,y,x)dzdydx`` |
|
130 | - | See [Cuba.jl](https://giordano.github.io/Cuba.jl/stable/) for all the available keyword arguments. |
|
157 | + | ||
158 | + | Available integration methods: |
|
159 | + | - `:cuhre` |
|
160 | + | - `:divonne` |
|
161 | + | - `:suave` |
|
162 | + | - `:vegas` |
|
163 | + | - `:hcubature` |
|
164 | + | ||
165 | + | See [Cuba.jl](https://giordano.github.io/Cuba.jl/stable/) for all the available keyword arguments fro the `:cuhre`, `:divonne`, `:suave` and `:vegas` methods. |
|
166 | + | See [HCubature](https://github.com/stevengj/HCubature.jl) for all the available keywords for the `:hcubature` method. |
|
131 | 167 | ||
132 | 168 | # Examples |
|
133 | 169 | ```jldoctest |
164 | 200 | integrate = suave |
|
165 | 201 | elseif method == :vegas |
|
166 | 202 | integrate = vegas |
|
203 | + | elseif method == :hcubature |
|
204 | + | integrate = hcubature |
|
167 | 205 | else |
|
168 | 206 | ex = ErrorException("Integration method $method is not supported!") |
|
169 | 207 | throw(ex) |
181 | 219 | arg2(a, b, c) = |
|
182 | 220 | ustrip(units, (x2 - x1) * arg1(a, b, (x2 - x1) * c + x1))::Float64 |
|
183 | 221 | ||
184 | - | function integrand(x, f) |
|
185 | - | f[1] = arg2(x[1], x[2], x[3]) |
|
186 | - | end |
|
222 | + | if method == :hcubature |
|
223 | + | function integrand(arr) |
|
224 | + | return arg2(arr[1], arr[2], arr[3]) |
|
225 | + | end |
|
226 | + | ||
227 | + | min_arr = [0, 0, 0] |
|
228 | + | max_arr = [1, 1, 1] |
|
229 | + | result, err = integrate(integrand, min_arr, max_arr; kwargs...) |
|
230 | + | else |
|
231 | + | function integrand2(x, f) |
|
232 | + | f[1] = arg2(x[1], x[2], x[3]) |
|
233 | + | end |
|
187 | 234 | ||
188 | - | result, err = integrate(integrand, 3, 1; kwargs...) |
|
235 | + | result, err = integrate(integrand2, 3, 1; kwargs...) |
|
236 | + | end |
|
189 | 237 | ||
190 | 238 | if units == Unitful.NoUnits |
|
191 | 239 | return result[1], err[1] |
Files | Coverage |
---|---|
src/MultiQuad.jl | 100.00% |
Project Totals (1 files) | 100.00% |
53a46aa
6445fd0
4d5f621
607ecdd