Skip to content

Commit

Permalink
explicit vector in ContinuousSpace integration (#204)
Browse files Browse the repository at this point in the history
* explicit vector in ContinuousSpace integration

* fix typo

* add components inference test

* limit inference test to recent Julia versions
  • Loading branch information
jishnub authored Mar 1, 2023
1 parent dfa4e91 commit aabc765
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/ApproxFunOrthogonalPolynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ bary(v::AbstractVector{Float64},d::IntervalOrSegmentDomain,x::Float64) = bary(v,

strictconvert(T::Type, x) = convert(T, x)::T

convert_vector(v::AbstractVector) = convert(Vector, v)
convert_vector(t::Tuple) = [t...]

include("bary.jl")


Expand Down
4 changes: 2 additions & 2 deletions src/Spaces/Ultraspherical/ContinuousSpace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function *(P::TransformPlan{T,<:ContinuousSpace,false},vals::AbstractVector{T})
end
end

components(S::ContinuousSpace) = map(ChebyshevDirichlet{1,1}, components(domain(S)))
components(S::ContinuousSpace) = [ChebyshevDirichlet{1,1}(s) for s in components(domain(S))]
canonicalspace(S::ContinuousSpace) = PiecewiseSpace(components(S))
convert(::Type{PiecewiseSpace}, S::ContinuousSpace) = canonicalspace(S)

Expand Down Expand Up @@ -429,7 +429,7 @@ function union_rule(A::ContinuousSpace{<:Real}, B::ContinuousSpace{<:Real})
end

function integrate(f::Fun{<:ContinuousSpace})
cs = cumsum.(components(f))
cs = [cumsum(x) for x in components(f)]
for k=1:length(cs)-1
cs[k+1] += last(cs[k])
end
Expand Down
5 changes: 5 additions & 0 deletions test/SpacesTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ using ApproxFunBaseTest: testbandedoperator, testraggedbelowoperator,
@test conversion_type(s,cs) == s

@test Fun(exp,d)(.1) exp(.1)

if VERSION >= v"1.8"
f = abs(Fun(sin,-5..5))
@inferred components(space(f))
end
end

@testset "Jacobi recurrence bug" begin
Expand Down

0 comments on commit aabc765

Please sign in to comment.