Closed msagarpatel closed 7 months ago
Sorry for the lack of documentation. The VcatDomain
will concatenate its elements into a vector, in the process promoting them as in
julia> vcat(2.3, 5)
2-element Vector{Float64}:
2.3
5.0
The set of natural numbers can not be promoted to have Float64 type, that is why you're getting an error.
The VcatDomain
is a concrete subtype of ProductDomain
. The more generic function productdomain
decides, based on the arguments, which concrete subtype of ProductDomain
is most suited to return. However, that will also fail here, because by default it chooses VcatDomain
for domains with scalar eltypes.
The type you're probably after is TupleProductDomain
, which represents its elements as a Tuple rather than a Vector and which doesn't promote them:
julia> d = TupleProductDomain(ℝ, ℕ)
RealNumbers() × NaturalNumbers()
julia> eltype(d)
Tuple{Float64, Int64}
julia> (2.3,5) ∈ d
true
Alternatively, you could type ProductDomain{Tuple{Float64,Int}}(ℝ, ℕ)
.
Thank you, @daanhb! That makes sense.
I may be misunderstanding the intended use of VcatDomain, but I assumed it represents a Cartesian Product based on this code: https://github.com/JuliaApproximation/DomainSets.jl/blob/3b914a2b81015c706e6ea7f4be1444eb58c6d49b/src/domains/numbers.jl#L64-L71
So, I tried to represent $
\mathbb{R} \times \mathbb{N}
$, but was met with an error: