Skip to content

Commit

Permalink
Remove term iterator behavior of polynomial
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 12, 2024
1 parent 469c47c commit 36f091c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/mult.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ function _mul(
Z = Vector{Vector{Int}}(undef, N)
a = Vector{T}(undef, N)
i = 0
for u in p
for v in q
for u in MP.terms(p)
for v in MP.terms(q)
if samevars
z = MP.monomial(u).z + MP.monomial(v).z
else
Expand Down
2 changes: 1 addition & 1 deletion src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ end
Base.:(+)(x::DMonomialLike, y::DMonomialLike) = MP.term(x) + MP.term(y)
Base.:(-)(x::DMonomialLike, y::DMonomialLike) = MP.term(x) - MP.term(y)

_getindex(p::Polynomial, i::Int) = p[i]
_getindex(p::Polynomial, i::Int) = MP.terms(p)[i]
_getindex(t::_Term, ::Int) = t
function _plusorminus_to!(
a::Vector{U},
Expand Down
8 changes: 0 additions & 8 deletions src/poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ end
#Base.convert(::Type{term_type{V,M}}, p::TermContainer{V,M}) where {V,M} = p
#Base.convert(::Type{term_type{V,M,T}}, p::TermContainer{V,M,T}) where {V,M,T} = p

Base.length(p::Polynomial) = length(p.a)
Base.isempty(p::Polynomial) = isempty(p.a)
Base.iterate(p::Polynomial) = isempty(p) ? nothing : (p[1], 1)
function Base.iterate(p::Polynomial, state::Int)
return state < length(p) ? (p[state+1], state + 1) : nothing
end
#eltype(::Type{Polynomial{V,M,T}}) where {V,M,T} = T
Base.getindex(p::Polynomial, I::Int) = MP.term(p.a[I[1]], p.x[I[1]])

#Base.transpose(p::Polynomial) = Polynomial(map(transpose, p.a), p.x) # FIXME invalid age range update

Expand Down

0 comments on commit 36f091c

Please sign in to comment.