Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 34 additions & 40 deletions src/DomainSets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,24 @@ import Base:
# Set operations
setdiff, in, isempty, issubset, intersect, union, &, \,
# Arrays
eltype, hash, isreal,
eltype, hash,
# Types, promotions and conversions
convert, promote,
# for maps (both deprecated and to be removed)
size, inv,
# Display
show

import FunctionMaps:
convert_eltype,
convert_prectype,
convert_numtype,
prectype,
numtype,
factors,
isrealtype,
tointernalpoint,
toexternalpoint,
compatibleproductdims

import CompositeTypes: component, components

import IntervalSets: (..), endpoints, Domain, AbstractInterval, TypedEndpointsInterval,
Expand All @@ -31,9 +41,27 @@ import IntervalSets: (..), endpoints, Domain, AbstractInterval, TypedEndpointsIn
infimum, supremum
export ..

# to be removed in breaking version 0.8
import LinearAlgebra: cross, ×, pinv

using FunctionMaps:
CanonicalType,
Equal,
AbstractAffineMap,
GenericLinearMap,
GenericAffineMap,
interval_map,
UnitCircleMap,
AngleMap,
UnitDiskMap,
StaticTypes,
hashrec,
euclideandimension,
convert_eltype,
promotable_eltypes,
promote_prectype,
promote_numtype,
convert_fromcartesian,
convert_tocartesian,
nfactors,
factor

################################
## Exhaustive list of exports
Expand All @@ -47,36 +75,6 @@ export prectype, numtype,
convert_prectype, promote_prectype,
iscomposite, component, components, ncomponents

## Maps

include("maps_imports.jl")

# from maps/map.jl
export AbstractMap, Map, MapRef, TypedMap,
applymap, isequalmap,
domaintype, codomaintype,
inverse, leftinverse, rightinverse,
mapsize, mapdim, # mapdim is deprecated
jacobian, jacdet, diffvolume,
isrealmap
# from maps/composite.jl
export ComposedMap, composedmap
# from maps/product.jl
export ProductMap, productmap
# from maps/basic.jl
export IdentityMap,
StaticIdentityMap, VectorIdentityMap,
ZeroMap, UnityMap, ConstantMap,
isconstant, constant, # deprecated
isconstantmap, mapconstant,
isidentity, isidentitymap # isidentity is deprecated
# from maps/affine.jl
export AffineMap, Translation, LinearMap,
affinematrix, affinevector,
matrix, vector, # deprecated aliases
islinear, isaffine, # deprecated
islinearmap, isaffinemap

## Generic domains

# from generic/domain.jl
Expand Down Expand Up @@ -178,10 +176,6 @@ export LevelSet, ZeroSet,
# from domain/indicator.jl
export IndicatorFunction

## Applications
# from applications/rotation.jl
export rotation_map,
CartToPolarMap, PolarToCartMap

include("util/common.jl")

Expand Down
43 changes: 0 additions & 43 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,43 +0,0 @@

@deprecate convert_prectype(d::Domain, ::Type{T}) where {T} convert_prectype(T, d)
@deprecate convert_numtype(d::Domain, ::Type{T}) where {T} convert_numtype(T, d)

@deprecate point_in_domain(d) choice(d)

@deprecate broadcast_in(A, d::Domain) vectorized_in(A, d)
@deprecate broadcast_approx_in(A, d::Domain) vectorized_approx_in(A, d)
@deprecate broadcast_approx_in(A, d::Domain, tol) vectorized_approx_in(A, d, tol)

@deprecate UnionDomain(domain::Domain) UnionDomain((domain,))
@deprecate UnionDomain{T}(domain::Domain) where {T} UnionDomain{T}((domain,))
@deprecate IntersectDomain(domain::Domain) IntersectDomain((domain,))
@deprecate IntersectDomain{T}(domain::Domain) where T IntersectDomain((domain,))

@deprecate issubset(d1::AnyDomain, d2) issubset(d1, DomainRef(d2))
@deprecate union(d1::AnyDomain, d2, domains...) union(d1, DomainRef(d2), domains...)
@deprecate union(d1, d2::AnyDomain, domains...) union(DomainRef(d1), d2, domains...)
@deprecate intersect(d1, d2::AnyDomain) intersect(DomainRef(d1), d2)
@deprecate intersect(d1::AnyDomain, d2) intersect(d1, DomainRef(d2))
@deprecate \(d1::AnyDomain, d2) d1 \ DomainRef(d2)
@deprecate \(d1, d2::AnyDomain) DomainRef(d1) \ d2
@deprecate setdiff(d1::AnyDomain, d2) setdiff(d1, DomainRef(d2))
@deprecate setdiff(d1, d2::AnyDomain) setdiff(DomainRef(d1), d2)
@deprecate (&)(d1::AnyDomain, d2) d1 & DomainRef(d2)
@deprecate (&)(d1, d2::AnyDomain) DomainRef(d1) & d2

@deprecate isequal1(d1,d2) isequaldomain1(d1,d2)
@deprecate isequal2(d1,d2) isequaldomain2(d1,d2)

# AsDomain was defined in versions 0.7 and 0.7.1, and then replaced by DomainRef
@deprecate AsDomain(d) DomainRef(d)

@deprecate inv(m::AbstractMap) inverse(m)

@deprecate size(m::AbstractMap) mapsize(m)
@deprecate size(m::AbstractMap, i) mapsize(m, i)
@deprecate issquare(m::AbstractMap) issquaremap(m)

# Added in v0.7.17, to be removed in v0.8
@deprecate isreal(d::Domain) isrealdomain(d)
LinearAlgebra.cross(d1::Domain, domains...) = linearalgebra_x_becomes_domainsets_x(d1, domains...)
@deprecate linearalgebra_x_becomes_domainsets_x(d1::Domain, domains...) cartesianproduct(d1, domains...)
10 changes: 6 additions & 4 deletions src/domains/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ show(io::IO, d::ComplexUnitDisk{T,:open}) where {T} = print(io, "ComplexUnitDisk
canonicaldomain(::Parameterization, d::ComplexUnitCircle{T}) where {T} =
UnitInterval{T}()
mapfrom_canonical(::Parameterization, d::ComplexUnitCircle{T}) where {T} =
VectorToComplex{T}() ∘ UnitCircleMap{T}()
FunctionMaps.VectorToComplex{T}() ∘ UnitCircleMap{T}()

canonicaldomain(::Isomorphic, d::ComplexUnitCircle{T}) where {T} = UnitCircle{T}()
mapfrom_canonical(::Isomorphic, d::ComplexUnitCircle{T}) where {T} = VectorToComplex{T}()
mapfrom_canonical(::Isomorphic, d::ComplexUnitCircle{T}) where {T} =
FunctionMaps.VectorToComplex{T}()

canonicaldomain(::Parameterization, d::ComplexUnitDisk{T}) where {T} = UnitSquare{T}()
mapfrom_canonical(::Parameterization, d::ComplexUnitDisk{T}) where {T} =
VectorToComplex{T}() ∘ UnitDiskMap{T}()
FunctionMaps.VectorToComplex{T}() ∘ UnitDiskMap{T}()

canonicaldomain(::Isomorphic, d::ComplexUnitDisk{T}) where {T} = UnitCircle{T}()
mapfrom_canonical(::Isomorphic, d::ComplexUnitDisk{T}) where {T} = VectorToComplex{T}()
mapfrom_canonical(::Isomorphic, d::ComplexUnitDisk{T}) where {T} =
FunctionMaps.VectorToComplex{T}()
2 changes: 1 addition & 1 deletion src/domains/interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ identitymap(d::TypedEndpointsInterval{L,R,T}) where {L,R,T<:Integer} = IdentityM
canonicaldomain(d::TypedEndpointsInterval{:closed,:closed,T}) where {T} =
ChebyshevInterval{T}()
mapfrom_canonical(d::TypedEndpointsInterval{:closed,:closed}) =
bounded_interval_map(-1, 1, endpoints(d)...)
FunctionMaps.bounded_interval_map(-1, 1, endpoints(d)...)

canonicaldomain(d::FixedInterval) = d
canonicaldomain(ctype::Equal, d::FixedInterval) = d
Expand Down
4 changes: 2 additions & 2 deletions src/domains/trivial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ isequaldomain2(d1, d2::EmptySpace) = isempty(d1)
domainhash(d::EmptySpace, h::UInt) = hash("EmptySpace", h)

mapto1(d1::EmptySpace{T}, d2) where {T} =
isempty(d2) ? StaticIdentityMap{T}() : throw(ArgumentError("Can't map empty to non-empty domain"))
isempty(d2) ? IdentityMap{T}() : throw(ArgumentError("Can't map empty to non-empty domain"))
mapto2(d1, d2::EmptySpace{T}) where {T} =
isempty(d1) ? StaticIdentityMap{T}() : throw(ArgumentError("Can't map non-empty to empty domain"))
isempty(d1) ? IdentityMap{T}() : throw(ArgumentError("Can't map non-empty to empty domain"))


"""
Expand Down
2 changes: 1 addition & 1 deletion src/generic/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ broadcasted(::DomainSetStyle, ::typeof(/), d::AnyDomain, a::Number) =
broadcasted(::DomainSetStyle, ::typeof(\), a::Number, d::AnyDomain) =
mapped_domain(LinearMap(a), domain(d))

broadcasted(::DomainSetStyle, m::AbstractMap, d::AnyDomain) =
broadcasted(::DomainSetStyle, m::Map, d::AnyDomain) =
map_domain(m, domain(d))

broadcasted(::DomainSetStyle, fun::Function, d::AnyDomain) =
Expand Down
4 changes: 2 additions & 2 deletions src/generic/canonical.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ mapto_canonical(::Isomorphic, d) = leftinverse(mapfrom_canonical(Isomorphic(), d
canonicaldomain(::Isomorphic, d::Domain{<:StaticVector{1,T}}) where {T} =
convert(Domain{T}, d)
mapfrom_canonical(::Isomorphic, d::Domain{<:StaticVector{1,T}}) where {T} =
NumberToVector{T}()
FunctionMaps.NumberToVector{T}()

canonicaldomain(::Isomorphic, d::Domain{NTuple{N,T}}) where {N,T} =
convert(Domain{SVector{N,T}}, d)
mapfrom_canonical(::Isomorphic, d::Domain{NTuple{N,T}}) where {N,T} =
VectorToTuple{N,T}()
FunctionMaps.VectorToTuple{N,T}()



Expand Down
6 changes: 3 additions & 3 deletions src/generic/mapped.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ corners(d::AbstractMappedDomain) = [forward_map(d, x) for x in corners(superdoma

show(io::IO, mime::MIME"text/plain", d::AbstractMappedDomain) = composite_show(io, mime, d)
Display.displaystencil(d::AbstractMappedDomain) =
map_stencil_broadcast(forward_map(d), superdomain(d))
FunctionMaps.map_stencil_broadcast(forward_map(d), superdomain(d))
Display.object_parentheses(d::AbstractMappedDomain) =
FunctionMaps.map_object_parentheses(forward_map(d))
Display.stencil_parentheses(d::AbstractMappedDomain) =
Expand All @@ -56,7 +56,7 @@ _promote_map_domain_pair(map, domain, ::Type{T}, ::Type{T}) where T = map, domai
_promote_map_domain_pair(map, domain, ::Type{S}, ::Type{T}) where {S,T} =
_promote_map_domain_pair(map, domain, S, T, promote_type(S,T))
_promote_map_domain_pair(map, domain, ::Type{S}, ::Type{T}, ::Type{U}) where {S,T,U} =
convert_codomaintype(U, map), convert_eltype(U, domain)
FunctionMaps.convert_codomaintype(U, map), convert_eltype(U, domain)
_promote_map_domain_pair(map, domain, ::Type{Any}, ::Type{T}, ::Type{Any}) where T =
map, domain
_promote_map_domain_pair(map, domain, ::Type{S}, ::Type{Any}, ::Type{Any}) where S =
Expand Down Expand Up @@ -86,7 +86,7 @@ _MappedDomain(invmap, domain) =
_MappedDomainT(mapped_domain_eltype(invmap,domain), invmap, domain)

MappedDomain{T}(invmap, domain) where T =
_MappedDomainT(T, convert_domaintype(T, invmap), convert_eltype(T, domain))
_MappedDomainT(T, FunctionMaps.convert_domaintype(T, invmap), convert_eltype(T, domain))
_MappedDomainT(::Type{T}, invmap, domain) where T =
MappedDomain{T,typeof(invmap),typeof(domain)}(invmap, domain)

Expand Down
9 changes: 4 additions & 5 deletions src/generic/productdomain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ julia> (0..1) × (2..3)
````
"""
cartesianproduct(d...) = productdomain(d...)
# To be activated in v0.8:
# × = cartesianproduct
× = cartesianproduct

Base.:^(d::Domain, n::Int) = productdomain(ntuple(i->d, n)...)

Expand Down Expand Up @@ -152,12 +151,12 @@ end

# multiplication with a scalar number
function map_domain(linmap::GenericLinearMap{<:StaticVector{N,S},A}, domain::ProductDomain{<:StaticVector{N,T}}) where {N,S,T,A<:Number}
c = unsafe_matrix(linmap)
c = FunctionMaps.unsafe_matrix(linmap)
ProductDomain{SVector{N,promote_type(S,T)}}(map(d -> c .* d, components(domain)))
end

function map_domain(transmap::Translation{<:StaticVector{N,S}}, domain::ProductDomain{<:StaticVector{N,T}}) where {N,S,T}
vec = unsafe_vector(transmap)
vec = FunctionMaps.unsafe_vector(transmap)
ProductDomain{SVector{N,promote_type(S,T)}}(
map( (d,v) -> d .+ v, components(domain), tointernalpoint(domain, vec)))
end
Expand Down Expand Up @@ -258,4 +257,4 @@ end
TupleProductDomain{T}(domains::Tuple) where {T} =
TupleProductDomain{T,typeof(domains)}(domains)

matching_product_map(d::TupleProductDomain, maps) = TupleProductMap(maps)
matching_product_map(d::TupleProductDomain, maps) = FunctionMaps.TupleProductMap(maps)
114 changes: 0 additions & 114 deletions src/maps_imports.jl

This file was deleted.

Loading
Loading