From 36f091c5c6ccbd5642e3be8f4605b42334560808 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 12 Jun 2024 16:21:38 +0200 Subject: [PATCH] Remove term iterator behavior of polynomial --- src/mult.jl | 4 ++-- src/operators.jl | 2 +- src/poly.jl | 8 -------- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/mult.jl b/src/mult.jl index 929a22a..8521190 100644 --- a/src/mult.jl +++ b/src/mult.jl @@ -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 diff --git a/src/operators.jl b/src/operators.jl index aa14e65..539d1bc 100644 --- a/src/operators.jl +++ b/src/operators.jl @@ -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}, diff --git a/src/poly.jl b/src/poly.jl index 0c8f727..3195c56 100644 --- a/src/poly.jl +++ b/src/poly.jl @@ -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