Skip to content

Commit

Permalink
fix: wrong addeq! for MatAlgebraElem (#1548)
Browse files Browse the repository at this point in the history
- fixes #1547
  • Loading branch information
thofma authored Jun 19, 2024
1 parent 5d876ad commit 3c29ce9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/AlgAss/AlgMatElem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,16 @@ function mul!(c::T, a::T, b::T) where {T <: MatAlgebraElem}
return c
end

function addeq!(b::T, a::T) where {T <: MatAlgebraElem}
parent(a) != parent(b) && error("Parents don't match.")
A = parent(a)

b.matrix = addeq!(b.matrix, a.matrix)
b.has_coeffs = false

return b
end

################################################################################
#
# Ad hoc operations
Expand Down
9 changes: 9 additions & 0 deletions test/AlgAss/Elem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,13 @@
# mul! for matrix algebra elements
A = matrix_algebra(QQ, 2)
@test isone(mul!(zero(A), one(A), ZZRingElem(1)))

# add! for matrix algebra elements
# 1547
let
A = matrix_algebra(QQ, 2)
b = A(matrix(QQ, [3 4; 5 6]))
Hecke.addeq!(b,b)
@test b == A(matrix(QQ, [6 8; 10 12]))
end
end

0 comments on commit 3c29ce9

Please sign in to comment.