Skip to content

Commit bf93251

Browse files
authored
fix sparse multiplication (#515)
1 parent f4d90d9 commit bf93251

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/common.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ copy_with_eltype(::Type{T}, p::P) where {T, S, Y, P <:AbstractPolynomial{S,Y}} =
546546
#copy_with_eltype(::Type{T}, p::P) where {T, S, X, P<:AbstractPolynomial{S,X}} =
547547
# copy_with_eltype(Val(T), Val(X), p)
548548

549-
Base.iszero(p::AbstractPolynomial) = all(iszero, p)
549+
Base.iszero(p::AbstractPolynomial) = all(iszero, values(p))
550550

551551

552552
# See discussions in https://github.com/JuliaMath/Polynomials.jl/issues/258
@@ -622,7 +622,7 @@ hasnan(x) = isnan(x)
622622
623623
Is the polynomial `p` a constant.
624624
"""
625-
isconstant(p::AbstractPolynomial) = degree(p) <= 0
625+
isconstant(p::AbstractPolynomial) = degree(p) <= 0 && iszero(firstindex(p))
626626

627627
"""
628628
coeffs(::AbstractPolynomial)
@@ -1152,7 +1152,7 @@ function Base.:(==)(p1::AbstractPolynomial, p2::AbstractPolynomial)
11521152
check_same_variable(p1, p2) || return false
11531153
==(promote(p1,p2)...)
11541154
end
1155-
Base.:(==)(p::AbstractPolynomial, n::Number) = degree(p) <= 0 && constantterm(p) == n
1155+
Base.:(==)(p::AbstractPolynomial, n::Number) = isconstant(p) && constantterm(p) == n
11561156
Base.:(==)(n::Number, p::AbstractPolynomial) = p == n
11571157

11581158
function Base.isapprox(p1::AbstractPolynomial, p2::AbstractPolynomial; kwargs...)

src/polynomials/standard-basis.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Base.:+(p::P, c::T) where {T, X, P<:StandardBasisPolynomial{T, X}} = p + ⟒(P)(
8888
## default multiplication between same type.
8989
## subtypes might relax to match T,S to avoid one conversion
9090
function Base.:*(p::P, q::P) where {T,X, P<:StandardBasisPolynomial{T,X}}
91-
cs = (P, coeffs(p), coeffs(q))
91+
cs = (P, p.coeffs, q.coeffs)
9292
P(cs)
9393
end
9494

0 commit comments

Comments
 (0)