Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
galettof committed Jul 8, 2022
2 parents 2afa6f2 + 10f7e4f commit 562a214
Show file tree
Hide file tree
Showing 11 changed files with 245 additions and 207 deletions.
47 changes: 45 additions & 2 deletions Demo.m2
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ isInvariant((J.gens)_(0,0),L)
restart
needsPackage "InvariantRing"
R = QQ[x_1..x_4]
L = apply({"2134","2341"},permutationMatrix);
L = apply({[2,1,3,4],[2,3,4,1]},permutationMatrix);
S4 = finiteAction(L,R)
elapsedTime invariants S4
elapsedTime invariants(S4,UseLinearAlgebra=>true)
elapsedTime invariants(S4,Strategy=>"LinearAlgebra")
elapsedTime p=primaryInvariants S4
elapsedTime secondaryInvariants(p,S4)
elapsedTime hironakaDecomposition(S4)
Expand Down Expand Up @@ -159,3 +159,46 @@ M=transpose (
)
d=discriminant det M
ideal d==ideal first inv


-- 2x2 conjugation invariants
restart
needsPackage "InvariantRing"
S = QQ[g_(1,1)..g_(2,2),t]
I = ideal((det genericMatrix(S,2,2))*t-1)
Q = S/I
A = Q[y_(1,1)..y_(2,2)]
Y = transpose genericMatrix(A,2,2)
-- generic group element
g = promote(genericMatrix(S,2,2),A)
-- act by conjugation on a 2x2 generic matrix
-- get corresponding action of 1x4 matrix of variables
G = reshape(A^1,A^4,g*Y*inverse(g)) // (vars A)
G = lift(map(A^4,A^4,G),S)

R = QQ[x_(1,1)..x_(2,2)]
L=linearlyReductiveAction(I,G,R)
elapsedTime H=hilbertIdeal(L)
elapsedTime invariants L


-- 3x3 conjugation invariants
restart
needsPackage "InvariantRing"
S = QQ[g_(1,1)..g_(3,3),t]
I = ideal((det genericMatrix(S,3,3))*t-1)
Q = S/I
A = Q[y_(1,1)..y_(3,3)]
Y = transpose genericMatrix(A,3,3)
-- generic group element
g = promote(genericMatrix(S,3,3),A)
-- act by conjugation on a 2x2 generic matrix
-- get corresponding action of 1x4 matrix of variables
G = reshape(A^1,A^9,g*Y*inverse(g)) // (vars A)
G = lift(map(A^9,A^9,G),S)
R = QQ[x_(1,1)..x_(3,3)]
L=linearlyReductiveAction(I,G,R)
elapsedTime H=hilbertIdeal(L)
elapsedTime invariants(L,1)
elapsedTime invariants(L,2)
elapsedTime invariants(L,3)
48 changes: 29 additions & 19 deletions InvariantRing.m2
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

newPackage(
"InvariantRing",
Version => "2.1",
Date => "July 9, 2021",
Version => "2.2",
Date => "July 8, 2022",
Authors => {
{Name => "Luigi Ferraro",
Email => "[email protected]",
Expand All @@ -30,7 +30,7 @@ newPackage(
},
{Name => "Thomas Hawes", Email => "[email protected]"},
{Name => "Matthew Mastroeni",
Email => "mmastro@okstate.edu",
Email => "mmastro@iastate.edu",
HomePage => "https://mnmastro.github.io/"
},
{Name => "Xianglong Ni",
Expand All @@ -52,43 +52,54 @@ newPackage(
"volume URI" => "http://j-sag.org/Volume5/"
},
AuxiliaryFiles => true,
DebuggingMode => false
DebuggingMode => false,
PackageExports => {
"Graphs"
}
)



export {
"GroupAction",
"finiteAction",
"FiniteGroupAction",
-- New Types
"GroupAction",
"FiniteGroupAction",
"DiagonalAction",
"LinearlyReductiveAction",

--FiniteGroups.m2
"finiteAction",
"group",
"isAbelian",
"permutationMatrix",
"schreierGraph",
"words",
"cyclicFactors",
"DiagonalAction",
"words",

--AbelianGroups.m2
"cyclicFactors",
"diagonalAction",
"equivariantHilbert",
"equivariantHilbertSeries",
"weights",
"weights",

--LinearlyReductiveGroups.m2
"actionMatrix",
"groupIdeal",
"hilbertIdeal",
"linearlyReductiveAction",
"LinearlyReductiveAction",
"linearlyReductiveAction",

--Invariants.m2
"action",
"definingIdeal",
"DegreeBound",
"invariants",
"invariantRing",
"isInvariant",
"reynoldsOperator",
"UseLinearAlgebra",
"reynoldsOperator",
"RingOfInvariants",
"UseCoefficientRing",
"UseNormaliz",
"UsePolyhedra",
"UseCoefficientRing",

--Hawes.m2
"hironakaDecomposition",
"molienSeries",
"primaryInvariants",
Expand All @@ -98,7 +109,6 @@ export {
"PrintDegreePolynomial"
}


needsPackage("Elimination")
needsPackage("Normaliz")
needsPackage("Polyhedra")
Expand Down
4 changes: 4 additions & 0 deletions InvariantRing/AbelianGroups.m2
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ equivariantHilbertSeries DiagonalAction := op -> T -> (
)
)

-- computes equivariant hilbert series as rational function
-- INPUT: T, DiagonalAction
equivariantHilbertRational = T -> (
n := dim T;
W1 := first weights T;
Expand All @@ -143,6 +145,8 @@ equivariantHilbertRational = T -> (
Divide{1,den}
)

-- computes equivariant hilbert series up to a given degree
-- INPUT: T, DiagonalAction
equivariantHilbertPartial = (T, d) -> (
if not T.cache.?equivariantHilbert then (
T.cache.equivariantHilbert = 1_(degreesRing T);
Expand Down
124 changes: 52 additions & 72 deletions InvariantRing/FiniteGroups.m2
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,26 @@ numgens FiniteGroupAction := ZZ => G -> G.numgens

-------------------------------------------

isAbelian = method()
isAbelian = method(Options => true)

isAbelian FiniteGroupAction := { } >> opts -> (cacheValue (symbol isAbelian)) (G -> runHooks(FiniteGroupAction, symbol isAbelian, G) )
isAbelian FiniteGroupAction := { } >> opts -> (cacheValue (symbol isAbelian)) (
G -> runHooks((isAbelian, FiniteGroupAction), G) )


addHook(FiniteGroupAction, symbol isAbelian, G -> break (
addHook((isAbelian, FiniteGroupAction), G -> (
X := G.generators;
n := #X;
if n == 1 then(
true
)
else(
all(n - 1, i -> all(n - 1 - i, j -> (X#j)*(X#(n - 1 - i)) == (X#(n - 1 - i))*(X#j) ) )
)
))
if n == 1 then true
else all(n - 1, i -> all(n - 1 - i, j -> (X#j)*(X#(n - 1 - i)) == (X#(n - 1 - i))*(X#j) ) )
))



generateGroup = method()
generateGroup = method(Options => true)

generateGroup FiniteGroupAction := { } >> opts -> (cacheValue (symbol generateGroup)) (G -> runHooks(FiniteGroupAction, symbol generateGroup, G) )
generateGroup FiniteGroupAction := {} >> opts -> (cacheValue (symbol generateGroup)) (G -> runHooks((generateGroup, FiniteGroupAction), G) )

addHook(FiniteGroupAction, symbol generateGroup, G -> break (
addHook((generateGroup, FiniteGroupAction), G -> (
m := numgens G;
n := dim G;
K := coefficientRing ring G;
Expand Down Expand Up @@ -111,40 +108,37 @@ addHook(FiniteGroupAction, symbol generateGroup, G -> break (

-------------------------------------------

schreierGraph = method()
schreierGraph = method(Options => true)

schreierGraph FiniteGroupAction := { } >> opts -> (cacheValue (symbol schreierGraph)) (G -> runHooks(FiniteGroupAction, symbol schreierGraph, G) )
schreierGraph FiniteGroupAction := {} >> opts -> (cacheValue (symbol schreierGraph)) (G -> runHooks((schreierGraph, FiniteGroupAction), G) )

addHook(FiniteGroupAction, symbol schreierGraph,
G -> break (generateGroup G)_0
)
addHook((schreierGraph, FiniteGroupAction), G -> (generateGroup G)_0 )


-------------------------------------------

group = method()
group = method(Options => true)

group FiniteGroupAction := { } >> opts -> (cacheValue (symbol group)) (G -> runHooks(FiniteGroupAction, symbol group, G) )
group FiniteGroupAction := { } >> opts -> (cacheValue (symbol group)) (G -> runHooks((group, FiniteGroupAction), G) )

addHook((group, FiniteGroupAction), G -> keys first schreierGraph G )

addHook(FiniteGroupAction, symbol group,
G -> break keys first schreierGraph G
)

-------------------------------------------

words = method()
words = method(Options => true)

words FiniteGroupAction := { } >> opts -> (cacheValue (symbol words)) (G -> runHooks(FiniteGroupAction, symbol words, G) )
words FiniteGroupAction := { } >> opts -> (cacheValue (symbol words)) (G -> runHooks((words, FiniteGroupAction), G) )

addHook((words, FiniteGroupAction), G -> applyValues((generateGroup G)_1, val -> first val) )

addHook(FiniteGroupAction, symbol words,
G -> break applyValues((generateGroup G)_1, val -> first val)
)

-------------------------------------------

relations FiniteGroupAction := { } >> opts -> (cacheValue (symbol relations)) (G -> runHooks(FiniteGroupAction, symbol relations, G) )
relations FiniteGroupAction := { } >> opts -> (cacheValue (symbol relations)) (
G -> runHooks((relations, FiniteGroupAction), G) )

addHook(FiniteGroupAction, symbol relations, G -> break (
addHook((relations, FiniteGroupAction), G -> (
relators := values last generateGroup G;
W := apply(relators, r -> first r);
relators = flatten apply(#W, i -> apply(drop(relators#i, 1), a -> {W#i,a} ) );
Expand All @@ -159,57 +153,43 @@ addHook(FiniteGroupAction, symbol relations, G -> break (
unique relators
))


-------------------------------------------

permutationMatrix = method()
permutationMatrix = method(Options => {EntryMode => "one-line"})

permutationMatrix String := Matrix => s -> (
n := #s;
p := apply(n, i -> (
v := value(s#i);
if v <= 0 or v > n then (
error "permutationMatrix: Expected a string of positive integers
representing a permutation."
)
else v
)
);
if #(unique p) =!= n then (
error "permutationMatrix: Expected a string of distinct integers."
);
matrix apply(n, i ->
apply(n, j -> if p#j - 1 == i then 1 else 0)
permutationMatrix Array := Matrix => opts -> p -> (
if opts.EntryMode == "cycle" then permutationMatrix(max p, p)
else (
n := max p;
if #p =!= n or set (1..n) =!= set p then (
error "permutationMatrix: Expected a sequence of positive integers
representing a permutation."
);
matrix apply(n, i -> apply(n, j -> if p#j - 1 == i then 1 else 0) )
)
)

permutationMatrix (ZZ, Array) := Matrix => (n, c) -> permutationMatrix(n, {c})

permutationMatrix (ZZ, List) := Matrix => (n, p) -> (
if n <= 0 then (error "permutationMatrix: Expected the first input to be a positive integer.");
if any(p, c -> not instance(c, Array) or any(c, i -> i <= 0 or i > n)) then (
error "permutationMatrix: Expected the second input to be a list of arrays
with integer entries between 1 and the first input."
permutationMatrix (ZZ, Array) := Matrix => opts -> (n, c) -> (
if n <= 0 then error "permutationMatrix: Expected a positive integer.";
if #c == 0 then error "permutationMatrix: Expected a nonempty array,";
if #(set c) =!= #c or not isSubset(set c, set(1..n)) then (
error "permutationMatrix: Expected an array of distinct integers
between 1 and the first input."
);
if any(p, c -> #(unique toList c) =!= #c) then (error "permutationMatrix: Expected each sequence in
the list to have distinct entries.");
s := new MutableHashTable from apply(n, i -> i + 1 => i + 1);
scan(p, c -> (
k := #c;
u := hashTable pairs s;
scan(k, j -> (
if j < k - 1 then s#(c_j) = u#(c_(j+1))
else s#(c_j) = u#(c_0)
)
)
permutationMatrix new Array from apply(n, i ->
if (set c)#?(i + 1) then (
k := position(c, j -> j == i + 1);
if k == #c - 1 then c#0 else c#(k + 1)
)
);
s = horizontalJoin apply(values s, i -> toString i);
permutationMatrix toString s
)

permutationMatrix Array := Matrix => c -> permutationMatrix(max c, c)
else i + 1
)
)

permutationMatrix (ZZ, List) := Matrix => opts -> (n, p) -> product apply(p, c -> permutationMatrix(n, c) )

permutationMatrix List := Matrix => p -> permutationMatrix(max (p/max), p)
permutationMatrix List := Matrix => opts -> p -> permutationMatrix(max (p/max), p)




Expand Down
Loading

0 comments on commit 562a214

Please sign in to comment.