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

allow specifying index type for CachedExtensionHomomorphism #65

Merged
merged 2 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
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
33 changes: 26 additions & 7 deletions src/ext_homomorphisms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ PermutationGroups.degree(hom::InducedActionHomomorphism) = length(basis(hom))

coeff_type(hom::InducedActionHomomorphism) = coeff_type(action(hom))
_int_type(::Type{<:StarAlgebras.AbstractBasis{T,I}}) where {T,I} = I
_int_type(hom::InducedActionHomomorphism) = _int_type(typeof(basis(hom)))
_int_type(basis::StarAlgebras.AbstractBasis) = _int_type(typeof(basis))
_int_type(hom::InducedActionHomomorphism) = _int_type(basis(hom))

# Exceeding typemax(UInt32) here would mean e.g. that you're trying to block-diagonalize
# an SDP constraint of size 4_294_967_295 × 4_294_967_295, which is highly unlikely ;)
_int_type(::Type{<:Action}) = UInt32
_int_type(ac::Action) = _int_type(typeof(ac))

# Exceeding typemax(UInt16) here would mean e.g. that you're trying to block-diagonalize
# an SDP constraint of size 65535×65535, which is highly unlikely ;)
_int_type(::Type{<:InducedActionHomomorphism}) = UInt16

function induce(hom::InducedActionHomomorphism, g::GroupElement)
return induce(action(hom), hom, g)
Expand All @@ -43,7 +46,7 @@ end

function ExtensionHomomorphism(action::Action, basis)
return ExtensionHomomorphism(
_int_type(ExtensionHomomorphism),
_int_type(action),
action,
basis,
)
Expand Down Expand Up @@ -78,12 +81,13 @@ StarAlgebras.basis(h::CachedExtensionHomomorphism) = basis(h.ehom)
action(h::CachedExtensionHomomorphism) = action(h.ehom)

function CachedExtensionHomomorphism(
::Type{I},
G::Group,
action::Action,
basis;
precompute = false,
)
hom = ExtensionHomomorphism(action, basis)
) where {I}
hom = ExtensionHomomorphism(I, action, basis)
S = typeof(induce(hom, one(G)))
chom = CachedExtensionHomomorphism{eltype(G),S}(hom)
@sync if precompute
Expand All @@ -96,6 +100,21 @@ function CachedExtensionHomomorphism(
return chom
end

function CachedExtensionHomomorphism(
G::Group,
action::Action,
basis;
precompute = false,
)
return CachedExtensionHomomorphism(
_int_type(action),
G,
action,
basis;
precompute = precompute,
)
end

function induce(ac::Action, chom::CachedExtensionHomomorphism, g::GroupElement)
return _induce(ac, chom, g)
end
Expand Down
11 changes: 11 additions & 0 deletions test/action_permutation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,23 @@ end
action = OnLetters()
tbl = SymbolicWedderburn.CharacterTable(Rational{Int}, G)
ehom = SymbolicWedderburn.CachedExtensionHomomorphism(
Int32,
G,
action,
words;
precompute = true,
)
@test all(g ∈ keys(ehom.cache) for g in G) # we actually cached
@test typeof(SymbolicWedderburn.induce(ehom, one(G))) == Perm{Int32}

ehom = SymbolicWedderburn.CachedExtensionHomomorphism(
G,
action,
words;
precompute = true,
)
@test all(g ∈ keys(ehom.cache) for g in G) # we actually cached
@test typeof(SymbolicWedderburn.induce(ehom, one(G))) == Perm{UInt32} # the default

ψ = SymbolicWedderburn.action_character(ehom, tbl)
@test SymbolicWedderburn.constituents(ψ) == [40, 22, 18]
Expand Down
Loading