Skip to content

Commit

Permalink
WIP: coeffs as before
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani committed Jul 27, 2023
1 parent 8b3bfb4 commit 266bf47
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/abstract-polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,15 @@ copy_with_eltype(::Type{T}, ::Val{X}, p::P) where {B,T, X, S, Y, P <:AbstractUni

# XXX something feels off here...
# coefficients
# return dense coefficients (vector or tuple)
# if laurent type and of lowest degree (after chopping) 0 or greater,
# *or* not of laurent type return p_0, ..., p_n (padded out on left)
# if laurent type trim, return coeffs
# if not laurent, return all
# if laurent type and lowest degree < 0 (after chopping) return p.coeffs (user needs to get offset)
# return Val(::Bool) to indicate if laurent type. This should compile away, unlike the check
laurenttype(P::Type{<:AbstractPolynomial}) = Val(minimumexponent(P) < 0)

Check warning on line 134 in src/abstract-polynomial.jl

View check run for this annotation

Codecov / codecov/patch

src/abstract-polynomial.jl#L134

Added line #L134 was not covered by tests

coeffs(p::P) where {P <: AbstractUnivariatePolynomial} = coeffs(laurenttype(P), p)
function coeffs(laurent::Val{true}, p)
q = chop(p)
firstindex(q) 0 && return [q[i] for i 0:lastindex(q)]
return q.coeffs
p.coeffs
end
function coeffs(laurent::Val{false}, p)
firstindex(p) == 0 && return p.coeffs
Expand Down

0 comments on commit 266bf47

Please sign in to comment.