Skip to content

Commit 3fd3e3b

Browse files
authored
Merge pull request #63 from tweisser/master
Close issue #62
2 parents 6d706fd + 6ec4fdf commit 3fd3e3b

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/mono.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct Monomial{C} <: AbstractMonomial
1111

1212
function Monomial{C}(vars::Vector{PolyVar{C}}, z::Vector{Int}) where {C}
1313
if length(vars) != length(z)
14-
throw(ArgumentError("There should be as many vars than exponents"))
14+
throw(ArgumentError("There should be as many variables as exponents"))
1515
end
1616
new(vars, z)
1717
end

src/poly.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ MA.mutable_copy(p::Polynomial{C, T}) where {C, T} = Polynomial{C, T}(MA.mutable_
2323
Base.copy(p::Polynomial) = MA.mutable_copy(p)
2424
Base.zero(::Type{Polynomial{C, T}}) where {C, T} = Polynomial(T[], MonomialVector{C}())
2525
Base.one(::Type{Polynomial{C, T}}) where {C, T} = Polynomial([one(T)], MonomialVector{C}(PolyVar{C}[], [Int[]]))
26-
Base.zero(p::Polynomial{C, T}) where {C, T} = Polynomial(T[], emptymonovec(_vars(p)))
27-
Base.one(p::Polynomial{C, T}) where {C, T} = Polynomial([one(T)], MonomialVector(_vars(p), [zeros(Int, nvariables(p))]))
26+
Base.zero(p::Polynomial{C, T}) where {C, T} = Polynomial(T[], emptymonovec(copy(_vars(p))))
27+
Base.one(p::Polynomial{C, T}) where {C, T} = Polynomial([one(T)], MonomialVector(copy(_vars(p)), [zeros(Int, nvariables(p))]))
2828

2929
Polynomial{C, T}(a::AbstractVector, x::MonomialVector) where {C, T} = Polynomial{C, T}(Vector{T}(a), x)
3030
Polynomial{C, T}(a::AbstractVector, X::DMonoVec) where {C, T} = Polynomial{C, T}(monovec(a, X)...)

test/mutable_arithmetics.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,13 @@ using DynamicPolynomials
2727
@test nterms(p) == 10
2828
@test issorted(monomials(p), rev=true)
2929
@test p == T(2)x^3 + T(5)x^2 + T(4)x * y + T(4)y^2 + T(5)x + T(2) + q
30+
31+
@testset "Issue #62" begin
32+
@polyvar x y
33+
p = x^2 + x + 1
34+
q = rem(p, [x^2-y])
35+
@test q == x + y + 1
36+
end
3037
end
38+
39+

0 commit comments

Comments
 (0)