Skip to content

Commit

Permalink
zero!(.) -> MA.operate!(zero, .)
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Feb 26, 2024
1 parent 9cd7e19 commit 79bbcf8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Base.:^(a::AlgebraElement, p::Integer) = Base.power_by_squaring(a, p)

# mutable API; TODO: replace with MutableArithmetic

function zero!(a::AlgebraElement)
function MA.operate!(::typeof(zero), a::AlgebraElement)
MA.operate!(zero, a.coeffs)
return a
end
Expand All @@ -56,7 +56,7 @@ function add!(res::AlgebraElement, X::AlgebraElement, Y::AlgebraElement)
res[idx] += x
end
else
zero!(res)
MA.operate!(zero, res)
for (idx, x) in _nzpairs(coeffs(X))
res[idx] += x
end
Expand All @@ -77,7 +77,7 @@ end
function mul!(res::AlgebraElement, X::AlgebraElement, a::Number)
@assert parent(res) === parent(X)
if res !== X
zero!(res)
MA.operate!(zero, res)
end
for (idx, x) in _nzpairs(coeffs(X))
res.coeffs[idx] = a * x
Expand Down
2 changes: 1 addition & 1 deletion test/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
)
@test coeffs(Z) == coeffs(W)

StarAlgebras.zero!(W)
MA.operate!(zero, W)
StarAlgebras.fmac!(coeffs(W), coeffs(X), coeffs(Y), RG.mstructure)

@test coeffs(2 * X * Y) == coeffs(StarAlgebras.mul!(W, W, 2))
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ using StarAlgebras
import StarAlgebras as SA
using LinearAlgebra
using SparseArrays
import MutableArithmetics as MA


include("perm_grp_algebra.jl")
Expand Down

0 comments on commit 79bbcf8

Please sign in to comment.