From f491908e6251c811939e7fe44e1562a6e5683404 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 12 Mar 2024 17:08:19 +0100 Subject: [PATCH] Fixes --- src/chebyshev.jl | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/chebyshev.jl b/src/chebyshev.jl index 452e9cd..809b589 100644 --- a/src/chebyshev.jl +++ b/src/chebyshev.jl @@ -3,17 +3,29 @@ Base.keytype(p::MP.AbstractPolynomial) = MP.monomial_type(p) Base.valtype(p::MP.AbstractPolynomial) = MP.coefficient_type(p) #Base.keys(p::MP.AbstractPolynomial) = MP.monomials(p) Base.pairs(p::MP.AbstractPolynomial) = MP.terms(p) -function Base.similar(p::PT, ::Type{T}) where {PT<:MP._APL,T} - return convert(MP.similar_type(PT, T), copy(p)) -end -function Base.indexed_iterate(t::MP.Term, i::Int) - if i == 1 - return MP.coefficient(t) +function Base.similar(p::PT, ::Type{T}) where {PT<:MP.AbstractPolynomial,T} + return convert(MP.similar_type(PT, T), copy(p)) # Missing the `copy` in MP +end +Base.iterate(t::MP.Term) = iterate(t, 1) +function Base.iterate(t::MP.Term, state) + if state == 1 + return MP.monomial(t), 2 + elseif state == 2 + return MP.coefficient(t), 3 else - return MP.monomial(t) + return nothing end end +function MA.operate!( + ::SA.UnsafeAddMul{typeof(*)}, + mc::MP.AbstractPolynomial, + val, + c::MP.AbstractPolynomial, +) + return MA.operate!(MA.add_mul, mc, val, c) +end +function SA.__canonicalize!(::MP.AbstractPolynomial) end struct Polynomial{B,M<:MP.AbstractMonomial} monomial::M