Skip to content

rename isapproxinteger_addhalf to isapproxhalfoddinteger #257

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 1 commit into from
Jun 7, 2023
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
10 changes: 5 additions & 5 deletions src/ApproxFunOrthogonalPolynomials.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ isequalhalf(x) = x == _onehalf(x)
isequalhalf(@nospecialize(a::StaticInt)) = false
isequalhalf(x::Integer) = false

isapproxinteger_addhalf(a) = !isapproxinteger(a) && isapproxinteger(a+_onehalf(a))
isapproxinteger_addhalf(a::HalfOddInteger) = true
isapproxinteger_addhalf(@nospecialize(a::StaticInt)) = false
function isapproxinteger_addhalf(a::StaticFloat64)
isapproxhalfoddinteger(a) = !isapproxinteger(a) && isapproxinteger(a+_onehalf(a))
isapproxhalfoddinteger(a::HalfOddInteger) = true
isapproxhalfoddinteger(@nospecialize(a::StaticInt)) = false
function isapproxhalfoddinteger(a::StaticFloat64)
x = mod(a, static(1))
x == _onehalf(x) || dynamic(x) ≈ 0.5
end
isapproxinteger_addhalf(::Integer) = false
isapproxhalfoddinteger(::Integer) = false

include("bary.jl")

Expand Down
2 changes: 1 addition & 1 deletion src/Spaces/Jacobi/Jacobi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ compare_orders((Aa, Ba)::NTuple{2,Number}, (Ab, Bb)::NTuple{2,Number}) = compare
spacescompatible(a::Jacobi, b::Jacobi) = compare_orders((a.a, b.a), (a.b, b.b)) && domainscompatible(a,b)

function canonicalspace(S::Jacobi)
if isapproxinteger_addhalf(S.a) && isapproxinteger_addhalf(S.b)
if isapproxhalfoddinteger(S.a) && isapproxhalfoddinteger(S.b)
Chebyshev(domain(S))
else
# return space with parameters in (-1,0.]
Expand Down
6 changes: 3 additions & 3 deletions src/Spaces/Jacobi/JacobiOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function Conversion(L::Jacobi,M::Jacobi)
else
return _conversion_shiftordersbyone(L, M)
end
elseif isapproxinteger_addhalf(L.a - M.a) && isapproxinteger_addhalf(L.b - M.b)
elseif isapproxhalfoddinteger(L.a - M.a) && isapproxhalfoddinteger(L.b - M.b)
if L.a ≈ L.b && M.a ≈ M.b && isapproxminhalf(M.a)
return Conversion(L,Ultraspherical(L),Chebyshev(dm),M)
elseif L.a ≈ L.b && isapproxminhalf(L.a) && M.a ≈ M.b && M.a >= L.a
Expand Down Expand Up @@ -485,7 +485,7 @@ for (OPrule,OP) in ((:conversion_rule,:conversion_type), (:maxspace_rule,:maxspa
if isapproxminhalf(B.a) && isapproxminhalf(B.b)
# the spaces are the same
A
elseif isapproxinteger_addhalf(B.a) && isapproxinteger_addhalf(B.b)
elseif isapproxhalfoddinteger(B.a) && isapproxhalfoddinteger(B.b)
$OP(Jacobi(A),B)
else
NoSpace()
Expand All @@ -496,7 +496,7 @@ for (OPrule,OP) in ((:conversion_rule,:conversion_type), (:maxspace_rule,:maxspa
if isapproxminhalf(B.a - m) && isapproxminhalf(B.b - m)
# the spaces are the same
A
elseif isapproxinteger_addhalf(B.a) && isapproxinteger_addhalf(B.b)
elseif isapproxhalfoddinteger(B.a) && isapproxhalfoddinteger(B.b)
$OP(Jacobi(A),B)
else
NoSpace()
Expand Down
4 changes: 2 additions & 2 deletions src/Spaces/Ultraspherical/UltrasphericalOperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function Conversion(A::Chebyshev, B::Ultraspherical)
dB = domain(B)
if isequalhalf(mB) || mB == 1
return ConcreteConversion(A,B)
elseif (isinteger(mB) || isapproxinteger_addhalf(mB)) && mB > 0
elseif (isinteger(mB) || isapproxhalfoddinteger(mB)) && mB > 0
r = mB:-1:(isinteger(mB) ? 2 : 1)
v = [ConcreteConversion(Ultraspherical(i-1, d), Ultraspherical(i,d)) for i in r]
U = domainspace(last(v))
Expand Down Expand Up @@ -173,7 +173,7 @@ function Conversion(A::Ultraspherical,B::Ultraspherical)
d=domain(A)
if b==a
return ConversionWrapper(Operator(I,A))
elseif isapproxinteger(b-a) || isapproxinteger_addhalf(b-a)
elseif isapproxinteger(b-a) || isapproxhalfoddinteger(b-a)
if -1 ≤ b-a ≤ 1 && (a,b) ≠ (2,1)
return ConcreteConversion(A,B)
elseif b-a > 1
Expand Down
12 changes: 6 additions & 6 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module ApproxFunOrthogonalPolynomials_Runtests

using ApproxFunOrthogonalPolynomials
using ApproxFunOrthogonalPolynomials: isapproxminhalf, isequalminhalf, isequalhalf, isapproxinteger_addhalf
using ApproxFunOrthogonalPolynomials: isapproxminhalf, isequalminhalf, isequalhalf, isapproxhalfoddinteger
using LinearAlgebra
using Test
using Aqua
Expand Down Expand Up @@ -46,11 +46,11 @@ include("testutils.jl")
@test !isequalhalf(1)
@test !isequalhalf(static(1))

@test isapproxinteger_addhalf(0.5)
@test isapproxinteger_addhalf(static(0.5))
@test isapproxinteger_addhalf(half(Odd(1)))
@test !isapproxinteger_addhalf(1)
@test !isapproxinteger_addhalf(static(1))
@test isapproxhalfoddinteger(0.5)
@test isapproxhalfoddinteger(static(0.5))
@test isapproxhalfoddinteger(half(Odd(1)))
@test !isapproxhalfoddinteger(1)
@test !isapproxhalfoddinteger(static(1))

@test ApproxFunOrthogonalPolynomials._minonehalf(2) == -0.5
@test ApproxFunOrthogonalPolynomials._onehalf(2) == 0.5
Expand Down