Skip to content

Commit b299796

Browse files
authored
AbstractVector in piecewisespace jumplocation (#206)
1 parent fd30901 commit b299796

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

src/ApproxFunOrthogonalPolynomials.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ strictconvert(T::Type, x) = convert(T, x)::T
9090
convert_vector(v::AbstractVector) = convert(Vector, v)
9191
convert_vector(t::Tuple) = [t...]
9292

93+
convert_absvector(t::Tuple) = SVector(t)
94+
convert_absvector(v::AbstractVector) = v
95+
96+
convert_vector_or_svector(v::AbstractVector) = convert(Vector, v)
97+
convert_vector_or_svector(t::Tuple) = SVector(t)
98+
9399
const TupleOrVector{T} = Union{Tuple{T,Vararg{T}},AbstractVector{<:T}}
94100

95101
include("bary.jl")

src/Spaces/Chebyshev/ChebyshevOperators.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ function getindex(op::ConcreteEvaluation{<:Chebyshev{DD,RR},typeof(rightendpoint
117117
scal!(cst,ret)
118118
end
119119

120-
convert_vector_or_svector(v::AbstractVector) = convert(Vector, v)
121-
convert_vector_or_svector(t::Tuple) = SVector(t)
122-
123120
@inline function _Dirichlet_Chebyshev(S, order)
124121
order == 0 && return ConcreteDirichlet(S,
125122
ArraySpace(convert_vector_or_svector(

src/specialfunctions.jl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function jumplocations(f::Fun)
101101
end
102102

103103
# Return the locations of jump discontinuities
104+
_maybeview(dc::AbstractVector, inds...) = view(dc, inds)
104105
function jumplocations(f::Fun{S}) where{S<:Union{PiecewiseSpace,ContinuousSpace}}
105106
d = domain(f)
106107

@@ -111,13 +112,15 @@ function jumplocations(f::Fun{S}) where{S<:Union{PiecewiseSpace,ContinuousSpace}
111112
dtol=10eps(eltype(d))
112113
ftol=10eps(cfstype(f))
113114

114-
dc = components(d)
115-
fc = components(f)
115+
dc = convert_vector_or_svector(components(d))
116+
fc = convert_vector_or_svector(components(f))
116117

117-
isjump = isapprox.(leftendpoint.(dc[2:end]), rightendpoint.(dc[1:end-1]), rtol=dtol) .&
118-
.!isapprox.(first.(fc[2:end]), last.(fc[1:end-1]), rtol=ftol)
118+
isjump = isapprox.(leftendpoint.(@view dc[2:end]),
119+
rightendpoint.(@view dc[1:end-1]), rtol=dtol) .&
120+
.!isapprox.(first.(@view fc[2:end]),
121+
last.(@view fc[1:end-1]), rtol=ftol)
119122

120-
locs = rightendpoint.(dc[1:end-1])
123+
locs = rightendpoint.(@view dc[1:end-1])
121124
locs[isjump]
122125
end
123126

0 commit comments

Comments
 (0)