Skip to content

Commit

Permalink
feat: group algebras with sparse representation
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Oct 26, 2024
1 parent 2af99ca commit 60f759d
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 90 deletions.
1 change: 1 addition & 0 deletions docs/src/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export default defineConfig({
{ text: 'Introduction', link: 'manual/algebras/intro'},
{ text: 'Basics', link: 'manual/algebras/basics'},
{ text: 'Structure constant algebras', link: 'manual/algebras/structureconstant'},
{ text: 'Group algebras', link: 'manual/algebras/groupalgebras'},
{ text: 'Ideals', link: 'manual/algebras/ideals'},
]
},
Expand Down
61 changes: 61 additions & 0 deletions docs/src/manual/algebras/groupalgebras.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Group algebras

```@meta
CurrentModule = Hecke
DocTestSetup = quote
using Hecke
end
```

As is natural, the basis of a group algebra $K[G]$ correspond to the elements of $G$ with respect
to some arbitrary ordering.

## Creation

```@docs
group_algebra(::Field, ::Group)
```

Note that by default, this construction requires enumerating all elements of
the group and thus is inefficient for large groups. Using the optional argument `sparse = true`,
the algebra can be constructed with a different internal model. This allows for much larger groups,
but not all functionality is available in this case.

```jldoctest
julia> G = abelian_group([2 for i in 1:10]) # group of order 2^10
(Z/2)^10
julia> QG = group_algebra(QQ, G; sparse = true);
```

## Elements

Given a group algebra `A` and an element of a group `g`, the corresponding group algebra element
can be constructed using the syntax `A(g)`.

```jldoctest grpalgex1
julia> G = abelian_group([2, 2]); a = G([0, 1]);
julia> QG = group_algebra(QQ, G);
julia> x = QG(a)
[0, 0, 1, 0]
```

Vice versa, one can obtain the coordinate of a group algebra element `x` with respect to a group
element `a` using the syntax `x[a]`.

```jldoctest grpalgex1
julia> x[a]
1
```

It is also possible to create elements by specifying for each group element the corresponding coordinate either by a list of pairs or a dictionary:

```jldoctest grpalgex1
julia> QG(a => 2, zero(G) => 1) == 2 * QG(a) + 1 * QG(zero(G))
true
julia> QG(Dict(a => 2, zero(G) => 1)) == 2 * QG(a) + 1 * QG(zero(G))
true
```
15 changes: 15 additions & 0 deletions src/AlgAss/AbsAlgAss.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
################################################################################
#
# Internal thingy
#
################################################################################

# check if elements are represented using a sparse row

_is_sparse(A::AbstractAssociativeAlgebra) = false

_is_sparse(A::GroupAlgebra) = A.sparse

# because we are lazy
_is_dense(A::AbstractAssociativeAlgebra) = !_is_sparse(A)

_base_ring(A::AbstractAssociativeAlgebra) = base_ring(A)

@doc raw"""
Expand Down
62 changes: 40 additions & 22 deletions src/AlgAss/AlgGrp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ group(A::GroupAlgebra) = A.group

has_one(A::GroupAlgebra) = true

function (A::GroupAlgebra{T, S, R})(c::Vector{T}; copy::Bool = false) where {T, S, R}
length(c) != dim(A) && error("Dimensions don't match.")
function (A::GroupAlgebra{T, S, R})(c::Union{Vector{T}, SRow{T}}; copy::Bool = false) where {T, S, R}
c isa Vector && length(c) != dim(A) && error("Dimensions don't match.")
return GroupAlgebraElem{T, typeof(A)}(A, copy ? deepcopy(c) : c)
end

Expand All @@ -52,24 +52,44 @@ function multiplication_table(A::GroupAlgebra; copy::Bool = true)
end
end

# get the underyling group operation, I wish this was part of the group interface

_op(G::AbstractAlgebra.AdditiveGroup) = +

_op(G::Group) = *

_op(A::GroupAlgebra) = _op(group(A))

################################################################################
#
# Construction
#
################################################################################

@doc raw"""
group_algebra(K::Ring, G; op = *) -> GroupAlgebra
group_algebra(K::Ring, G::Group; cached::Bool = true) -> GroupAlgebra
Returns the group ring $K[G]$.
$G$ may be any set and `op` a group operation on $G$.
"""
group_algebra(K::Ring, G; op = *) = GroupAlgebra(K, G, op = op)
Return the group algebra of the group $G$ over the ring $R$. Shorthand syntax
for this construction is `R[G]`.
group_algebra(K::Ring, G::FinGenAbGroup) = GroupAlgebra(K, G)
# Examples
function group_algebra(K::Field, G; op = *)
A = GroupAlgebra(K, G, op = op)
```jldoctest
julia> QG = group_algebra(QQ, small_group(8, 5))
Group algebra
of generic group of order 8 with multiplication table
over rational field
```
"""
group_algebra(K::Ring, G; cached = true) = _group_algebra(K, G; op = *, cached)

# one additional level of indirection to hide the non-user facing options
# `op` and `sparse`.
function _group_algebra(K::Ring, G; op = *, sparse = _use_sparse_group_algebra(G), cached::Bool = true)
A = GroupAlgebra(K, G; op = _op(G) , sparse = sparse, cached = cached)
if !(K isa Field)
return A
end
if iszero(characteristic(K))
A.issemisimple = 1
else
Expand All @@ -78,21 +98,19 @@ function group_algebra(K::Field, G; op = *)
return A
end

function group_algebra(K::Field, G::FinGenAbGroup)
A = group_algebra(K, G, op = +)
A.is_commutative = true
return A
end
#_group_algebra(K::Ring, G::FinGenAbGroup; op = +, cached::Bool = true, sparse::Bool = false) = GroupAlgebra(K, G, cached, sparse)

@doc raw"""
(K::Ring)[G::Group] -> GroupAlgebra
(K::Ring)[G::FinGenAbGroup] -> GroupAlgebra
Returns the group ring $K[G]$.
"""
getindex(K::Ring, G::Group) = group_algebra(K, G)
getindex(K::Ring, G::FinGenAbGroup) = group_algebra(K, G)

function _use_sparse_group_algebra(G)
if !is_finite(G)
return true
else
return order(G) >= 1000
end
end

################################################################################
#
# Commutativity
Expand Down Expand Up @@ -629,7 +647,7 @@ const _reps = [(i=24,j=12,n=5,dims=(1,1,2,3,3),
#
################################################################################

mutable struct AbsAlgAssMorGen{S, T, U, V} <: Map{S, T, HeckeMap, AbsAlgAssMorGen}
mutable struct AbsAlgAssMorGen{S, T, U, V} <: Map{S, T, HeckeMap, Any}#AbsAlgAssMorGen}
domain::S
codomain::T
tempdomain::U
Expand Down
Loading

0 comments on commit 60f759d

Please sign in to comment.