Skip to content

type-stability in Fun(identity, ::Jacobi) #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ name: CI
on:
- push
- pull_request

concurrency:
group: build-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ApproxFunOrthogonalPolynomials"
uuid = "b70543e2-c0d9-56b8-a290-0d4d6d4de211"
version = "0.4.11"
version = "0.4.12"

[deps]
AbstractFFTs = "621f4979-c628-5d54-868e-fcf4e3e8185c"
Expand Down
17 changes: 13 additions & 4 deletions src/Spaces/Jacobi/Jacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,20 @@ one(S::Jacobi) = Fun(S,fill(one(Float64),1))
zeros(::Type{T},S::Jacobi) where {T<:Number} = Fun(S,zeros(T,1))
zeros(S::Jacobi) = Fun(S,zeros(prectype(S),1))

Fun(::typeof(identity), J::Jacobi{<:ChebyshevInterval}) =
Fun(J,[(J.b-J.a)/(2+J.a+J.b),2.0/(2+J.a+J.b)])
_Fun(J::Jacobi, ::ChebyshevInterval) = Fun(J, [(J.b-J.a)/(2+J.a+J.b),2.0/(2+J.a+J.b)])
_unscaledcoeff(J) = [2.0*(J.b + 1)/(2+J.a+J.b), 2.0/(2+J.a+J.b)]
function _Fun(J::Jacobi, d::Interval)
scale = complexlength(d)/2
coeffs = _unscaledcoeff(J) .* scale
coeffs[1] += leftendpoint(d)
Fun(J, coeffs)
end
function _Fun(J::Jacobi, d)
complexlength(d)/2*(Fun(J,_unscaledcoeff(J)))+leftendpoint(d)
end

function Fun(::typeof(identity), J::Jacobi)
d=domain(J)
complexlength(d)/2*(Fun(J,[2.0*(J.b + 1)/(2+J.a+J.b),2.0/(2+J.a+J.b)]))+leftendpoint(d)
_Fun(J, domain(J))
end


Expand Down
16 changes: 16 additions & 0 deletions test/JacobiTest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,29 @@ import ApproxFunOrthogonalPolynomials: jacobip
@time testbandedoperator(D)
end

@testset "identity Fun for interval domains" begin
for d in [1..2, -1..1, 10..20], s in Any[Legendre(d), Jacobi(1, 2, d), Jacobi(1.2, 2.3, d)]
f = Fun(identity, s)
g = Fun(x->x, s)
@test coefficients(f) ≈ coefficients(g)
end
f = Fun(identity, Legendre(-1..1))
g = Fun(identity, Legendre())
@test coefficients(f) ≈ coefficients(g)
@test f(0.2) ≈ g(0.2) ≈ 0.2
end

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

@test (x*f)(.1) ≈ .1exp(.1)

x=Fun(identity,Jacobi(0.,0., 1..2))
f=Fun(exp,Jacobi(0.,0., 1..2))

@test (x*f)(1.1) ≈ 1.1exp(1.1)

x=Fun(identity,Jacobi(12.324,0.123))
f=Fun(exp,Jacobi(0.,0.))

Expand Down