Skip to content

Commit

Permalink
Fix mutation of power of monomial (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat authored Sep 8, 2023
1 parent 6795fc4 commit d9c7949
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Defining the specific methods solve this problem and also make
# them a lot faster
Base.:(^)(x::Variable{V,M}, i::Int) where {V,M} = Monomial{V,M}([x], [i])
Base.:(^)(x::Monomial{<:Commutative}, i::Int) = Monomial(x.vars, i * x.z)
Base.:(^)(x::Monomial{<:Commutative}, i::Int) = Monomial(copy(x.vars), i * x.z)

myminivect(x::T, y::T) where {T} = [x, y]
function myminivect(x::S, y::T) where {S,T}
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ using LinearAlgebra
@test p(x0 => y0, x1 => y1) == y1 * y0 * y1
end

# https://github.com/JuliaAlgebra/DynamicPolynomials.jl/issues/141
@testset "Issue #141" begin
@polyvar x
m = x^2
q = m^2
@test variables(q) !== variables(m)
end

@testset "Issue #79, Issue #80 and Issue #92" begin
@polyvar x[1:2]
p1 = x[1] * 0.0 + x[2] * 0
Expand Down

0 comments on commit d9c7949

Please sign in to comment.