-
Notifications
You must be signed in to change notification settings - Fork 12
Add support for domains with vector elements #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The errors in Julia 1.0 and 1.1 are related to mapreduce. A |
We're getting there, I'm writing some more tests. Some preliminary conclusions:
julia> p = ProductDomain(1:10, [true,false], 0..1)
DomainSets.WrappedDomain{Int64,UnitRange{Int64}}(1:10) x DomainSets.WrappedDomain{Bool,Array{Bool,1}}(Bool[1, 0]) x 0..1
julia> eltype(p)
Tuple{Int64,Bool,Int64}
julia> (4, true, 0.5) ∈ p
true
julia> p = ProductDomain([0..i for i in 1:5])
0..1 x 0..2 x 0..3 x 0..4 x 0..5
julia> typeof(p)
VectorProductDomain{Int64,Interval{:closed,:closed,Int64}}
julia> p = ProductDomain(UnitDisk(), UnitDisk())
the 2-dimensional closed unit ball x the 2-dimensional closed unit ball
julia> eltype(p)
SArray{Tuple{4},Float64,1,4}
|
I think this pull request is ready. Can you check @dlfivefifty for unexpected compatibility problems? I've tried to minimize breaking changes (exports etcetera). Support for vectors is much improved, and in particular the issue leading to #58 should work. |
This is creating several strange test failures and I can't figure out why.... |
I ran the ApproxFun test suite a while back and concluded at the time that at least the definition of the boundary made a difference, but I did not pursue it. In contrast I've had to make only very minor changes in my own packages because functionally nothing changed much, it was related to syntax change of spheres. Alright, I'll look into it, but it may not be right away. |
Can you fix the conflicts and I'll try again? |
I've looked at it but I don't think there is anything I can merge. The added test works on the "vector" branch: julia> using StaticArrays, DomainSets
julia> struct Basis3Vector <: StaticVector{3,Float64} end
julia> Base.getindex(::Basis3Vector, k::Int) = k == 1 ? 1.0 : 0.0
julia> Basis3Vector() in UnitSphere()
true The conversion in circle.jl that was extended no longer exists. To avoid hardcoding static vectors everywhere How did you arrive at a |
I ended up with a static vector because I made a special type to represent a point in spherical coordinates: |
That's good to know of, I did not check for that use case. |
This pull request is a work in progress. It started by addressing #53. It also (partially) addresses #44 and #43.
Similar to intervals, balls and simplices can now be closed or open.
A product domain has a
Vector
element type by invoking the constructor with a vector of domains (rather than a list of arguments or a tuple of domains):ProductDomain
has two constructors: the unqualifiedProductDomain
attempts to simplify the element type to an SVector as before, butProductDomain{T}
simply makes a product domain with the specified element typeT
. The translation between nested tuples and flat vectors is now done explicitly in productdomain.jl. As a result, the machinery of spaces and embeddings could be removed from this package, addressing Split out "isomorphisms" #43 and simplifying the code.Rather than storing an "internal and external" element type, the ProductDomain now keeps the dimensions of the domains:
The type parameter DIM is (2,1) in this example, which is enough information to do the conversion from a vector [1,2,3] to ([1,2], 3) and back efficiently and generically.
in
method in three steps:x
(this can be about applying a map, or converting between [1,2,3] and ([1,2],3),x
over its member domains, invoking theirin
functionin
of the member domains to a final result.For example, a
UnionDomain
will passx
unaltered to all its member domains, and do a mapreduce on the outcomes with|
. A ProductDomain will convertx
from flat to nested format, distribute the elements ofx
separately to its member domains, and combines the outcomes with&
. This does not go as far as ProductDomain -> VcatDomain #44 proposes, but it gets us closer.in
implementation of the genericDomain
attempts to do some conversions as before (possibly promoting bothx
and the domain), but it will also automatically do a limited number of conversions. It allows anyAbstractVector
for aVectorDomain
(which is aDomain{Vector{T}}
). It allows anyAbstractVector
for aEuclideanDomain
(which is aDomain{SVector{N,T}}
) by converting to anSVector
. It also allows anNTuple{N,T}
for aEuclideanDomain{N,T}
. It returns false if the types do not match, but currently prints a warning if that happens.