Skip to content

Commit 81e2851

Browse files
authored
type-stability in Fun(identity, ::Jacobi) (#82)
* type-stability in Fun(identity, ::Jacobi) * split default coeffs to separate function * Fun for Interval * scale coefficients correctly * add tests against Legendre() * version bump to v0.4.12
1 parent 7cba684 commit 81e2851

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: CI
22
on:
33
- push
44
- pull_request
5+
6+
concurrency:
7+
group: build-${{ github.event.pull_request.number || github.ref }}
8+
cancel-in-progress: true
9+
510
jobs:
611
test:
712
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}

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.11"
3+
version = "0.4.12"
44

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

src/Spaces/Jacobi/Jacobi.jl

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,20 @@ one(S::Jacobi) = Fun(S,fill(one(Float64),1))
134134
zeros(::Type{T},S::Jacobi) where {T<:Number} = Fun(S,zeros(T,1))
135135
zeros(S::Jacobi) = Fun(S,zeros(prectype(S),1))
136136

137-
Fun(::typeof(identity), J::Jacobi{<:ChebyshevInterval}) =
138-
Fun(J,[(J.b-J.a)/(2+J.a+J.b),2.0/(2+J.a+J.b)])
137+
_Fun(J::Jacobi, ::ChebyshevInterval) = Fun(J, [(J.b-J.a)/(2+J.a+J.b),2.0/(2+J.a+J.b)])
138+
_unscaledcoeff(J) = [2.0*(J.b + 1)/(2+J.a+J.b), 2.0/(2+J.a+J.b)]
139+
function _Fun(J::Jacobi, d::Interval)
140+
scale = complexlength(d)/2
141+
coeffs = _unscaledcoeff(J) .* scale
142+
coeffs[1] += leftendpoint(d)
143+
Fun(J, coeffs)
144+
end
145+
function _Fun(J::Jacobi, d)
146+
complexlength(d)/2*(Fun(J,_unscaledcoeff(J)))+leftendpoint(d)
147+
end
148+
139149
function Fun(::typeof(identity), J::Jacobi)
140-
d=domain(J)
141-
complexlength(d)/2*(Fun(J,[2.0*(J.b + 1)/(2+J.a+J.b),2.0/(2+J.a+J.b)]))+leftendpoint(d)
150+
_Fun(J, domain(J))
142151
end
143152

144153

test/JacobiTest.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,29 @@ import ApproxFunOrthogonalPolynomials: jacobip
5555
@time testbandedoperator(D)
5656
end
5757

58+
@testset "identity Fun for interval domains" begin
59+
for d in [1..2, -1..1, 10..20], s in Any[Legendre(d), Jacobi(1, 2, d), Jacobi(1.2, 2.3, d)]
60+
f = Fun(identity, s)
61+
g = Fun(x->x, s)
62+
@test coefficients(f) coefficients(g)
63+
end
64+
f = Fun(identity, Legendre(-1..1))
65+
g = Fun(identity, Legendre())
66+
@test coefficients(f) coefficients(g)
67+
@test f(0.2) g(0.2) 0.2
68+
end
5869

5970
@testset "Jacobi multiplication" begin
6071
x=Fun(identity,Jacobi(0.,0.))
6172
f=Fun(exp,Jacobi(0.,0.))
6273

6374
@test (x*f)(.1) .1exp(.1)
6475

76+
x=Fun(identity,Jacobi(0.,0., 1..2))
77+
f=Fun(exp,Jacobi(0.,0., 1..2))
78+
79+
@test (x*f)(1.1) 1.1exp(1.1)
80+
6581
x=Fun(identity,Jacobi(12.324,0.123))
6682
f=Fun(exp,Jacobi(0.,0.))
6783

0 commit comments

Comments
 (0)