Skip to content

Commit

Permalink
Implement equality with Polynomial (#27)
Browse files Browse the repository at this point in the history
* Implement equality with Polynomial

* Fix
  • Loading branch information
blegat authored May 22, 2024
1 parent 02b3595 commit 569a597
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function Polynomial{B}(v::MP.AbstractVariable) where {B}
return Polynomial{B}(MP.monomial(v))
end

function Base.:(==)(p::Polynomial{B}, q::Polynomial{B}) where {B}
return p.monomial == q.monomial
end

MP.variables(p::Polynomial) = MP.variables(p.monomial)
MP.nvariables(p::Polynomial) = MP.nvariables(p.monomial)

Expand Down
2 changes: 2 additions & 0 deletions test/monomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ using DynamicPolynomials
b = a * a
@test b.coeffs == x^2
@test typeof(b.coeffs) == typeof(x^2)
@test MB.Polynomial{MB.Monomial}(x^2) == MB.Polynomial{MB.Monomial}(x^2)
@test MB.Polynomial{MB.Monomial}(x^3) != MB.Polynomial{MB.Monomial}(x^2)
end

@testset "Linear" begin
Expand Down

0 comments on commit 569a597

Please sign in to comment.