-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from kalmarek/enh/minimal_projection_system
Enh/minimal projection system
- Loading branch information
Showing
40 changed files
with
2,602 additions
and
1,185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
struct PermutingVariables <: SymbolicWedderburn.ByPermutations end | ||
using DynamicPolynomials | ||
MP = DynamicPolynomials.MultivariatePolynomials | ||
using GroupsCore | ||
using PermutationGroups | ||
|
||
function SymbolicWedderburn.action(a::PermutingVariables, g::PermutationGroups.AbstractPerm, m::Monomial) | ||
struct VariablePermutation <: SymbolicWedderburn.ByPermutations end | ||
|
||
function SymbolicWedderburn.action(a::VariablePermutation, g::PermutationGroups.AbstractPerm, m::Monomial) | ||
v = variables(m) | ||
return m(v => SymbolicWedderburn.action(a, g, v)) | ||
end | ||
|
||
function SymbolicWedderburn.action(::PermutingVariables, g::PermutationGroups.AbstractPerm, v::AbstractVector) | ||
function SymbolicWedderburn.action(::VariablePermutation, g::PermutationGroups.AbstractPerm, v::AbstractVector) | ||
return map(i -> v[i^g], eachindex(v)) | ||
end | ||
|
||
abstract type OnMonomials <: SymbolicWedderburn.ByLinearTransformation end | ||
|
||
function SymbolicWedderburn.action( | ||
a::Union{VariablePermutation,OnMonomials}, | ||
el::GroupElement, | ||
term::MP.AbstractTerm, | ||
) | ||
return MP.coefficient(term) * SymbolicWedderburn.action(a, el, MP.monomial(term)) | ||
end | ||
function SymbolicWedderburn.action( | ||
a::Union{VariablePermutation,OnMonomials}, | ||
el::GroupElement, | ||
poly::MP.AbstractPolynomial, | ||
) | ||
return sum([SymbolicWedderburn.action(a, el, term) for term in MP.terms(poly)]) | ||
end | ||
|
||
function SymbolicWedderburn.decompose( | ||
k::MP.AbstractPolynomialLike, | ||
hom::SymbolicWedderburn.InducedActionHomomorphism, | ||
) | ||
# correct only if features(hom) == monomials | ||
|
||
indcs = [hom[mono] for mono in MP.monomials(k)] | ||
coeffs = MP.coefficients(k) | ||
|
||
return indcs, coeffs | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import GroupsCore | ||
|
||
struct DihedralGroup <: GroupsCore.Group | ||
n::Int | ||
end | ||
|
||
struct DihedralElement <: GroupsCore.GroupElement | ||
n::Int | ||
reflection::Bool | ||
id::Int | ||
end | ||
|
||
Base.one(G::DihedralGroup) = DihedralElement(G.n, false, 0) | ||
|
||
Base.eltype(::DihedralGroup) = DihedralElement | ||
function Base.iterate(G::DihedralGroup, prev::DihedralElement=DihedralElement(G.n, false, -1)) | ||
if prev.id + 1 >= G.n | ||
if prev.reflection | ||
return nothing | ||
else | ||
next = DihedralElement(G.n, true, 0) | ||
end | ||
else | ||
next = DihedralElement(G.n, prev.reflection, prev.id + 1) | ||
end | ||
return next, next | ||
end | ||
Base.IteratorSize(::Type{DihedralGroup}) = Base.HasLength() | ||
|
||
GroupsCore.order(::Type{T}, G::DihedralGroup) where {T} = convert(T, 2G.n) | ||
GroupsCore.gens(G::DihedralGroup) = [DihedralElement(G.n, false, 1), DihedralElement(G.n, true, 0)] | ||
|
||
# Base.rand not needed for our purposes here | ||
|
||
Base.parent(g::DihedralElement) = DihedralGroup(g.n) | ||
function Base.:(==)(g::DihedralElement, h::DihedralElement) | ||
return g.n == h.n && g.reflection == h.reflection && g.id == h.id | ||
end | ||
|
||
function Base.inv(el::DihedralElement) | ||
if el.reflection || iszero(el.id) | ||
return el | ||
else | ||
return DihedralElement(el.n, false, el.n - el.id) | ||
end | ||
end | ||
function Base.:*(a::DihedralElement, b::DihedralElement) | ||
a.n == b.n || error("Cannot multiply elements from different Dihedral groups") | ||
id = mod(a.reflection ? a.id - b.id : a.id + b.id, a.n) | ||
return DihedralElement(a.n, a.reflection != b.reflection, id) | ||
end | ||
|
||
Base.copy(a::DihedralElement) = DihedralElement(a.n, a.reflection, a.id) | ||
|
||
# optional functions: | ||
function GroupsCore.order(T::Type, el::DihedralElement) | ||
if el.reflection | ||
return T(2) | ||
else | ||
if iszero(el.id) | ||
return T(1) | ||
else | ||
return T(div(el.n, gcd(el.n, el.id))) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.