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

Convert GroupAlgebraElem to Dict #1690

Open
lgoettgens opened this issue Nov 21, 2024 · 0 comments
Open

Convert GroupAlgebraElem to Dict #1690

lgoettgens opened this issue Nov 21, 2024 · 0 comments

Comments

@lgoettgens
Copy link
Contributor

The following code comes from the abandoned oscar-system/Oscar.jl#4334, and can be used to convert a GroupAlgebraElem (with sparse rep!) to a Dict{Group, elem_type(base_ring_type(...)) using Dict(x). I put this here in case someone wants to extend it for the dense rep and put it in the src.

function Base.length(x::GroupAlgebraElem)
  @assert Hecke._is_sparse(x)
  return length(x.coeffs_sparse)
end

function Base.iterate(x::GroupAlgebraElem)
  @assert Hecke._is_sparse(x)
  next = iterate(x.coeffs_sparse)
  isnothing(next) && return nothing
  (i, c), st = next
  return (parent(x).base_to_group[i], c), st
end

function Base.iterate(x::GroupAlgebraElem, st)
  @assert Hecke._is_sparse(x)
  next = iterate(x.coeffs_sparse, st)
  isnothing(next) && return nothing
  (i, c), st = next
  return (parent(x).base_to_group[i], c), st
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant