Skip to content

Commit 5a42cb2

Browse files
authored
revert moving integral over domain (#164)
* revert moving integral over domain * Add tests
1 parent 0b7ecbb commit 5a42cb2

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ApproxFunOrthogonalPolynomials"
22
uuid = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
3-
version = "0.5.20"
3+
version = "0.5.21"
44

55
[deps]
66
ApproxFunBase = "fbd15aa5-315a-5a7d-a8a4-24992e37be05"

src/Spaces/IntervalSpace.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Space(d::IntervalOrSegment) = Chebyshev(d)
22
Space(d::FullSpace{<:Real}) = Chebyshev(Line())
33

4+
# TODO: mode these functions to ApproxFunBase
5+
# Currently, Space(d::Interval) isn't type-stable, so the spaces are
6+
# explicitly listed in these calls.
47
Fun(::typeof(identity), d::IntervalOrSegment{<:Number}) =
58
Fun(Chebyshev(d), [mean(d), complexlength(d)/2])
9+
10+
# the default domain space is higher to avoid negative ultraspherical spaces
11+
Integral(d::IntervalOrSegment,n::Integer) = Integral(Ultraspherical(1,d), n)

src/Spaces/Ultraspherical/UltrasphericalOperators.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ function Derivative(sp::Ultraspherical{LT,DD}, m::Number) where {LT,DD<:Interval
5858
assert_integer(m)
5959
ConcreteDerivative(sp,m)
6060
end
61-
function Integral(sp::Ultraspherical{LT,DD}, m::Number) where {LT,DD<:IntervalOrSegment}
61+
function Integral(sp::Ultraspherical{<:Any,<:IntervalOrSegment}, m::Number)
6262
assert_integer(m)
6363
λ = order(sp)
6464
if m λ
6565
ConcreteIntegral(sp,m)
6666
else # Convert up
67-
nsp = Ultraspherical(λ+1,domain(sp))
68-
IntegralWrapper(Integral(nsp,m)*Conversion(sp,nsp),m)
67+
nsp = Ultraspherical(m,domain(sp))
68+
IntegralWrapper(ConcreteIntegral(nsp,m)*Conversion(sp,nsp),m)
6969
end
7070
end
7171

@@ -248,6 +248,7 @@ end
248248

249249

250250
function coefficients(g::AbstractVector,sp::Ultraspherical{Int},C::Chebyshev)
251+
domainscompatible(C,sp) || throw(ArgumentError("domains don't match: $(domain(sp)) and $(domain(C))"))
251252
if order(sp) == 1
252253
ultraiconversion(g)
253254
else
@@ -256,6 +257,7 @@ function coefficients(g::AbstractVector,sp::Ultraspherical{Int},C::Chebyshev)
256257
end
257258
end
258259
function coefficients(g::AbstractVector,C::Chebyshev,sp::Ultraspherical)
260+
domainscompatible(C,sp) || throw(ArgumentError("domains don't match: $(domain(C)) and $(domain(sp))"))
259261
if order(sp) == 1
260262
ultraconversion(g)
261263
else

test/ChebyshevTest.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ using ApproxFunOrthogonalPolynomials: forwardrecurrence
3939
@test y == 2Fun()
4040
end
4141

42+
@testset "inference in Space(::Interval)" begin
43+
S = @inferred Space(0..1)
44+
f = Fun(S)
45+
g = Fun(domain(S))
46+
@test f(0.2) g(0.2) 0.2
47+
48+
S = Space(0.0..1.0)
49+
f = Fun(S)
50+
g = Fun(domain(S))
51+
@test f(0.2) g(0.2) 0.2
52+
end
53+
4254
@testset "Algebra" begin
4355
ef = @inferred Fun(exp,ChebyshevInterval())
4456
@test ef == @inferred -(-ef)

test/UltrasphericalTest.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,15 @@ using ApproxFunOrthogonalPolynomials: jacobip
165165
end
166166
end
167167
end
168+
169+
@testset "Integral" begin
170+
d = 0..1
171+
A = @inferred Integral(0..1)
172+
x = Derivative() * A * Fun(d)
173+
@test x(0.2) 0.2
174+
d = 0.0..1.0
175+
A = @inferred Integral(d)
176+
x = Derivative() * A * Fun(d)
177+
@test x(0.2) 0.2
178+
end
168179
end

0 commit comments

Comments
 (0)