Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ for op in [:+, :-]
return $op(map_coefficients(J -> J.λ, p1, nonzero = true), p2)
end
end

function Base.isapprox(t1::AbstractTermLike, t2::AbstractTermLike; kwargs...)
return isapprox(coefficient(t1), coefficient(t2); kwargs...) &&
monomial(t1) == monomial(t2)
end

function Base.isapprox(p1::_APL, p2::_APL; kwargs...)
return isapprox(promote(p1, p2)...; kwargs...)
end
Expand Down
11 changes: 11 additions & 0 deletions test/commutative/comparison.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@
@testset "Monomial equality" begin
Mod.@polyvar x y
@test 1 == constant_monomial(x)
@test 1 ≈ constant_monomial(x)
@test 2 != constant_monomial(x)
@test !(2 ≈ constant_monomial(x))
@test 2 != x
@test !(2 ≈ x)
@test 2 != x * y
@test !(2 ≈ x * y)
@test x * y != x
@test !(x * y ≈ x)
@test 1x * y == x * y
@test 1x * y ≈ x * y
@test 2x * y != x * y
@test !(2x * y ≈ x * y)
@test x == monomial(x)
@test x ≈ monomial(x)
@test x * y^0 == x
@test x * y^0 ≈ x
@test x != x^0 * y
@test !(x ≈ x^0 * y)
@test x^2 != x * y
@test !(x^2 ≈ x * y)
end
@testset "Polynomial equality" begin
Mod.@polyvar x y
Expand Down
Loading