diff --git a/CITATION.bib b/CITATION.bib index d9c2b837..122f1b01 100644 --- a/CITATION.bib +++ b/CITATION.bib @@ -1,12 +1,9 @@ -@software{legat2021multivariatepolynomials, - author = {Benoît Legat and - Sascha Timme and - Robin Deits}, - title = {JuliaAlgebra/MultivariatePolynomials.jl: v0.3.18}, +@software{legat2023multivariate, + author = {Legat, Beno{\^\i}t}, + title = {Multivariate polynomials in Julia}, month = jul, - year = 2021, - publisher = {Zenodo}, - version = {v0.3.18}, - doi = {10.5281/zenodo.5083796}, - url = {https://doi.org/10.5281/zenodo.5083796} + year = 2023, + booktitle = {JuliaCon}, + year = {2022}, + url = {https://pretalx.com/juliacon-2022/talk/TRFSJY/}, } diff --git a/Project.toml b/Project.toml index 3a89e45c..4e23a531 100644 --- a/Project.toml +++ b/Project.toml @@ -2,7 +2,7 @@ name = "MultivariatePolynomials" uuid = "102ac46a-7ee4-5c85-9060-abc95bfdeaa3" license = "MIT" repo = "https://github.com/JuliaAlgebra/MultivariatePolynomials.jl" -version = "0.5.0" +version = "0.5.3" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/README.md b/README.md index fd341a81..73a7eea0 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,11 @@ The interface contains functions for accessing the coefficients, monomials, term - [**STABLE**][docs-stable-url] — **most recently tagged version of the documentation.** - [**LATEST**][docs-latest-url] — *in-development version of the documentation.* +## Citing + +Please cite the [JuliaCon 2022 presentation](https://pretalx.com/juliacon-2022/talk/TRFSJY/) [[Slides](https://drive.google.com/file/d/1q9UT5rpcmm0GdRmWm7llhVpbOx7OxGnZ/view)]. +See [CITATION.bib](https://github.com/JuliaPolyhedra/MultivariatePolynomials.jl/blob/master/CITATION.bib) for the BibTeX. + ## Examples Below is a simple usage example diff --git a/docs/src/types.md b/docs/src/types.md index 08302dee..e7bfb725 100644 --- a/docs/src/types.md +++ b/docs/src/types.md @@ -81,6 +81,8 @@ leading_coefficient leading_monomial remove_leading_term remove_monomials +filter_terms +OfDegree monic map_coefficients map_coefficients! diff --git a/src/default_term.jl b/src/default_term.jl index 34509bbc..7a91d5ad 100644 --- a/src/default_term.jl +++ b/src/default_term.jl @@ -108,6 +108,14 @@ function MA.operate!(::typeof(*), t1::Term, t2::AbstractTermLike) return t1 end +# Needed to resolve ambiguity with +# MA.operate!(::typeof(*), ::AbstractMonomial, ::AbstractMonomialLike) +function MA.operate!(::typeof(*), t1::Term, t2::AbstractMonomialLike) + MA.operate!(*, t1.coefficient, coefficient(t2)) + MA.operate!(*, t1.monomial, monomial(t2)) + return t1 +end + function MA.operate!(::typeof(one), t::Term) MA.operate!(one, t.coefficient) MA.operate!(constant_monomial, t.monomial) diff --git a/src/lazy_iterators.jl b/src/lazy_iterators.jl index 80b921aa..f60bae46 100644 --- a/src/lazy_iterators.jl +++ b/src/lazy_iterators.jl @@ -32,7 +32,7 @@ Iterator over the elements of `data` mapped by `f`. This is similar to `Base.Generator(f, data)` except that the `eltype` of a `LazyMap` is given at construction while the `eltype` of `Base.Generator(f, data)` is `Any`. """ -struct LazyMap{T,VT,F} <: AbstractVector{T} +struct LazyMap{T,VT<:AbstractVector,F} <: AbstractVector{T} f::F data::VT end @@ -58,7 +58,10 @@ Base.IteratorSize(it::LazyMap) = Base.IteratorSize(it.data) Base.eltype(::LazyMap{T}) where {T} = T -Base.getindex(it::LazyMap, i) = it.f(getindex(it.data, i)) +Base.getindex(it::LazyMap, i::Integer) = it.f(getindex(it.data, i)) +function Base.getindex(it::LazyMap{T}, I::AbstractVector) where {T} + return LazyMap{T}(it.f, getindex(it.data, I)) +end Base.eachindex(it::LazyMap) = Base.eachindex(it.data) Base.lastindex(it::LazyMap) = Base.lastindex(it.data) diff --git a/src/monomial_vector.jl b/src/monomial_vector.jl index 989e2f6f..348ebb83 100644 --- a/src/monomial_vector.jl +++ b/src/monomial_vector.jl @@ -12,7 +12,7 @@ empty_monomial_vector(p) = monomial_type(p)[] """ monomial_vector(X::AbstractVector{MT}) where {MT<:AbstractMonomialLike} -Returns the vector of monomials `X` in decreasing order and without any duplicates. +Returns the vector of monomials `X` in increasing order and without any duplicates. ### Examples @@ -31,7 +31,7 @@ end """ monomial_vector(a, X::AbstractVector{MT}) where {MT<:AbstractMonomialLike} -Returns `b, Y` where `Y` is the vector of monomials of `X` in decreasing order +Returns `b, Y` where `Y` is the vector of monomials of `X` in increasing order and without any duplicates and `b` is the vector of corresponding coefficients in `a`, where coefficients of duplicate entries are summed together. @@ -66,7 +66,7 @@ end Returns the return type of `monomial_vector`. """ function monomial_vector_type( - X::Union{AbstractVector{PT},Type{<:AbstractVector{PT}}}, + ::Union{AbstractVector{PT},Type{<:AbstractVector{PT}}}, ) where {PT<:_APL} return monomial_vector_type(PT) end @@ -102,10 +102,20 @@ sort_monomial_vector(X::Tuple) = sort_monomial_vector(vec(X)) """ merge_monomial_vectors{MT<:AbstractMonomialLike, MVT<:AbstractVector{MT}}(X::AbstractVector{MVT}} -Returns the vector of monomials in the entries of `X` in decreasing order and without any duplicates, i.e. `monomial_vector(vcat(X...))` +Returns the vector of monomials in the entries of `X` in increasing order and without any duplicates, i.e. `monomial_vector(vcat(X...))` ### Examples Calling `merge_monomial_vectors` on ``[[xy, x, xy], [x^2y, x]]`` should return ``[x^2y, xy, x]``. """ merge_monomial_vectors(X) = monomial_vector(reduce(vcat, X)) + +function error_for_negative_degree(deg) + if deg < 0 + throw( + ArgumentError( + "The degree should be a nonnegative number but the provided degree `$deg` is negative.", + ), + ) + end +end diff --git a/src/polynomial.jl b/src/polynomial.jl index 1e9ef5f8..aef6aa92 100644 --- a/src/polynomial.jl +++ b/src/polynomial.jl @@ -272,23 +272,29 @@ end #$(SIGNATURES) """ - mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}) + mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}) Returns the minimal total degree of the monomials of `p`, i.e. `minimum(degree, terms(p))`. - mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable) + mindegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}, v::AbstractVariable) Returns the minimal degree of the monomials of `p` in the variable `v`, i.e. `minimum(degree.(terms(p), v))`. ### Examples Calling `mindegree` on on ``4x^2y + xy + 2x`` should return 1, `mindegree(4x^2y + xy + 2x, x)` should return 1 and `mindegree(4x^2y + xy + 2x, y)` should return 0. """ -function mindegree(X::AbstractVector{<:AbstractTermLike}, args...) - return isempty(X) ? 0 : minimum(t -> degree(t, args...), X) +function mindegree( + X::AbstractVector{<:AbstractPolynomialLike}, + args::Vararg{Any,N}, +) where {N} + return isempty(X) ? 0 : minimum(t -> mindegree(t, args...), X) end -function mindegree(p::AbstractPolynomialLike, args...) +function mindegree(p::AbstractPolynomialLike, args::Vararg{Any,N}) where {N} return mindegree(terms(p), args...) end +function mindegree(t::AbstractTermLike, args::Vararg{Any,N}) where {N} + return degree(t, args...) +end #$(SIGNATURES) """ @@ -304,22 +310,25 @@ Returns the maximal degree of the monomials of `p` in the variable `v`, i.e. `ma Calling `maxdegree` on ``4x^2y + xy + 2x`` should return 3, `maxdegree(4x^2y + xy + 2x, x)` should return 2 and `maxdegree(4x^2y + xy + 2x, y)` should return 1. """ function maxdegree( - X::AbstractVector{<:AbstractTermLike}, + X::AbstractVector{<:AbstractPolynomialLike}, args::Vararg{Any,N}, ) where {N} - return mapreduce(t -> degree(t, args...), max, X, init = 0) + return mapreduce(t -> maxdegree(t, args...), max, X, init = 0) end function maxdegree(p::AbstractPolynomialLike, args::Vararg{Any,N}) where {N} return maxdegree(terms(p), args...) end +function maxdegree(t::AbstractTermLike, args::Vararg{Any,N}) where {N} + return degree(t, args...) +end #$(SIGNATURES) """ - extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}) + extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}) Returns the extremal total degrees of the monomials of `p`, i.e. `(mindegree(p), maxdegree(p))`. - extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractTermLike}}, v::AbstractVariable) + extdegree(p::Union{AbstractPolynomialLike, AbstractVector{<:AbstractPolynomialLike}}, v::AbstractVariable) Returns the extremal degrees of the monomials of `p` in the variable `v`, i.e. `(mindegree(p, v), maxdegree(p, v))`. @@ -327,7 +336,7 @@ Returns the extremal degrees of the monomials of `p` in the variable `v`, i.e. ` Calling `extdegree` on ``4x^2y + xy + 2x`` should return `(1, 3)`, `extdegree(4x^2y + xy + 2x, x)` should return `(1, 2)` and `maxdegree(4x^2y + xy + 2x, y)` should return `(0, 1)`. """ function extdegree( - p::Union{AbstractPolynomialLike,AbstractVector{<:AbstractTermLike}}, + p::Union{AbstractPolynomialLike,AbstractVector{<:AbstractPolynomialLike}}, args..., ) return (mindegree(p, args...), maxdegree(p, args...)) @@ -465,6 +474,52 @@ function remove_monomials( return q end +""" + function filter_terms(f::Function, p::AbstractPolynomialLike) + +Filter the polynomial `p` by only keep the terms `t` such that `f(p)` is +`true`. + +See also [`OfDegree`](@ref). + +### Examples + +```julia +julia> p = 1 - 2x + x * y - 3y^2 + x^2 * y +1 - 2x - 3y² + xy + x²y + +julia> filter_terms(OfDegree(2), p) +-3y² + xy + +julia> filter_terms(!OfDegree(2), p) +1 - 2x + x²y + +julia> filter_terms(!OfDegree(0:2), p) +x²y + +julia> filter_terms(iseven ∘ coefficient, p) +-2x +``` +""" +function filter_terms(f::F, p::AbstractPolynomialLike) where {F<:Function} + return polynomial(filter(f, terms(p)), SortedUniqState()) +end + +""" + struct OfDegree{D} <: Function + degree::D + end + +A function `d::OfDegree` is such that `d(t)` returns +`degree(t) == d.degree`. Note that `!d` creates the negation. +See also [`filter_terms`](@ref). +""" +struct OfDegree{D} <: Function + degree::D +end + +(d::OfDegree)(mono::AbstractTermLike) = in(degree(mono), d.degree) + """ monic(p::AbstractPolynomialLike) diff --git a/src/substitution.jl b/src/substitution.jl index f370bfe1..8dfa0b74 100644 --- a/src/substitution.jl +++ b/src/substitution.jl @@ -41,23 +41,7 @@ is equivalent to: subs(polynomial, (x=>1, y=>2)) """ function substitute(st::_AST, p::_APL, s::AbstractMultiSubstitution) - return substitute(st, p, pair_zip(_monomial_vector_to_variable_tuple(s))) -end - -# Evaluate the stream -# If I do s2..., then -# subs(x, x=>x+y, y=>2) would call substitute(Subs(), x+y, y=>2) -# subs(x, x=>1, y=>2) would call substitute(Subs(), 1, y=>2) -# so it would force use to also define -# sustitute(::_AST, ..., ::AbstractSubstitution...) for Any, _APL and RationalPoly. -#substitute(st::_AST, p::_APL, s1::AbstractSubstitution, s2::AbstractSubstitution...) = substitute(st, substitute(st, p, s1), s2...) -function substitute( - st::_AST, - p::_APL, - s1::AbstractSubstitution, - s2::AbstractSubstitution..., -) - return substitute(st, substitute(st, p, s1), s2) + return substitute(st, p, _flatten_subs(s)) end ## Variables @@ -82,35 +66,70 @@ function powersubstitute( return powersubstitute(st, s, p) * powersubstitute(st, s, p2...) end -function _promote_subs(S, T, s::Substitution) - # `T` is a constant - return T +function _promote_subs( + S, + ::Type{V}, + s::Substitution, +) where {V<:AbstractVariable} + return MA.promote_operation(substitute, S, V, typeof(s)) end -function _promote_subs(S, T::Type{<:Union{RationalPoly,_APL}}, s::Substitution) - return MA.promote_operation(substitute, S, T, typeof(s)) +function _flatten_subs(s::AbstractMultiSubstitution) + return pair_zip(_monomial_vector_to_variable_tuple(s)) end -function _promote_subs(S, T, s::AbstractMultiSubstitution) - return _promote_subs( - S, - T, - pair_zip(_monomial_vector_to_variable_tuple(s))..., - ) +function _flatten_subs(s::Substitution) + return (s,) end -function _promote_subs( - S, - T, - head::AbstractSubstitution, +# Turn a tuple of `AbstractSubstitution` into a `Tuple` if `Substitution` +function _flatten_subs( + s::AbstractSubstitution, tail::Vararg{AbstractSubstitution,N}, ) where {N} - return _promote_subs(S, _promote_subs(S, T, head), tail...) + return (_flatten_subs(s)..., _flatten_subs(tail...)...) +end + +function power_promote( + S, + ::Type{V}, + s::Substitutions, +) where {V<:AbstractVariable} + T = MA.promote_operation(substitute, S, V, typeof.(_flatten_subs(s...))...) + return MA.promote_operation(*, T, T) +end + +function power_promote( + S, + ::Vector{V}, + s::Substitutions, +) where {V<:AbstractVariable} + return power_promote(S, V, s) +end + +function power_promote( + S, + ::Tuple{V}, + s::Substitutions, +) where {V<:AbstractVariable} + return power_promote(S, V, s) +end + +function power_promote( + S, + vars::Tuple{V,Vararg{AbstractVariable,N}}, + s::Substitutions, +) where {V<:AbstractVariable,N} + return MA.promote_operation( + *, + power_promote(S, V, s), + power_promote(S, Base.tail(vars), s), + ) end function substitute(st::_AST, m::AbstractMonomial, s::Substitutions) if isconstant(m) - return one(_promote_subs(typeof(st), typeof(m), s...)) + return one(power_promote(typeof(st), variables(m), s)) else return powersubstitute(st, s, powers(m)...) end diff --git a/test/monomial_vector.jl b/test/monomial_vector.jl index 632d1130..5f43757b 100644 --- a/test/monomial_vector.jl +++ b/test/monomial_vector.jl @@ -100,4 +100,11 @@ v[1]^3, ] end + + @testset "Negative degree" begin + Mod.@polyvar x[1:3] + @test_throws ArgumentError monomials(x, -1) + @test_throws ArgumentError monomials(x, -1:1) + @test_throws ArgumentError monomials(x, [1, -1]) + end end diff --git a/test/mutable_arithmetics.jl b/test/mutable_arithmetics.jl index 9a93c691..77120c85 100644 --- a/test/mutable_arithmetics.jl +++ b/test/mutable_arithmetics.jl @@ -1,5 +1,5 @@ -import MutableArithmetics -const MA = MutableArithmetics +using Test +import MutableArithmetics as MA function all_tests(a, b, c, d, e, f, g) a_copy = deepcopy(a) diff --git a/test/ncmonomial.jl b/test/ncmonomial.jl index 552cf589..fe3252da 100644 --- a/test/ncmonomial.jl +++ b/test/ncmonomial.jl @@ -37,7 +37,10 @@ end end @testset "Non-commutative MonomialVector" begin - Mod.@ncpolyvar x y + v = Mod.@ncpolyvar x y + @test_throws ArgumentError monomials(v, -1) + @test_throws ArgumentError monomials(v, -1:1) + @test_throws ArgumentError monomials(v, [1, -1]) X = empty_monomial_vector(typeof(x)) @test iszero(nvariables(X)) @test isempty(variables(X)) diff --git a/test/polynomial.jl b/test/polynomial.jl index 3ebb00ac..90434ba5 100644 --- a/test/polynomial.jl +++ b/test/polynomial.jl @@ -1,7 +1,6 @@ using Test using LinearAlgebra -import MutableArithmetics -const MA = MutableArithmetics +import MutableArithmetics as MA using MultivariatePolynomials const MP = MultivariatePolynomials @testset "Polynomial" begin @@ -73,29 +72,44 @@ const MP = MultivariatePolynomials @test Tuple(variables([x + 1, y^2])) == (x, y) @test Tuple(variables([y^2, x + 1])) == (x, y) - @test maxdegree(x^2 - x^2) == 0 - @test maxdegree(x^2 - x^2, x) == 0 - @test maxdegree(x^2 - x^2, y) == 0 - @test mindegree(x^2 - x^2) == 0 - @test mindegree(x^2 - x^2, x) == 0 - @test mindegree(x^2 - x^2, y) == 0 - @test extdegree(x^2 - x^2) == (0, 0) - @test extdegree(x^2 - x^2, x) == (0, 0) - @test extdegree(x^2 - x^2, y) == (0, 0) - @test maxdegree(x * y + 2 + x^2 * y + x + y) == 3 - @test maxdegree(x * y + 2 + x^2 * y + x + y, x) == 2 - @test maxdegree(x * y + 2 + x^2 * y + x + y, y) == 1 - @test mindegree(x * y + 2 + x^2 * y + x + y) == 0 - @test mindegree(x * y + 2 + x^2 * y + x + y, x) == 0 - @test mindegree(x * y + 2 + x^2 * y + x + y, y) == 0 - @test extdegree(x * y + 2 + x^2 * y + x + y) == (0, 3) - @test extdegree(x * y + 2 + x^2 * y + x + y, x) == (0, 2) - @test extdegree(x * y + 2 + x^2 * y + x + y, y) == (0, 1) - @test extdegree(x * y + x^2 * y, x) == (1, 2) - @test extdegree(x * y + x^2 * y, y) == (1, 1) - @test leading_term(x * y + 2 + x^2 * y + x + y) == x^2 * y + p = x^2 - x^2 + @test maxdegree(p) == 0 + @test maxdegree(p, x) == 0 + @test maxdegree(p, y) == 0 + @test mindegree(p) == 0 + @test mindegree(p, x) == 0 + @test mindegree(p, y) == 0 + @test extdegree(p) == (0, 0) + @test extdegree(p, x) == (0, 0) + @test extdegree(p, y) == (0, 0) + q = x * y + 2 + x^2 * y + x + y + @test maxdegree(q) == 3 + @test maxdegree(q, x) == 2 + @test maxdegree(q, y) == 1 + @test mindegree(q) == 0 + @test mindegree(q, x) == 0 + @test mindegree(q, y) == 0 + @test extdegree(q) == (0, 3) + @test extdegree(q, x) == (0, 2) + @test extdegree(q, y) == (0, 1) + r = x * y + x^2 * y + @test extdegree(r, x) == (1, 2) + @test extdegree(r, y) == (1, 1) + @test leading_term(q) == x^2 * y @test nvariables(x + y - x) == 2 @test nvariables(x + x^2) == 1 + @test mindegree([p, q, r]) == 0 + @test mindegree([p, q, r], x) == 0 + @test mindegree([p, q, r], y) == 0 + @test mindegree([p, q], y) == 0 + @test mindegree([q], y) == 0 + @test mindegree([r], y) == 1 + @test maxdegree([p, q, r]) == 3 + @test maxdegree([p, q, r], x) == 2 + @test maxdegree([p, q, r], y) == 1 + @test extdegree([p, q, r]) == (0, 3) + @test extdegree([p, q, r], x) == (0, 2) + @test extdegree([p, q, r], y) == (0, 1) @test collect( coefficients( @@ -108,11 +122,15 @@ const MP = MultivariatePolynomials @test collect(coefficients(4x^2 * y + x * y + 2x)) == [2, 1, 4] @test collect(coefficients(4x^2 * y + x * y + 2x + 3, [x, 1, x * y, y])) == [2, 3, 1, 0] + @test monomials(4x^2 * y + x * y + 2x + 3)[1:1] == + [constant_monomial(x * y)] for p in [polynomial([4, 9], [x, x * x]), polynomial([9, 4], [x * x, x])] @test collect(coefficients(p)) == [4, 9] @test monomials(p)[1] == x @test monomials(p)[2] == x^2 + @test monomials(p)[1:2][1] == x + @test monomials(p)[1:2][2] == x^2 @test p == dot([4, 9], [x, x * x]) end @@ -131,7 +149,12 @@ const MP = MultivariatePolynomials @test transpose(x + y) == x + y @test transpose([1 2; 3 4] * x) == [1 3; 2 4] * x - @test remove_monomials(4x^2 * y + x * y + 2x, [x * y]) == 4x^2 * y + 2x + p = 4x^2 * y + x * y + 2x + @test remove_monomials(p, [x * y]) == 4x^2 * y + 2x + @test filter_terms(OfDegree(2), 4x^2 * y + x * y + 2x) == x * y + @test filter_terms(!OfDegree(2), 4x^2 * y + x * y + 2x) == 4x^2 * y + 2x + @test filter_terms(iseven ∘ MP.coefficient, 4x^2 * y + x * y + 2x) == + 4x^2 * y + 2x @test_throws InexactError push!([1], x + 1) diff --git a/test/substitution.jl b/test/substitution.jl index 3e0deb1e..e9118636 100644 --- a/test/substitution.jl +++ b/test/substitution.jl @@ -70,6 +70,13 @@ import MutableArithmetics as MA @test p(varst => valst) == 13 @test p(varsv => valsv) == 13 + @testset "Eval on constant monomial" begin + m = constant_monomial(prod(x)) + mr = m(x => reverse(x)) + @test isconstant(mr) + @test variables(mr) == x + end + Mod.@polyvar x y @test subs([x^2 + y, x + y], x => y) == [y^2 + y, 2y] diff --git a/test/term.jl b/test/term.jl index 92bfc6d1..6da09258 100644 --- a/test/term.jl +++ b/test/term.jl @@ -1,6 +1,16 @@ +import MutableArithmetics as MA +import MultivariatePolynomials as MP + struct CoefNotComparable end Base.iszero(::CoefNotComparable) = false +struct Term2{T,M} <: MP.AbstractTermLike{T} + monomial::M +end +MP.coefficient(t::Term2{T}) where {T} = 2one(T) +MP.monomial(t) = t.monomial +MP.term_type(::Type{Term2{T,M}}) where {T,M} = MP.Term{T,M} + @testset "Term" begin Mod.@polyvar x @test convert(Any, 1x) == 1x @@ -95,4 +105,21 @@ Base.iszero(::CoefNotComparable) = false @test !(t1 < t2) @test t1 <= t2 end + + @testset "MA $T" for T in [Int, BigInt] + M = typeof(x^2) + t = one(T) * x + s = MA.operate!!(*, t, x) + @test monomial(s) == x^2 + if T == BigInt && MA.mutability(M) isa MA.IsMutable + @test monomial(t) == x^2 + end + u = MA.operate!!(*, s, Term2{T,M}(x^3)) + @test monomial(u) == x^5 + @test coefficient(u) == 2 + if T == BigInt && MA.mutability(M) isa MA.IsMutable + @test monomial(t) == x^5 + @test coefficient(t) == 2 + end + end end diff --git a/test/utils.jl b/test/utils.jl index d2d98553..e6e1b543 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -19,7 +19,6 @@ end struct CustomPoly{T,P<:AbstractPolynomial{T}} <: AbstractPolynomialLike{T} p::P end -CustomPoly(p::AbstractPolynomial{T}) where {T} = CustomPoly{T,typeof(p)}(p) function MultivariatePolynomials.term_type(::Type{CustomPoly{T,P}}) where {T,P} return MultivariatePolynomials.term_type(P) end @@ -39,7 +38,6 @@ Base.copy(p::CustomPoly) = CustomPoly(copy(p.p)) struct CustomTerms{T,P<:AbstractPolynomial{T}} <: AbstractPolynomialLike{T} p::P end -CustomTerms(p::AbstractPolynomial{T}) where {T} = CustomTerms{T,typeof(p)}(p) function MultivariatePolynomials.term_type(::Type{CustomTerms{T,P}}) where {T,P} return MultivariatePolynomials.term_type(P) end @@ -50,9 +48,6 @@ function MultivariatePolynomials.monomial_type( ) where {T,P} return monomial_type(P) end -function MultivariatePolynomials.constant_monomial(p::CustomPoly) - return constant_monomial(p.p) -end Base.copy(p::CustomTerms) = CustomTerms(copy(p.p)) function _typetests(x, ::Type{T}) where {T}