Skip to content

Commit 05977a0

Browse files
committed
clean up
1 parent 130741d commit 05977a0

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/common.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ In-place version of [`chop`](@ref)
210210
function chop!(p::AbstractPolynomial{T};
211211
rtol::Real = Base.rtoldefault(real(T)),
212212
atol::Real = 0,) where {T}
213-
isempty(p.coeffs) && return p
213+
isempty(values(p)) && return p
214214
tol = norm(p) * rtol + atol
215215
for i = lastindex(p):-1:0
216216
val = p[i]
@@ -264,7 +264,7 @@ end
264264
265265
Returns the complex conjugate of the polynomial
266266
"""
267-
LinearAlgebra.conj(p::P) where {P <: AbstractPolynomial} = _convert(p, conj(coeffs(p)))
267+
LinearAlgebra.conj(p::P) where {P <: AbstractPolynomial} = map(conj, p)
268268
LinearAlgebra.adjoint(p::P) where {P <: AbstractPolynomial} = map(adjoint, p)
269269
LinearAlgebra.transpose(p::AbstractPolynomial) = p
270270
LinearAlgebra.transpose!(p::AbstractPolynomial) = p
@@ -319,7 +319,7 @@ Base.any(pred, p::AbstractPolynomial) = any(pred, values(p))
319319

320320

321321
"""
322-
map(fn, p::AbstractPolynomial, args...v )
322+
map(fn, p::AbstractPolynomial, args...)
323323
324324
Transform coefficients of `p` by applying a function (or other callables) `fn` to each of them.
325325
@@ -430,7 +430,8 @@ Base.firstindex(p::AbstractPolynomial) = 0
430430
Base.lastindex(p::AbstractPolynomial) = length(p) - 1
431431
Base.eachindex(p::AbstractPolynomial) = 0:length(p) - 1
432432
Base.broadcastable(p::AbstractPolynomial) = Ref(p)
433-
Base.values(p::AbstractPolynomial) = coeffs(p)
433+
# like coeffs, though possibly only non-zero values (e.g. SparsePolynomial)
434+
Base.values(p::AbstractPolynomial) = coeffs(p)
434435

435436
# iteration
436437
# iteration occurs over the basis polynomials

src/polynomials/LaurentPolynomial.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,7 @@ julia> conj(p)(z) ≈ (conj ∘ p ∘ conj)(z)
327327
true
328328
```
329329
"""
330-
function LinearAlgebra.conj(p::P) where {P <: LaurentPolynomial}
331-
_convert(p, conj(coeffs(p)))
332-
end
330+
LinearAlgebra.conj(p::P) where {P <: LaurentPolynomial} = map(conj, p)
333331

334332

335333
"""

0 commit comments

Comments
 (0)