Skip to content

Commit bf25662

Browse files
committed
Concrete derivatives for Ultraspherical and Jacobi
1 parent 91068f3 commit bf25662

File tree

5 files changed

+38
-18
lines changed

5 files changed

+38
-18
lines changed

src/Spaces/Chebyshev/Chebyshev.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const NormalizedChebyshev{D<:Domain,R} = NormalizedPolynomialSpace{Chebyshev{D,
2626
NormalizedChebyshev() = NormalizedPolynomialSpace(Chebyshev())
2727
NormalizedChebyshev(d) = NormalizedPolynomialSpace(Chebyshev(d))
2828

29-
function Base.getproperty(S::Chebyshev{<:Any,<:Any},v::Symbol)
29+
function getproperty(S::Chebyshev, v::Symbol)
3030
if v==:b || v==:a
3131
-0.5
3232
else

src/Spaces/Jacobi/JacobiOperators.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## Derivative
22

33
# specialize Derivative so that this is type-inferred even without constant propagation
4-
Derivative(J::Jacobi) = ConcreteDerivative(J,1)
4+
Derivative(J::MaybeNormalized{<:Jacobi}) = ConcreteDerivative(J,1)
55
@inline function _Derivative(J::Jacobi, k::Number)
66
assert_integer(k)
77
if k==1
@@ -20,9 +20,9 @@ else
2020
end
2121

2222

23-
rangespace(D::ConcreteDerivative{<:Jacobi}) = Jacobi(D.space.b+D.order,D.space.a+D.order,domain(D))
24-
bandwidths(D::ConcreteDerivative{<:Jacobi}) = -D.order,D.order
25-
isdiag(D::ConcreteDerivative{<:Jacobi}) = false
23+
rangespace(D::ConcreteDerivative{<:MaybeNormalized{<:Jacobi}}) = Jacobi(D.space.b+D.order,D.space.a+D.order,domain(D))
24+
bandwidths(D::ConcreteDerivative{<:MaybeNormalized{<:Jacobi}}) = -D.order,D.order
25+
isdiag(D::ConcreteDerivative{<:MaybeNormalized{<:Jacobi}}) = false
2626

2727
getindex(T::ConcreteDerivative{<:Jacobi}, k::Integer, j::Integer) =
2828
j==k+1 ? eltype(T)((k+1+T.space.a+T.space.b)/complexlength(domain(T))) : zero(eltype(T))

src/Spaces/PolynomialSpace.jl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,11 @@ end
430430

431431
@containsconstants NormalizedPolynomialSpace
432432

433+
@inline function getproperty(N::NormalizedPolynomialSpace, v::Symbol)
434+
((v == :a) || (v == :b)) && return getproperty(getfield(N, :space), v)
435+
getfield(N, v)
436+
end
437+
433438
domain(S::NormalizedPolynomialSpace) = domain(S.space)
434439
canonicalspace(S::NormalizedPolynomialSpace) = S.space
435440
setdomain(NS::NormalizedPolynomialSpace, d::Domain) = NormalizedPolynomialSpace(setdomain(canonicalspace(NS), d))
@@ -505,8 +510,8 @@ end
505510

506511
# Conversion
507512

508-
bandwidths(C::ConcreteConversion{NormalizedPolynomialSpace{S,D,R},S}) where {S,D,R} = (0, 0)
509-
bandwidths(C::ConcreteConversion{S,NormalizedPolynomialSpace{S,D,R}}) where {S,D,R} = (0, 0)
513+
bandwidths(::ConcreteConversion{<:NormalizedPolynomialSpace{S},S}) where {S} = (0, 0)
514+
bandwidths(::ConcreteConversion{S,<:NormalizedPolynomialSpace{S}}) where {S} = (0, 0)
510515

511516
function getindex(C::ConcreteConversion{NormalizedPolynomialSpace{S,D,R},S,T},k::Integer,j::Integer) where {S,D<:IntervalOrSegment,R,T}
512517
if j==k

src/Spaces/Ultraspherical/UltrasphericalOperators.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ end
5757
#Derivative(d::IntervalOrSegment)=Derivative(1,d)
5858

5959

60-
function Derivative(sp::Ultraspherical{LT,DD}, m::Number) where {LT,DD<:IntervalOrSegment}
60+
function Derivative(sp::MaybeNormalized{<:Ultraspherical{<:Any,<:IntervalOrSegment}}, m::Number)
6161
assert_integer(m)
6262
ConcreteDerivative(sp,m)
6363
end
@@ -75,15 +75,15 @@ function Integral(sp::Ultraspherical{<:Any,<:IntervalOrSegment}, m::Number)
7575
end
7676

7777

78-
rangespace(D::ConcreteDerivative{<:Ultraspherical{LT,DD}}) where {LT,DD<:IntervalOrSegment} =
78+
rangespace(D::ConcreteDerivative{<:MaybeNormalized{<:Ultraspherical{<:Any,<:IntervalOrSegment}}}) =
7979
Ultraspherical(order(domainspace(D))+D.order,domain(D))
8080

81-
bandwidths(D::ConcreteDerivative{<:Ultraspherical{LT,DD}}) where {LT,DD<:IntervalOrSegment} = -D.order,D.order
82-
bandwidths(D::ConcreteIntegral{<:Ultraspherical{LT,DD}}) where {LT,DD<:IntervalOrSegment} = D.order,-D.order
83-
Base.stride(D::ConcreteDerivative{<:Ultraspherical{LT,DD}}) where {LT,DD<:IntervalOrSegment} = D.order
81+
bandwidths(D::ConcreteDerivative{<:MaybeNormalized{<:Ultraspherical{<:Any,<:IntervalOrSegment}}}) = -D.order,D.order
82+
bandwidths(D::ConcreteIntegral{<:MaybeNormalized{<:Ultraspherical{<:Any,<:IntervalOrSegment}}}) = D.order,-D.order
83+
Base.stride(D::ConcreteDerivative{<:MaybeNormalized{<:Ultraspherical{<:Any,<:IntervalOrSegment}}}) = D.order
8484

85-
isdiag(D::ConcreteDerivative{<:Ultraspherical{<:Any,<:IntervalOrSegment}}) = false
86-
isdiag(D::ConcreteIntegral{<:Ultraspherical{<:Any,<:IntervalOrSegment}}) = false
85+
isdiag(D::ConcreteDerivative{<:MaybeNormalized{<:Ultraspherical{<:Any,<:IntervalOrSegment}}}) = false
86+
isdiag(D::ConcreteIntegral{<:MaybeNormalized{<:Ultraspherical{<:Any,<:IntervalOrSegment}}}) = false
8787

8888
function getindex(D::ConcreteDerivative{<:Ultraspherical{TT,DD},K,T},
8989
k::Integer,j::Integer) where {TT,DD<:IntervalOrSegment,K,T}

src/fastops.jl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ end
7272

7373

7474

75-
function BandedMatrix(S::SubOperator{T,ConcreteDerivative{Chebyshev{DD,RR},K,T},
76-
NTuple{2,UnitRange{Int}}}) where {T,K,DD,RR}
75+
function BandedMatrix(S::SubOperator{T,<:ConcreteDerivative{<:Chebyshev,<:Any,T},
76+
NTuple{2,UnitRange{Int}}}) where {T}
7777

7878
n,m = size(S)
7979
ret = BandedMatrix{eltype(S)}(undef, (n,m), bandwidths(S))
@@ -98,8 +98,8 @@ function BandedMatrix(S::SubOperator{T,ConcreteDerivative{Chebyshev{DD,RR},K,T},
9898
end
9999

100100

101-
function BandedMatrix(S::SubOperator{T,ConcreteDerivative{Ultraspherical{LT,DD,RR},K,T},
102-
NTuple{2,UnitRange{Int}}}) where {T,K,DD,RR,LT}
101+
function BandedMatrix(S::SubOperator{T,<:ConcreteDerivative{<:Ultraspherical,T},
102+
NTuple{2,UnitRange{Int}}}) where {T}
103103
n,m = size(S)
104104
ret = BandedMatrix{eltype(S)}(undef, (n,m), bandwidths(S))
105105
kr,jr = parentindices(S)
@@ -116,3 +116,18 @@ function BandedMatrix(S::SubOperator{T,ConcreteDerivative{Ultraspherical{LT,DD,R
116116
ret
117117
end
118118

119+
function BandedMatrix(S::SubOperator{T,<:ConcreteDerivative{<:NormalizedPolynomialSpace,<:Any,T},
120+
NTuple{2,UnitRange{Int}}}) where {T}
121+
122+
D = parent(S)
123+
sp = domainspace(D)
124+
csp = canonicalspace(sp)
125+
ind1, ind2 = parentindices(S)
126+
B = BandedMatrix(view(ConcreteDerivative(csp, D.order), ind1, ind2))
127+
data = BandedMatrices.bandeddata(B)
128+
C = ConcreteConversion(sp, csp)
129+
for (ind, col) in enumerate(ind2)
130+
@views data[:, ind] .*= C[col, col]
131+
end
132+
B
133+
end

0 commit comments

Comments
 (0)