Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance of bracket for AbstractLieAlgebraElem #4228

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double checked and it seems this is indeed the correct argument order -- very confusing when one already knows addmul! :-(.

On the up side, perhaps we can just simply define methods

addmul!(a::SRow{T}, b::SRow{T}, c::T) where T = add_right_scaled_row(b, a, c) 
addmul!(a::SRow{T}, b::T, c::SRow{T}) where T = add_left_scaled_row(c, a, b)

and migrate to those over time?

But of course that's not any reason to hold up this PR, just musings :-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See thofma/Hecke.jl#1659. I would suggest to merge this PR here right now and then once thofma/Hecke.jl#1659 is available go through Oscar and phase out the add_scaled_row! calls. (if you agree please approve and merge this)

end
end
return L(vec)
end

###############################################################################
Expand Down
Loading