Skip to content

Commit 0f2ea17

Browse files
authored
setdomain for NormalizedPolynomialSpace (#74)
* setdomain for NormalizedPolynomialSpace * pass domsinspace to jacobi calculus wrappers * Add tests
1 parent 6ecd066 commit 0f2ea17

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
2121

2222
[compat]
2323
AbstractFFTs = "0.5, 1"
24-
ApproxFunBase = "0.5, 0.6"
24+
ApproxFunBase = "0.6.14"
2525
BandedMatrices = "0.16, 0.17"
2626
BlockArrays = "0.14, 0.15, 0.16"
2727
BlockBandedMatrices = "0.10, 0.11"

src/Spaces/Jacobi/JacobiOperators.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ end
9696

9797
## Derivative
9898

99-
Derivative(J::Jacobi,k::Integer)=k==1 ? ConcreteDerivative(J,1) : DerivativeWrapper(TimesOperator(Derivative(Jacobi(J.b+1,J.a+1,J.domain),k-1),ConcreteDerivative(J,1)),k)
99+
function Derivative(J::Jacobi,k::Integer)
100+
k==1 ? ConcreteDerivative(J,1) :
101+
DerivativeWrapper(
102+
TimesOperator(
103+
Derivative(Jacobi(J.b+1,J.a+1,J.domain),k-1),ConcreteDerivative(J,1)),
104+
J, k)
105+
end
100106

101107

102108

@@ -114,14 +120,14 @@ getindex(T::ConcreteDerivative{J},k::Integer,j::Integer) where {J<:Jacobi} =
114120
function Integral(J::Jacobi,k::Integer)
115121
if k > 1
116122
Q=Integral(J,1)
117-
IntegralWrapper(TimesOperator(Integral(rangespace(Q),k-1),Q),k)
123+
IntegralWrapper(TimesOperator(Integral(rangespace(Q),k-1),Q),J,k)
118124
elseif J.a > 0 && J.b > 0 # we have a simple definition
119125
ConcreteIntegral(J,1)
120126
else # convert and then integrate
121127
sp=Jacobi(J.b+1,J.a+1,domain(J))
122128
C=Conversion(J,sp)
123129
Q=Integral(sp,1)
124-
IntegralWrapper(TimesOperator(Q,C),1)
130+
IntegralWrapper(TimesOperator(Q,C),J,1)
125131
end
126132
end
127133

src/Spaces/PolynomialSpace.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ end
346346

347347
domain(S::NormalizedPolynomialSpace) = domain(S.space)
348348
canonicalspace(S::NormalizedPolynomialSpace) = S.space
349+
setdomain(NS::NormalizedPolynomialSpace, d::Domain) = NormalizedPolynomialSpace(setdomain(canonicalspace(NS), d))
349350

350351
NormalizedPolynomialSpace(space::PolynomialSpace{D,R}) where {D,R} = NormalizedPolynomialSpace{typeof(space),D,R}(space)
351352

test/ChebyshevTest.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ import ApproxFunOrthogonalPolynomials: forwardrecurrence
102102
r=rand(100) .+ 1
103103
@test maximum(abs,ef.(r)-exp.(r))<400eps()
104104
@test maximum(abs,ecf.(r).-cos.(r).*exp.(r))<100eps()
105+
106+
@testset "setdomain" begin
107+
@test setdomain(NormalizedChebyshev(0..1), 1..2) == NormalizedChebyshev(1..2)
108+
end
105109
end
106110

107111
@testset "Other interval" begin
@@ -237,5 +241,18 @@ import ApproxFunOrthogonalPolynomials: forwardrecurrence
237241
end
238242
end
239243
end
244+
245+
@testset "derivative in normalized space" begin
246+
s1 = NormalizedChebyshev(-1..1)
247+
s2 = NormalizedChebyshev()
248+
@test s1 == s2
249+
D1 = Derivative(s1)
250+
D2 = Derivative(s2)
251+
f = x -> 3x^2 + 5x
252+
f1 = Fun(f, s1)
253+
f2 = Fun(f, s2)
254+
@test f1 == f2
255+
@test D1 * f1 == D2 * f2
256+
end
240257
end
241258
end

test/JacobiTest.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ import ApproxFunOrthogonalPolynomials: jacobip
6060
@testset "Derivative" begin
6161
D=Derivative(Jacobi(0.,1.,Segment(1.,0.)))
6262
@time testbandedoperator(D)
63+
64+
@testset for S1 in Any[Jacobi(0,0),
65+
Jacobi(0,0,1..2), Jacobi(2,2,1..2), Jacobi(0.5,2.5,1..2)],
66+
S in Any[S1, NormalizedPolynomialSpace(S1)]
67+
f = Fun(x->x^3 + 4x^2 + 2x + 6, S)
68+
@test Derivative(S) * f Fun(x->3x^2 + 8x + 2, S)
69+
@test Derivative(S)^2 * f Fun(x->6x+8, S)
70+
@test Derivative(S)^3 * f Fun(x->6, S)
71+
@test Derivative(S)^4 * f zeros(S)
72+
end
6373
end
6474

6575
@testset "identity Fun for interval domains" begin

0 commit comments

Comments
 (0)