JuliaMath / HCubature.jl

pure-Julia multidimensional h-adaptive integration
Other
148 stars 23 forks source link

Integrand needs zero defined #66

Open 3f6a opened 2 months ago

3f6a commented 2 months ago

From the readme:

the integrand f(x) can return any vector-like object (technically, any type supporting +, -, * real, and norm: a Banach space)

However it seems we also need to have zero(f(x)) defined. This should be mentioned in the readme.

3f6a commented 2 months ago

For example, this means currently we cannot have vector of vectors integrand (which define a valid Banach space):

f(x) = [[1,2], [3,4,5]]

for which norm, +, -, and *real are all defined:

julia> 2 * [[1,2], [3,4,5]]
2-element Vector{Vector{Int64}}:
 [2, 4]
 [6, 8, 10]

julia> norm([[1,2], [3,4,5]])
7.416198487095664

...

However, zero([[1,2], [3,4,5]]) is not defined (there was an issue about this but I can't find it now), and this implies that integrating this function fails.

This particular issue should be fixed in Julia 1.11, https://github.com/JuliaLang/julia/issues/38064.

But for more other spaces, the fact that zero is needed should be mentioned IMO.

stevengj commented 2 months ago

Yes, please feel free to submit a PR to clarify this.