Skip to content

Commit

Permalink
Equality between bases (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored May 9, 2024
1 parent e437e29 commit d35bba2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Society for Industrial and Applied Mathematics, **2012**.
abstract type AbstractPolynomialBasis end

generators(basis::AbstractPolynomialBasis) = basis.polynomials
function Base.:(==)(a::AbstractPolynomialBasis, b::AbstractPolynomialBasis)
return generators(a) == generators(b)
end

function Base.copy(basis::AbstractPolynomialBasis)
return typeof(basis)(copy(generators(basis)))
Expand Down
2 changes: 2 additions & 0 deletions test/monomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ using DynamicPolynomials

@testset "Linear" begin
basis = MonomialBasis([x, y])
@test basis == MonomialBasis([y, x])
@test basis != MonomialBasis([y, y^2, x])
@test polynomial_type(basis, Int) == polynomial_type(x, Int)
@test polynomial(i -> i^2, basis) == 4x + y
@test coefficients(x + 4y, MonomialBasis) == [4, 1]
Expand Down

0 comments on commit d35bba2

Please sign in to comment.