8000 Convert `GroupAlgebraElem` to `Dict` · Issue #1690 · thofma/Hecke.jl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Convert GroupAlgebraElem to Dict #1690
Open
@lgoettgens

Description

@lgoettgens

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0