Skip to content

Commit b21e58f

Browse files
authored
Identity Fun in normalized Polynomial spaces (#91)
* Fun in normalized polynomial spaces * bump version to v0.4.17 * Add tests for Ultraspherical * fix range construction * actually add identity test * add approx tolerances * avoid shadowing variables
1 parent b08b5aa commit b21e58f

File tree

6 files changed

+68
-2
lines changed

6 files changed

+68
-2
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717
version:
1818
- '1.5'
1919
- '1'
20-
- '^1.8.0-0'
2120
os:
2221
- ubuntu-latest
2322
- macOS-latest

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.4.16"
3+
version = "0.4.17"
44

55
[deps]
66
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"

src/Spaces/PolynomialSpace.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,15 @@ function Conversion(L::S, M::NormalizedPolynomialSpace{S}) where S<:PolynomialSp
367367
end
368368
end
369369

370+
function Fun(::typeof(identity), S::NormalizedPolynomialSpace)
371+
C = canonicalspace(S)
372+
f = Fun(identity, C)
373+
coeffs = coefficients(f)
374+
CS = ConcreteConversion(C, S)
375+
ApproxFunBase.mul_coefficients!(CS, coeffs)
376+
Fun(S, coeffs)
377+
end
378+
370379
bandwidths(C::ConcreteConversion{NormalizedPolynomialSpace{S,D,R},S}) where {S,D,R} = (0, 0)
371380
bandwidths(C::ConcreteConversion{S,NormalizedPolynomialSpace{S,D,R}}) where {S,D,R} = (0, 0)
372381

test/ChebyshevTest.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,22 @@ import ApproxFunOrthogonalPolynomials: forwardrecurrence
220220
end
221221
end
222222
end
223+
224+
@testset "Normalized space" begin
225+
for f in Any[x -> 3x^3 + 5x^2 + 2, x->x, identity]
226+
for dt in Any[(), (0..1,)]
227+
S = Chebyshev(dt...)
228+
NS = NormalizedPolynomialSpace(S)
229+
230+
fS = Fun(f, S)
231+
fNS = Fun(f, NS)
232+
@test space(fNS) == NS
233+
d = domain(fS)
234+
r = range(leftendpoint(d), rightendpoint(d), length=10)
235+
for x in r
236+
@test fS(x) fNS(x) rtol=1e-7 atol=1e-14
237+
end
238+
end
239+
end
240+
end
223241
end

test/JacobiTest.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,4 +297,24 @@ import ApproxFunOrthogonalPolynomials: jacobip
297297
testbandedbelowoperator(C)
298298
@test norm(C*Fun(exp,Ultraspherical(1))-Fun(exp,Jacobi(0,0))) < 100eps()
299299
end
300+
301+
@testset "Normalized space" begin
302+
for f in Any[x -> 3x^3 + 5x^2 + 2, x->x, identity]
303+
for dt in Any[(), (0..1,)],
304+
S in Any[Jacobi(1,1,dt...),
305+
Jacobi(0.5,1.5,dt...),
306+
Legendre(dt...), ]
307+
308+
NS = NormalizedPolynomialSpace(S)
309+
fS = Fun(f, S)
310+
fNS = Fun(f, NS)
311+
@test space(fNS) == NS
312+
d = domain(fS)
313+
r = range(leftendpoint(d), rightendpoint(d), length=10)
314+
for x in r
315+
@test fS(x) fNS(x) rtol=1e-7 atol=1e-14
316+
end
317+
end
318+
end
319+
end
300320
end

test/UltrasphericalTest.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,24 @@ import ApproxFunOrthogonalPolynomials: jacobip
2929
ApproxFunBase.ConversionWrapper{TimesOperator{Float64, Tuple{Int64, Int64}}, Float64}};
3030
@inferred Tallowed Conversion(Ultraspherical(1), Ultraspherical(2));
3131
end
32+
33+
@testset "Normalized space" begin
34+
for f in Any[x -> 3x^3 + 5x^2 + 2, x->x, identity]
35+
for dt in Any[(), (0..1,)],
36+
S in Any[Ultraspherical(1, dt...),
37+
Ultraspherical(0.5,dt...),
38+
Ultraspherical(3, dt...)]
39+
40+
NS = NormalizedPolynomialSpace(S)
41+
fS = Fun(f, S)
42+
fNS = Fun(f, NS)
43+
@test space(fNS) == NS
44+
d = domain(fS)
45+
r = range(leftendpoint(d), rightendpoint(d), length=10)
46+
for x in r
47+
@test fS(x) fNS(x) rtol=1e-7 atol=1e-14
48+
end
49+
end
50+
end
51+
end
3252
end

0 commit comments

Comments
 (0)