Skip to content

DomainSets 0.0.2 support #1

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

Merged
merged 1 commit into from
Apr 22, 2019
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
4 changes: 3 additions & 1 deletion src/ApproxFunBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import StaticArrays, Calculus

import DomainSets: Domain, indomain, UnionDomain, ProductDomain, FullSpace, Point, elements, DifferenceDomain,
Interval, ChebyshevInterval, boundary, ∂, rightendpoint, leftendpoint,
dimension, Domain1d, Domain2d
dimension



import AbstractFFTs: Plan, fft, ifft
import FFTW: plan_r2r!, fftwNumber, REDFT10, REDFT01, REDFT00, RODFT00, R2HC, HC2R,
Expand Down
4 changes: 2 additions & 2 deletions src/Multivariate/LowRankFun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ end

## Construction in a TensorSpace via a Vector of Funs

function LowRankFun(X::Vector{VFun{S,T}},d::TensorSpace{SV,DD}) where {S,T,DD<:Domain2d,SV}
function LowRankFun(X::Vector{VFun{S,T}},d::TensorSpace{SV,DD}) where {S,T,DD<:EuclideanDomain{2},SV}
@assert d[1] == space(X[1])
LowRankFun(X,d[2])
end
Expand Down Expand Up @@ -190,7 +190,7 @@ end

## Construction via TensorSpaces and ProductDomains

LowRankFun(f::Function,S::TensorSpace{SV,DD,RR};kwds...) where {SV,DD<:Domain2d,RR} =
LowRankFun(f::Function,S::TensorSpace{SV,DD,RR};kwds...) where {SV,DD<:EuclideanDomain{2},RR} =
LowRankFun(dynamic(f),factor(S,1),factor(S,2);kwds...)
LowRankFun(f::Function,dx::Domain,dy::Domain;kwds...) =
LowRankFun(dynamic(f),Space(dx),Space(dy);kwds...)
Expand Down
2 changes: 1 addition & 1 deletion src/Multivariate/ProductFun.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ ProductFun(f::Function,dx::Space,dy::Space)=ProductFun(dynamic(f),TensorSpace(dx

ProductFun(f::Function,D::Domain,M::Integer,N::Integer) = ProductFun(dynamic(f),Space(D),M,N)
ProductFun(f::Function,d::Domain) = ProductFun(dynamic(f),Space(d))
ProductFun(f::Function,dx::Domain1d,dy::Domain1d) = ProductFun(dynamic(f),Space(dx),Space(dy))
ProductFun(f::Function, dx::EuclideanDomain{1}, dy::EuclideanDomain{1}) = ProductFun(dynamic(f),Space(dx),Space(dy))
ProductFun(f::Function) = ProductFun(dynamic(f),ChebyshevInterval(),ChebyshevInterval())

## Conversion from other 2D Funs
Expand Down
14 changes: 7 additions & 7 deletions src/Multivariate/TensorSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ end

## points

points(d::Union{Domain2d,BivariateSpace},n,m) = points(d,n,m,1),points(d,n,m,2)
points(d::Union{EuclideanDomain{2},BivariateSpace},n,m) = points(d,n,m,1),points(d,n,m,2)

function points(d::BivariateSpace,n,m,k)
ptsx=points(columnspace(d,1),n)
Expand Down Expand Up @@ -510,16 +510,16 @@ union_rule(a::TensorSpace,b::TensorSpace) = TensorSpace(map(union,a.spaces,b.spa
# (domain(ts)[2] == Point(0.0) && isconvertible(sp,ts.spaces[1])))
# end

isconvertible(sp::UnivariateSpace,ts::TensorSpace{SV,D,R}) where {SV,D<:Domain2d,R} = length(ts.spaces) == 2 &&
isconvertible(sp::UnivariateSpace,ts::TensorSpace{SV,D,R}) where {SV,D<:EuclideanDomain{2},R} = length(ts.spaces) == 2 &&
((domain(ts)[1] == Point(0.0) && isconvertible(sp,ts.spaces[2])) ||
(domain(ts)[2] == Point(0.0) && isconvertible(sp,ts.spaces[1])))


# coefficients(f::AbstractVector,sp::ConstantSpace,ts::TensorSpace{SV,D,R}) where {SV,D<:Domain2d,R} =
# coefficients(f::AbstractVector,sp::ConstantSpace,ts::TensorSpace{SV,D,R}) where {SV,D<:EuclideanDomain{2},R} =
# f[1]*ones(ts).coefficients

#
# function coefficients(f::AbstractVector,sp::Space{IntervalOrSegment{Vec{2,TT}}},ts::TensorSpace{Tuple{S,V},D,R}) where {S,V<:ConstantSpace,D<:Domain2d,R,TT} where {T<:Number}
# function coefficients(f::AbstractVector,sp::Space{IntervalOrSegment{Vec{2,TT}}},ts::TensorSpace{Tuple{S,V},D,R}) where {S,V<:ConstantSpace,D<:EuclideanDomain{2},R,TT} where {T<:Number}
# a = domain(sp)
# b = domain(ts)
# # make sure we are the same domain. This will be replaced by isisomorphic
Expand All @@ -530,7 +530,7 @@ isconvertible(sp::UnivariateSpace,ts::TensorSpace{SV,D,R}) where {SV,D<:Domain2d
# end


function coefficients(f::AbstractVector,sp::UnivariateSpace,ts::TensorSpace{SV,D,R}) where {SV,D<:Domain2d,R}
function coefficients(f::AbstractVector,sp::UnivariateSpace,ts::TensorSpace{SV,D,R}) where {SV,D<:EuclideanDomain{2},R}
@assert length(ts.spaces) == 2

if factor(domain(ts),1) == Point(0.0)
Expand All @@ -543,7 +543,7 @@ function coefficients(f::AbstractVector,sp::UnivariateSpace,ts::TensorSpace{SV,D
end


function isconvertible(sp::Space{Segment{Vec{2,TT}}},ts::TensorSpace{SV,D,R}) where {TT,SV,D<:Domain2d,R}
function isconvertible(sp::Space{Segment{Vec{2,TT}}},ts::TensorSpace{SV,D,R}) where {TT,SV,D<:EuclideanDomain{2},R}
d1 = domain(sp)
d2 = domain(ts)
if length(ts.spaces) ≠ 2
Expand All @@ -562,7 +562,7 @@ end


function coefficients(f::AbstractVector,sp::Space{Segment{Vec{2,TT}}},
ts::TensorSpace{SV,D,R}) where {TT,SV,D<:Domain2d,R}
ts::TensorSpace{SV,D,R}) where {TT,SV,D<:EuclideanDomain{2},R}
@assert length(ts.spaces) == 2
d1 = domain(sp)
d2 = domain(ts)
Expand Down
2 changes: 1 addition & 1 deletion src/PDE/KroneckerOperator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ Base.transpose(S::ConstantTimesOperator) = sp.c*transpose(S.op)
### Calculus

#TODO: general dimension
function Derivative(S::TensorSpace{SV,DD},order::Vector{Int}) where {SV,DD<:Domain2d}
function Derivative(S::TensorSpace{SV,DD},order::Vector{Int}) where {SV,DD<:EuclideanDomain{2}}
@assert length(order)==2
if order[1]==0
Dy=Derivative(S.spaces[2],order[2])
Expand Down
2 changes: 1 addition & 1 deletion src/PDE/PDE.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Laplacian(d::BivariateSpace,k::Integer)
end
end

Laplacian(d::Domain2d, k::Integer) = Laplacian(Space(d),k)
Laplacian(d::EuclideanDomain{2}, k::Integer) = Laplacian(Space(d),k)
grad(d::ProductDomain) = [Derivative(d,[1,0]),Derivative(d,[0,1])]


Expand Down
6 changes: 3 additions & 3 deletions src/Space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ abstract type Space{D,R} end

const RealSpace = Space{D,R} where {D,R<:Real}
const ComplexSpace = Space{D,R} where {D,R<:Complex}
const UnivariateSpace = Space{D,R} where {D<:Domain1d,R}
const BivariateSpace = Space{D,R} where {D<:Domain2d,R}
const RealUnivariateSpace = RealSpace{D,R} where {D<:Domain1d,R<:Real}
const UnivariateSpace = Space{D,R} where {D<:EuclideanDomain{1},R}
const BivariateSpace = Space{D,R} where {D<:EuclideanDomain{2},R}
const RealUnivariateSpace = RealSpace{D,R} where {D<:EuclideanDomain{1},R<:Real}



Expand Down
6 changes: 3 additions & 3 deletions src/Spaces/ArraySpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pieces(f::Fun{<:ArraySpace}) = [piece(f,k) for k=1:npieces(f)]

fromcanonical(d::ProductDomain, f::Fun{<:ArraySpace}) = vcat(fromcanonical.(factors(d), vec(f))...)

function coefficients(f::AbstractVector,sp::ArraySpace{<:ConstantSpace{AnyDomain}},ts::TensorSpace{SV,D,R}) where {SV,D<:Domain2d,R}
function coefficients(f::AbstractVector,sp::ArraySpace{<:ConstantSpace{AnyDomain}},ts::TensorSpace{SV,D,R}) where {SV,D<:EuclideanDomain{2},R}
@assert length(ts.spaces) == 2

if ts.spaces[1] isa ArraySpace
Expand All @@ -278,14 +278,14 @@ ArraySpace(sp::TensorSpace{Tuple{S1,S2}}) where {S1<:Space{D,R},S2} where {D,R<:
ArraySpace(sp::TensorSpace{Tuple{S1,S2}},k...) where {S1,S2<:Space{D,R}} where {D,R<:AbstractArray} =
ArraySpace(map(a -> sp.spaces[1] ⊗ a, sp.spaces[2]))

function coefficients(f::AbstractVector, a::VectorSpace, b::TensorSpace{Tuple{S1,S2},<:Domain2d}) where {S1<:Space{D,R},S2} where {D,R<:AbstractArray}
function coefficients(f::AbstractVector, a::VectorSpace, b::TensorSpace{Tuple{S1,S2},<:EuclideanDomain{2}}) where {S1<:Space{D,R},S2} where {D,R<:AbstractArray}
if size(a) ≠ size(b)
throw(DimensionMismatch("dimensions must match"))
end
interlace(map(coefficients,Fun(a,f),b),ArraySpace(b))
end

function coefficients(f::AbstractVector, a::VectorSpace, b::TensorSpace{Tuple{S1,S2},<:Domain2d}) where {S1,S2<:Space{D,R}} where {D,R<:AbstractArray}
function coefficients(f::AbstractVector, a::VectorSpace, b::TensorSpace{Tuple{S1,S2},<:EuclideanDomain{2}}) where {S1,S2<:Space{D,R}} where {D,R<:AbstractArray}
if size(a) ≠ size(b)
throw(DimensionMismatch("dimensions must match"))
end
Expand Down
6 changes: 3 additions & 3 deletions src/Spaces/ConstantSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ union_rule(A::ConstantSpace,B::Space) = ConstantSpace(domain(B))⊕B
## Special Multiplication and Conversion for constantspace

# TODO: this is a special work around but really we want it to be blocks
Conversion(a::ConstantSpace,b::Space{D}) where {D<:Domain2d} = ConcreteConversion{typeof(a),typeof(b),
Conversion(a::ConstantSpace,b::Space{D}) where {D<:EuclideanDomain{2}} = ConcreteConversion{typeof(a),typeof(b),
promote_type(real(prectype(a)),real(prectype(b)))}(a,b)

Conversion(a::ConstantSpace,b::Space) = ConcreteConversion(a,b)
Expand All @@ -130,10 +130,10 @@ end


coefficients(f::AbstractVector,sp::ConstantSpace{Segment{Vec{2,TT}}},
ts::TensorSpace{SV,DD}) where {TT,SV,DD<:Domain2d} =
ts::TensorSpace{SV,DD}) where {TT,SV,DD<:EuclideanDomain{2}} =
f[1]*ones(ts).coefficients
coefficients(f::AbstractVector,sp::ConstantSpace{<:Domain{<:Number}},
ts::TensorSpace{SV,DD}) where {TT,SV,DD<:Domain2d} =
ts::TensorSpace{SV,DD}) where {TT,SV,DD<:EuclideanDomain{2}} =
f[1]*ones(ts).coefficients
coefficients(f::AbstractVector, sp::ConstantSpace{<:Domain{<:Number}}, ts::Space) =
f[1]*ones(ts).coefficients
Expand Down
4 changes: 2 additions & 2 deletions src/Spaces/SubSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ points(sp::SubSpace, n) = points(sp.space, n)
points(sp::SubSpace) = points(sp, dimension(sp))


coefficients(v::AbstractVector,::SubSpace{DS,IT,Segment{Vec{2,TT}}},::TensorSpace{SV,DD}) where {DS,IT,TT,SV,DD<:Domain2d} =
coefficients(v::AbstractVector,::SubSpace{DS,IT,Segment{Vec{2,TT}}},::TensorSpace{SV,DD}) where {DS,IT,TT,SV,DD<:EuclideanDomain{2}} =
error("Not callable, only defined for ambiguity errors.")
coefficients(v::AbstractVector,::SubSpace{DS,IT,D},::TensorSpace{SV,DD}) where {DS,IT,D,SV,DD<:Domain2d} =
coefficients(v::AbstractVector,::SubSpace{DS,IT,D},::TensorSpace{SV,DD}) where {DS,IT,D,SV,DD<:EuclideanDomain{2}} =
error("Not callable, only defined for ambiguity errors.")

for TYP in (:SumSpace,:PiecewiseSpace,:TensorSpace,:ConstantSpace,:Space) # Resolve conflict
Expand Down
2 changes: 1 addition & 1 deletion src/specialfunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ for OP in (:abs,:sign,:log,:angle)
@eval begin
$OP(f::Fun{<:PiecewiseSpace{<:Any,<:Any,<:Real},<:Real}) =
Fun(map($OP,components(f)),PiecewiseSpace)
$OP(f::Fun{<:PiecewiseSpace{<:Any,<:Domain1d}}) =
$OP(f::Fun{<:PiecewiseSpace{<:Any,<:EuclideanDomain{1}}}) =
Fun(map($OP,components(f)),PiecewiseSpace)
end
end
Expand Down