Skip to content

Commit

Permalink
added on_indeterminates for matrix action (#1367)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBreuer committed Jun 3, 2022
1 parent 01a4a72 commit ca55722
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
36 changes: 34 additions & 2 deletions src/Groups/action.jl
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,13 @@ end
"""
on_indeterminates(f::GAP.GapObj, p::PermGroupElem)
on_indeterminates(f::Nemo.MPolyElem, p::PermGroupElem)
on_indeterminates(f::GAP.GapObj, p::MatrixGroupElem)
on_indeterminates(f::Nemo.MPolyElem{T}, p::MatrixGroupElem{T, S}) where T where S
Return the image of `f` under `p`, w.r.t. permuting the indeterminates
with `p`.
Return the image of `f` under `p`.
If `p` is a `PermGroupElem` then it acts via permuting the indeterminates,
if `p` is a `MatrixGroupElem` then it acts via evaluating `f` at the
vector obtained by multiplying `p` with the (column) vector of indeterminates.
For `Nemo.MPolyElem` objects, one can also call `^` instead of
`on_indeterminates`.
Expand All @@ -324,6 +328,18 @@ GAP: x_1*x_2+x_2*x_3
julia> on_indeterminates(f, p)
GAP: x_1*x_3+x_2*x_3
julia> g = general_linear_group(2, 5); m = g[2]
[4 1]
[4 0]
julia> R, x = PolynomialRing(base_ring(g), degree(g));
julia> f = x[1]*x[2] + x[1]
x1*x2 + x1
julia> f^m
x1^2 + 4*x1*x2 + 4*x1 + x2
```
"""
on_indeterminates(f::GAP.GapObj, p::PermGroupElem) = GAP.Globals.OnIndeterminates(f, p.X)
Expand All @@ -343,8 +359,24 @@ function on_indeterminates(f::Nemo.MPolyElem, s::PermGroupElem)
return finish(g)
end

function on_indeterminates(f::GAP.GapObj, p::MatrixGroupElem)
# We assume that we act on the indeterminates with numbers 1, ..., nrows(p).
# (Note that `f` does not know about a polynomial ring to which it belongs.)
n = nrows(p)
fam = GAP.Globals.CoefficientsFamily(GAP.Globals.FamilyObj(f))
indets = GAP.GapObj([GAP.Globals.Indeterminate(fam, i) for i in 1:n])
return GAP.Globals.Value(f, indets, p.X * indets)
end

function on_indeterminates(f::Nemo.MPolyElem{T}, p::MatrixGroupElem{T, S}) where T where S
act = Oscar.right_action(parent(f), p)
return act(f)
end

^(f::Nemo.MPolyElem, p::PermGroupElem) = on_indeterminates(f, p)

^(f::Nemo.MPolyElem{T}, p::MatrixGroupElem{T, S}) where T where S = on_indeterminates(f, p)


@doc Markdown.doc"""
stabilizer(G::Oscar.GAPGroup, pnt::Any[, actfun::Function])
Expand Down
46 changes: 46 additions & 0 deletions test/Groups/action.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,49 @@ end
@test S[1] == stabilizer(G, Set(gens(V)), on_sets)[1]

end

@testset "action on multivariate polynomials: permutations" begin
g = symmetric_group(3)
R, vars = PolynomialRing(QQ, 3);
(x1, x2, x3) = vars
f = x1*x2 + x2*x3
iso = Oscar.iso_oscar_gap(R)
img = iso(f)

for p in [g(cperm(1:3)), g(cperm(1:2))]
@test f^p == evaluate(f, permuted(vars, p^-1))
@test on_indeterminates(img, p) == iso(f^p)
end

for x in gens(g)
for y in gens(g)
@test on_indeterminates(on_indeterminates(f, x), y) == on_indeterminates(f, x*y)
end
end
end

@testset "action on multivariate polynomials: matrices" begin
g = general_linear_group(3, 5)
R, vars = PolynomialRing(base_ring(g), degree(g))
(x1, x2, x3) = vars
f = x1*x2 + x2*x3

# permutation matrix
p = cperm(1:3)
m = g(permutation_matrix(base_ring(g), p))
@test f^p == x1*x3 + x2*x3
@test f^m == f^p
iso = Oscar.iso_oscar_gap(R)
img = iso(f)
@test on_indeterminates(img, m) == iso(f^m)

# non-permutation matrix
m = g(matrix(base_ring(g), 3, 3, [3, 0, 2, 4, 0, 0, 0, 4, 0]))
@test f^m == 2*x1^2 + x1*x2 + 3*x1*x3

for x in gens(g)
for y in gens(g)
@test on_indeterminates(on_indeterminates(f, x), y) == on_indeterminates(f, x*y)
end
end
end

0 comments on commit ca55722

Please sign in to comment.