Skip to content

Commit

Permalink
Improve performance of bracket for AbstractLieAlgebraElem (#4228)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens authored Oct 24, 2024
1 parent ab11326 commit 5c30f3a
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions experimental/LieAlgebras/src/AbstractLieAlgebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ function bracket(
) where {C<:FieldElem}
check_parent(x, y)
L = parent(x)
mat = sum(
cxi * cyj * _struct_consts(L)[i, j] for (i, cxi) in enumerate(coefficients(x)),
(j, cyj) in enumerate(coefficients(y));
init=sparse_row(coefficient_ring(L)),
)
return L(mat)
vec = sparse_row(coefficient_ring(L))
for (i, cxi) in enumerate(coefficients(x))
iszero(cxi) && continue
for (j, cyj) in enumerate(coefficients(y))
iszero(cyj) && continue
Hecke.add_scaled_row!(_struct_consts(L)[i, j], vec, cxi * cyj)
end
end
return L(vec)
end

###############################################################################
Expand Down

0 comments on commit 5c30f3a

Please sign in to comment.