Skip to content

Commit

Permalink
coefa/coefb optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
wheeheee committed Dec 30, 2024
1 parent 878281a commit e3f404b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Filters/coefficients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ end

function shiftpoly(p::LaurentPolynomial{T,D}, i::Integer) where {T<:Number,D}
if !iszero(i)
return p * LaurentPolynomial{T,D}([one(T)], i)
p = copy(p)
p.order[] += i
return p
end
return p
end
Expand Down Expand Up @@ -191,8 +193,8 @@ function Base.:^(f::PolynomialRatio{D,T}, e::Integer) where {D,T}
end
end

coef_s(p::LaurentPolynomial) = p[end:-1:0]
coef_z(p::LaurentPolynomial) = p[0:-1:begin]
coef_s(p::LaurentPolynomial{T}) where T = copyto!(zeros(T, lastindex(p) + 1), 1, Iterators.reverse(p.coeffs))
coef_z(p::LaurentPolynomial{T}) where T = copyto!(zeros(T, 1 - firstindex(p)), 1 - lastindex(p), Iterators.reverse(p.coeffs))

"""
coefb(f::PolynomialRatio)
Expand Down

0 comments on commit e3f404b

Please sign in to comment.