Skip to content

Commit 5edd3e2

Browse files
authored
Fewer type parameters in chebyshev operator methods (#331)
1 parent 205f7d6 commit 5edd3e2

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

src/Spaces/Chebyshev/ChebyshevOperators.jl

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ recγ(::Type{T},::Chebyshev,k) where {T} = one(T)/2 # one(T) ensures we get co
1313

1414
## Evaluation
1515

16-
Evaluation(S::MaybeNormalized{<:Chebyshev},x::Number,o::Integer) = ConcreteEvaluation(S,x,o)
16+
Evaluation(S::MaybeNormalized{<:Chebyshev}, x::Number, o::Integer) = ConcreteEvaluation(S,x,o)
1717

18-
function evaluatechebyshev(n::Integer,x::T) where T<:Number
18+
function evaluatechebyshev(n::Integer, x::T) where T<:Number
1919
if n == 1
2020
[one(T)]
2121
else
@@ -33,7 +33,7 @@ function evaluatechebyshev(n::Integer,x::T) where T<:Number
3333
end
3434

3535
# We assume that x is already scaled to the canonical domain. S is unused here
36-
function forwardrecurrence(::Type{T},S::Chebyshev,r::AbstractUnitRange{<:Integer},x::Number) where {T}
36+
function forwardrecurrence(::Type{T}, S::Chebyshev, r::AbstractUnitRange{<:Integer}, x::Number) where {T}
3737
@assert !isempty(r) && first(r) >= 0
3838
v = evaluatechebyshev(maximum(r)+1, T(x))
3939
first(r) == 0 ? v : v[r .+ 1]
@@ -64,7 +64,8 @@ function _getindex_eval_leftendpoint(op::ConcreteEvaluation{<:Chebyshev{<:Interv
6464
op[j:j][1]
6565
end
6666
end
67-
function _getindex_eval_rightendpoint(op::ConcreteEvaluation{<:Chebyshev{<:IntervalOrSegment}}, x, j::Integer)
67+
function _getindex_eval_rightendpoint(op::ConcreteEvaluation{<:Chebyshev{<:IntervalOrSegment}},
68+
x, j::Integer)
6869
T=eltype(op)
6970
if op.order == 0
7071
one(T)
@@ -73,7 +74,8 @@ function _getindex_eval_rightendpoint(op::ConcreteEvaluation{<:Chebyshev{<:Inter
7374
op[j:j][1]
7475
end
7576
end
76-
function _getindex_eval_leftendpoint(op::ConcreteEvaluation{<:Chebyshev{<:IntervalOrSegment}}, x, k::AbstractUnitRange)
77+
function _getindex_eval_leftendpoint(op::ConcreteEvaluation{<:Chebyshev{<:IntervalOrSegment}},
78+
x, k::AbstractUnitRange)
7779
Base.require_one_based_indexing(k)
7880
T=eltype(op)
7981
x = op.x
@@ -96,7 +98,8 @@ function _getindex_eval_leftendpoint(op::ConcreteEvaluation{<:Chebyshev{<:Interv
9698

9799
scal!(cst,ret)
98100
end
99-
function _getindex_eval_rightendpoint(op::ConcreteEvaluation{<:Chebyshev{<:IntervalOrSegment}}, x, k::AbstractUnitRange)
101+
function _getindex_eval_rightendpoint(op::ConcreteEvaluation{<:Chebyshev{<:IntervalOrSegment}},
102+
x, k::AbstractUnitRange)
100103
Base.require_one_based_indexing(k)
101104
T=eltype(op)
102105
x = op.x
@@ -134,8 +137,7 @@ else
134137
end
135138
end
136139

137-
function getindex(op::ConcreteDirichlet{<:Chebyshev},
138-
k::Integer,j::Integer)
140+
function getindex(op::ConcreteDirichlet{<:Chebyshev}, k::Integer, j::Integer)
139141
if op.order == 0
140142
k == 1 && iseven(j) && return -one(eltype(op))
141143
return one(eltype(op))
@@ -144,8 +146,8 @@ function getindex(op::ConcreteDirichlet{<:Chebyshev},
144146
end
145147
end
146148

147-
function Matrix(S::SubOperator{T,ConcreteDirichlet{C,V,T},
148-
NTuple{2,UnitRange{Int}}}) where {C<:Chebyshev,V,T}
149+
function Matrix(S::SubOperator{T,<:ConcreteDirichlet{<:Chebyshev,<:Any,T},
150+
NTuple{2,UnitRange{Int}}}) where {T}
149151
ret = Array{T}(undef, size(S)...)
150152
kr,jr = parentindices(S)
151153
isempty(kr) && return ret
@@ -168,13 +170,12 @@ end
168170

169171
# Multiplication
170172

171-
Base.stride(M::ConcreteMultiplication{U,V}) where {U<:Chebyshev,V<:Chebyshev} =
172-
stride(M.f)
173+
Base.stride(M::ConcreteMultiplication{<:Chebyshev,<:Chebyshev}) = stride(M.f)
173174

174-
getindex(M::ConcreteMultiplication{C,C,T},k::Integer,j::Integer) where {T,C<:Chebyshev} =
175+
getindex(M::ConcreteMultiplication{C,C},k::Integer,j::Integer) where {C<:Chebyshev} =
175176
chebmult_getindex(coefficients(M.f),k,j)
176177

177-
getindex(M::ConcreteMultiplication{C,PS,T},k::Integer,j::Integer) where {PS<:PolynomialSpace,T,C<:Chebyshev} =
178+
getindex(M::ConcreteMultiplication{<:Chebyshev,<:PolynomialSpace},k::Integer,j::Integer) =
178179
M[k:k,j:j][1,1]
179180

180181

@@ -211,21 +212,21 @@ end
211212

212213
## Derivative
213214

214-
function Derivative(sp::Chebyshev{DD},order::Number) where {DD<:IntervalOrSegment}
215+
function Derivative(sp::Chebyshev{<:IntervalOrSegment}, order::Number)
215216
assert_integer(order)
216217
ConcreteDerivative(sp,order)
217218
end
218219

219220

220-
rangespace(D::ConcreteDerivative{Chebyshev{DD,RR}}) where {DD<:IntervalOrSegment,RR} =
221+
rangespace(D::ConcreteDerivative{<:Chebyshev{<:IntervalOrSegment}}) =
221222
Ultraspherical(D.order,domain(D))
222223

223-
bandwidths(D::ConcreteDerivative{Chebyshev{DD,RR}}) where {DD<:IntervalOrSegment,RR} = -D.order,D.order
224-
Base.stride(D::ConcreteDerivative{Chebyshev{DD,RR}}) where {DD<:IntervalOrSegment,RR} = D.order
224+
bandwidths(D::ConcreteDerivative{<:Chebyshev{<:IntervalOrSegment}}) = -D.order,D.order
225+
Base.stride(D::ConcreteDerivative{<:Chebyshev{<:IntervalOrSegment}}) = D.order
225226

226227
isdiag(D::ConcreteDerivative{<:Chebyshev{<:IntervalOrSegment}}) = false
227228

228-
function getindex(D::ConcreteDerivative{Chebyshev{DD,RR},K,T},k::Integer,j::Integer) where {DD<:IntervalOrSegment,RR,K,T}
229+
function getindex(D::ConcreteDerivative{<:Chebyshev{<:IntervalOrSegment},<:Any,T},k::Integer,j::Integer) where {T}
229230
m=D.order
230231
d=domain(D)
231232

@@ -237,7 +238,7 @@ function getindex(D::ConcreteDerivative{Chebyshev{DD,RR},K,T},k::Integer,j::Inte
237238
end
238239
end
239240

240-
linesum(f::Fun{Chebyshev{DD,RR}}) where {DD<:IntervalOrSegment,RR} =
241+
linesum(f::Fun{<:Chebyshev{<:IntervalOrSegment}}) =
241242
sum(setcanonicaldomain(f))*arclength(domain(f))/2
242243

243244

@@ -247,8 +248,8 @@ linesum(f::Fun{Chebyshev{DD,RR}}) where {DD<:IntervalOrSegment,RR} =
247248
for (Func,Len) in ((:DefiniteIntegral,:complexlength),(:DefiniteLineIntegral,:arclength))
248249
ConcFunc = Symbol(:Concrete, Func)
249250
@eval begin
250-
$Func(S::Chebyshev{D}) where {D<:IntervalOrSegment} = $ConcFunc(S)
251-
function getindex::$ConcFunc{Chebyshev{D,R},T},k::Integer) where {D<:IntervalOrSegment,R,T}
251+
$Func(S::Chebyshev{<:IntervalOrSegment}) = $ConcFunc(S)
252+
function getindex::$ConcFunc{<:Chebyshev{<:IntervalOrSegment},T}, k::Integer) where {T}
252253
d = domain(Σ)
253254
C = $Len(d)/2
254255

0 commit comments

Comments
 (0)