Skip to content

Commit

Permalink
Simplify a few expressions (#205)
Browse files Browse the repository at this point in the history
* Update chebyshev.jl

* Update chebyshev.jl
  • Loading branch information
putianyi889 authored Sep 1, 2024
1 parent 5e200d9 commit 1ed1f7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/classical/chebyshev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ weightedgrammatrix(::ChebyshevU{V}) where V = Diagonal(Fill(convert(V,π)/2,∞)
@simplify *(A::QuasiAdjoint{<:Any,<:Weighted{<:Any,<:ChebyshevU}}, B::ChebyshevU) = weightedgrammatrix(ChebyshevU{promote_type(eltype(A),eltype(B))}())

function grammatrix(A::ChebyshevT{T}) where T
f = (k,j) -> isodd(j-k) ? zero(T) : -(((1 + (-1)^(j + k))*(-1 + j^2 + k^2))/(j^4 + (-1 + k^2)^2 - 2j^2*(1 + k^2)))
f = (k,j) -> isodd(j-k) ? zero(T) : -(T(2)*(-1 + j^2 + k^2))/((-1 + j - k)*(-1 + j + k)*(1 + j - k)*(1 + j + k))
BroadcastMatrix{T}(f, 0:∞, (0:∞)')
end

Expand All @@ -170,13 +170,13 @@ end

@simplify function *(A::QuasiAdjoint{<:Any,<:ChebyshevT}, B::ChebyshevU)
T = promote_type(eltype(A), eltype(B))
f = (k,j) -> isodd(j-k) ? zero(T) : ((one(T) + (-1)^(j + k))*(1 + j))/((1 + j - k)*(1 + j + k))
f = (k,j) -> isodd(j-k) ? zero(T) : (T(2)*(1 + j))/((1 + j - k)*(1 + j + k))
BroadcastMatrix{T}(f, 0:∞, (0:∞)')
end


function grammatrix(A::Weighted{T,<:ChebyshevU}) where T
f = (k,j) -> isodd(j-k) ? zero(T) : -((2*(one(T) + (-1)^(j + k))*(1 + j)*(1 + k))/((-1 + j - k)*(1 + j - k)*(1 + j + k)*(3 + j + k)))
f = (k,j) -> isodd(j-k) ? zero(T) : -((T(4)*(1 + j)*(1 + k))/((-1 + j - k)*(1 + j - k)*(1 + j + k)*(3 + j + k)))
BroadcastMatrix{T}(f, 0:∞, (0:∞)')
end

Expand Down

0 comments on commit 1ed1f7e

Please sign in to comment.