source: git/Singular/LIB/gitfan.lib @ 428669

spielwiese
Last change on this file since 428669 was 428669, checked in by Hans Schoenemann <hannes@…>, 5 years ago
fix: example autXhat
  • Property mode set to 100644
File size: 87.8 KB
Line 
1////////////////////////////////////////////////////////////////////
2version="version gitfan.lib 4.1.2.0 Feb_2019 ";
3category="Algebraic Geometry";
4info="
5LIBRARY:   gitfan.lib       Compute GIT-fans.
6
7AUTHORS: Janko Boehm, boehm at mathematik.uni-kl.de @*
8         Simon Keicher, keicher at mail.mathematik.uni-tuebingen.de @*
9         Yue Ren, ren at mathematik.uni-kl.de @*
10
11OVERVIEW:
12This library allows you to calculate GIT-fans, torus orbits and GKZ-fans.
13
14In provides features to make use of symmetries of the torus action under consideration.
15
16The main procedure is GITfan which can be directly applied to an ideal and a grading matrix
17encoding the torus action, and returns a fan, the associated GIT-fan.
18We also provide various procedures implementing substeps of the algorithm
19to deal with large computations.
20
21The library uses the package 'gfanlib' by Anders N. Jensen.
22
23For notation, background, and algorithms see [BKR16].
24
25Functions produce debug output if printlevel is positive.
26
27Elements of the symmetric group Sn of type permutation can be created by
28the function permutationFromIntvec.
29The images of 1,...,n can be obtained by permutationToIntvec.
30Composition of permutations can be done by the *-Operator,
31also powers can be computed in the usual way.
32
33
34REFERENCES:
35
36[BKR16] J. Boehm, S. Keicher, Y. Ren: Computing GIT-Fans with Symmetry and the Mori Chamber Decomposition of M06bar,  https://arxiv.org/abs/1603.09241
37
38TYPES:
39  permutation; Permutation in map representation.
40
41PROCEDURES:
42  isAface(ideal,intvec); Checks whether the given face is an a-face.
43  afaces(ideal); Returns a list of intvecs that correspond to the set of all a-faces, optionally for given list of simplex faces.
44  fullDimImages(list,intmat); Finds the afaces which have a full-dimensional projection.
45  minimalAfaces(list); compute the minimal a-faces among the a-faces with full dimensional projection.
46  orbitCones(list,intmat); Returns the list of all orbit cones.
47  GITcone(list,bigintmat); Returns the GIT-cone containing the given weight vector.
48  GITfan(ideal,intmat); Compute GIT-fan.
49  GITfanFromOrbitCones(list,intmat,cone); Compute GIT-fan from orbit cones.
50  GITfanParallel(list,intmat,cone); Compute GIT-fan in parallel from orbit cones.
51  GKZfan(intmat); Returns the GKZ-fan of the matrix Q.
52  movingCone(intmat); Compute the moving cone.
53  computeAfaceOrbits(list,list); Compute orbits of a-faces under a permutation group action.
54  minimalAfaceOrbits(list); Find the minimal a-face orbits.
55  orbitConeOrbits(list,intmat); Project the a-face orbits to orbit cone orbits.
56  minimalOrbitConeOrbits(list); Find the minimal orbit cone orbits.
57  intersectOrbitsWithMovingCone(list,cone); Intersect orbit cone orbits with moving cone.
58  groupActionOnQImage(list,intmat); Determine the induced group action in the target of the grading matrix.
59  groupActionOnHashes(list,list); Determine the induced group action on the set of orbit cones.
60  storeActionOnOrbitConeIndices(list, string); Write the group action on the set of orbit cones to a file.
61  permutationFromIntvec(intvec); Create a permutation from an intvec of images.
62  permutationToIntvec(permutation); Return the intvec of images.
63  evaluateProduct(list,list); Evaluate a list of products of group elements in terms of a given representation of the elements as permutations.
64  GITfanSymmetric(list,intmat,cone,list); Compute GIT-fan from orbit cones by determining a minimal representing set for the orbits of maximal dimensional GIT-cones.
65  GITfanParallelSymmetric(list, intmat, cone, list); Compute GIT-fan in parallel from orbit cones by determining a minimal representing set for the orbits of maximal dimensional GIT-cones.
66  bigintToBinary(bigint,int); Convert bigint into a sparse binary represenation specifying the indices of the one-entries
67  binaryToBigint(intvec); Convert sparse binary represenation specifying the indices of the one-entries to bigint
68  applyPermutationToIntvec(intvec,permutation); Apply permutation to a set of integers represented as an intvec
69  hashToCone(bigint,list); Convert a bigint hash to a GIT-cone
70  hashesToFan(list hashes,list OC)
71gitCone(ideal,bigintmat,bigintmat); Returns the GIT-cone around the given weight vector w
72
73KEYWORDS: library, gitfan, GIT, geometric invariant theory, quotients
74";
75
76
77LIB "customstd.lib";
78LIB "linalg.lib";
79LIB "multigrading.lib";
80LIB "parallel.lib";
81
82static proc mod_init()
83{
84  LIB "gfanlib.so";
85  LIB "gitfan.so";
86  //LIB "subsets.so";
87  newstruct("permutation","intvec image");
88  system("install","permutation","*",composePermutations,2);
89  system("install","permutation","^",permutationPower,2);
90  system("install","permutation","print",printPermutation,1);
91}
92
93static proc emptyString(int n)
94{
95string st;
96for (int i = 1; i<=n;i++){
97  st=st+" ";
98}
99return(st);}
100
101proc printPermutation(permutation sigma)
102{
103 intvec v = permutationToIntvec(sigma);
104 string vsrc,vimg;
105 for (int i = 1; i<=size(v);i++){
106   vsrc=vsrc+emptyString(1+size(string(size(v)))-size(string(i)))+string(i);
107 }
108 for (i = 1; i<=size(v);i++){
109   vimg=vimg+emptyString(1+size(string(size(v)))-size(string(v[i])))+string(v[i]);
110 }
111 print("|"+vsrc+"|");
112 print("|"+vimg+"|");
113}
114
115
116////////////////////////////////////////////////////
117// converts e.g. n=5 to its binary representation, i.e. 0,1,0,1
118// if r = 3.
119// and stores it in an intvec.
120// r gives the bound for n <= 2^r:
121static proc int2face(int n, int r)
122{
123  int k = r-1;
124  intvec v;
125  int n0 = n;
126
127  while(n0 > 0){
128    while(2^k > n0){
129      k--;
130      //v[size(v)+1] = 0;
131    }
132
133    v = k+1,v;
134    n0 = n0 - 2^k;
135    k--;
136  }
137  v = v[1..size(v)-1];
138  return(v);
139}
140example
141{
142  echo = 2;
143  int n = 5;
144  int r = 4;
145  int2face(n, r);
146
147  n = 1;
148  r = 1;
149  int2face(n,r);
150}
151
152////////
153
154
155
156////////////////////////////////////////////////////
157
158proc afaces(ideal a, list #)
159"USAGE: afaces(a [,L]); a: ideal, L: list of intvecs
160PURPOSE: Returns a list of all a-faces (considered as intvecs of 0 and 1, where the i-th entry is 1 if the cone has the i-th unit basis vector as a generator), if L is specified only the faces of the simplex listed in L are considered (e.g. representatives with respect to a group action).
161RETURN: a list of intvecs
162EXAMPLE: example afaces; shows an example
163"
164{
165  list AF;
166  if ((size(#)>0) and (typeof(#[1])=="intvec")){
167    list L = #;
168    for(int i = 1; i<=size(L); i++ ){
169      dbprint("representative "+string(i)+" of "+string(size(L)));
170      if (isAface(a,L[i])){
171        AF[size(AF) + 1] = L[i];
172      }
173    }
174    return(AF);
175  }
176
177  intvec gam0;
178  int r = nvars(basering);
179
180  // check if 0 is an a-face:
181  int bd;
182  if (size(#)>0){bd=#[1];}
183  gam0 = 0;
184  if (size(gam0)>=bd){
185    if (isAface(a,gam0)){
186      AF[size(AF) + 1] = gam0;
187    }
188  }
189  // check for other a-faces:
190  for(int i = 1; i < 2^r; i++ ){
191    gam0 = int2face(i,r);
192    if (size(gam0)>=bd){
193      if (isAface(a,gam0)){
194        AF[size(AF) + 1] = gam0;
195      }
196    }
197  }
198
199  //"done checking a-faces!";
200  return(AF);
201}
202example
203{
204
205  echo = 2;
206  ring R = 0,T(1..3),dp;
207  ideal a = T(1)+T(2)+T(3);
208
209  list F = afaces(a);
210  print(F);
211  print(size(F));
212
213  // 2nd ex //
214  ring R2 = 0,T(1..3),dp;
215  ideal a2 = T(2)^2*T(3)^2+T(1)*T(3);
216
217  list F2 = afaces(a2);
218  print(F2);
219  print(size(F2));
220
221  // 3rd ex //
222  ring R3 = 0,T(1..3),dp;
223  ideal a3 = 0;
224
225  list F3 = afaces(a3);
226  print(F3);
227  print(size(F3));
228
229
230  // 4th ex //
231  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
232  ideal J =
233    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
234    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
235    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
236    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
237    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
238  list F4 = afaces(J);
239  print(size(F4));
240}
241
242
243
244static proc saturateWithRespectToVariable(ideal I, int k)
245{
246  // "saturating with respect to variable "+string(k);
247  ASSUME(1,k>=1);
248  ASSUME(1,k<=nvars(basering));
249
250  def origin = basering;
251  int n = nvars(basering);
252  intvec weightVector = ringlist(origin)[3][1][2];
253
254  string newVars;
255  intvec newWeightVector;
256  for (int i=1; i<k; i++)
257  {
258    newVars = newVars+string(var(i))+",";
259    newWeightVector[i]=weightVector[i];
260  }
261  for (i=k+1; i<=n; i++)
262  {
263    newVars = newVars+string(var(i))+",";
264    newWeightVector[i-1]=weightVector[i];
265  }
266  newVars = newVars+string(var(k));
267  newWeightVector[n]=weightVector[k];
268  execute("ring ringForSaturation = ("+charstr(origin)+"),("+newVars+"),(wp(newWeightVector));");
269
270  ideal I = satstd(imap(origin,I));
271  I = simplify(I,2+4+32);
272
273  // "finished saturating with respect to variable "+string(k);
274  setring origin;
275  return (imap(ringForSaturation,I));
276}
277
278static proc stepwiseSaturation(ideal I)
279{
280  if (I!=1)
281  {
282    list variablesToBeSaturated;
283    int l = nvars(basering);
284    for (int i=1; i<=l; i++)
285    { variablesToBeSaturated[i]=l-i+1; }
286
287    while (size(variablesToBeSaturated)>0)
288    {
289      I = saturateWithRespectToVariable(I,variablesToBeSaturated[1]);
290      variablesToBeSaturated = delete(variablesToBeSaturated,1);
291      if ((I==1) || (I==-1))
292      {
293        break;
294      }
295    }
296  }
297
298  return (I);
299}
300
301
302
303
304
305
306proc isAface(ideal a, intvec gam0)
307  "USAGE: isAface(a,gam0); a: ideal, gam0:intvec
308PURPOSE: Checks whether gam0 is an a-face w.r.t. the ideal a.
309RETURN: int
310EXAMPLE: example isaface; shows an example
311"
312{
313  // special case: gam0 is the zero-cone:
314  if (size(gam0) == 1 and gam0[1] == 0){
315    poly pz;
316    ideal G;
317    int i;
318    for (int k = 1; k <= size(a); k++) {
319      pz = subst(a[k], var(1), 0);
320      for (i = 2; i <= nvars(basering); i++) {
321        pz = subst(pz, var(i), 0);
322      }
323      G = G, pz;
324    }
325    G = std(G);
326    // monomial inside?:
327    if(G == 1){
328      return(0);
329    }
330    return(1);
331  }
332
333  string initNewRing = "ring Rgam0 = 0,(";
334
335  intvec w = ringlist(basering)[3][1][2];
336  intvec w0;
337  for (int i=1; i<size(gam0); i++)
338  {
339    // take only entries i of w0 with i in gam0
340    initNewRing = initNewRing + string(var(gam0[i])) + ",";
341    w0[i] = w[gam0[i]];
342  }
343  w0[size(gam0)] = w[gam0[size(gam0)]];
344
345  initNewRing = initNewRing + string(var(gam0[size(gam0)])) + "),wp(w0);";
346  def R = basering;
347  execute(initNewRing);
348
349  ideal agam0 = imap(R,a);
350
351  ideal G = stepwiseSaturation(agam0);
352
353  if(G == 1)
354  {
355    return(0); // true
356  }
357  return(1); // false
358}
359example
360{
361  echo = 2;
362
363  ring R = 0,(T(1..4)),dp;
364  ideal I = T(1)*T(2)-T(4);
365
366  intvec w = 1,4;
367  intvec v = 1,2,4;
368
369  isAface(I,w); // should be 0
370  isAface(I,v); // should be 1
371}
372
373
374proc applyPermutationToIntvec(intvec v, permutation g)
375"USAGE: applyPermutationToIntvec(v,g); v: intvec, g:permutation
376PURPOSE: Apply g to the set of entries of v. The result is a sorted intvec. We assume that the entries of v are valid arguments of g. We do not require that the input is sorted.
377RETURN: intvec.
378EXAMPLE: example applyPermutationToIntvec; shows an example
379"
380{
381  intvec gv = composeIntvecs(permutationToIntvec(g),v);
382  //for (int i=1;i<=size(v);i++){
383  //  gv[i]=g[v[i]];
384  //}
385  return(sort(gv)[1]);
386}
387example
388{
389permutation g = permutationFromIntvec(intvec(10, 9, 7, 4, 8, 6, 3, 5, 2, 1));
390applyPermutationToIntvec(intvec(1, 3, 4, 6, 8),g);
391}
392
393static proc isContained(intvec v, list orbit){
394  for (int i=1;i<=size(orbit);i++){
395    if (v==orbit[i]){return(1);}
396  }
397  return(0);
398}
399
400
401static proc computeSimplexOrbit(intvec v, list G){
402  list orbit;
403  intvec gv;
404  for (int i=1;i<=size(G);i++){
405    gv=applyPermutationToIntvec(v,G[i]);
406    if (isContained(gv,orbit)==0){orbit[size(orbit)+1]=gv;}
407  }
408  return(orbit);
409}
410
411
412proc computeAfaceOrbits(list AF, list G)
413  "USAGE: computeAfaceOrbits(AF,G); AF list of intvecs, G: list of permutations
414PURPOSE: Computes the orbits of the afaces in the list AF under the group action in G, where G is a list of permutations. We assume that the elements of G form a group and the first entry corresponds to the neutral element.
415RETURN: a list of lists of intvecs
416EXAMPLE: example computeAfaceOrbits; shows an example
417"
418{
419  list listorbits;
420  for (int i=1;i<=size(AF);i++){
421    dbprint(i);
422    listorbits[i]=computeSimplexOrbit(AF[i],G);
423  }
424  return(listorbits);}
425example
426{
427  echo = 2;
428  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
429  ideal J =
430    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
431    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
432    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
433    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
434    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
435  intmat Q[5][10] =
436    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
437    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
438    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
439    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
440    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
441  list simplexSymmetryGroup = G25Action();
442  list simplexOrbitRepresentatives = intvec( 1, 2, 3, 4, 5 ),
443  intvec( 1, 2, 3, 5, 6 ),
444  intvec( 1, 2, 3, 5, 7 ),
445  intvec( 1, 2, 3, 5, 10 ),
446  intvec( 1, 2, 3, 7, 9 ),
447  intvec( 1, 2, 6, 9, 10 ),
448  intvec( 1, 2, 3, 4, 5, 6 ),
449  intvec( 1, 2, 3, 4, 5, 10 ),
450  intvec( 1, 2, 3, 5, 6, 8 ),
451  intvec( 1, 2, 3, 5, 6, 9 ),
452  intvec( 1, 2, 3, 5, 7, 10 ),
453  intvec( 1, 2, 3, 7, 9, 10 ),
454  intvec( 1, 2, 3, 4, 5, 6, 7 ),
455  intvec( 1, 2, 3, 4, 5, 6, 8 ),
456  intvec( 1, 2, 3, 4, 5, 6, 9 ),
457  intvec( 1, 2, 3, 5, 6, 9, 10 ),
458  intvec( 1, 2, 3, 4, 5, 6, 7, 8 ),
459  intvec( 1, 2, 3, 4, 5, 6, 9, 10 ),
460  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9 ),
461  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
462  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
463  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
464  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
465  apply(afaceOrbits,size);}
466
467
468
469
470static proc isSubset(intvec v, intvec w)
471{
472  int i,j;
473  int jStart=1;
474  for (i=1; i<=size(v); i++)
475  {
476    for (j=jStart; j<=size(w); j++)
477    {
478      if (v[i]==w[j])
479      {
480        break;
481      }
482    }
483    if (j<=size(w))
484    {
485      jStart = j+1;
486    }
487    else
488    {
489      return (0);
490    }
491  }
492  return (1);
493}
494
495
496
497static proc containsOrbitd(list A, list B)
498{
499  intvec a = A[1];
500  for (int i=1; i<=size(B); i++)
501  {
502    if (isSubset(a,B[i]))
503    {
504      return (1);
505    }
506  }
507  return (0);
508}
509
510
511proc minimalAfaceOrbits(list listOfOrbits)
512"USAGE: minimalAfaceOrbits(afaceOrbits); afaceOrbits: list
513PURPOSE: Returns a list of all minimal a-face orbits.
514RETURN: a list of intvecs
515EXAMPLE: example minimalAfaceOrbits; shows an example
516"
517{
518  int i,j;
519  list L = listOfOrbits;
520  for (i=1; i<=size(L); i++)
521  {
522    dbprint(string(i)+" of "+string(size(L)));
523    for (j=1; j<=size(L); j++)
524    {
525      if (i!=j)
526      {
527        if (containsOrbitd(L[i],L[j]))
528        {
529          dbprint("werfe raus (Laenge):  " + string(size(L[j])));
530          L = delete(L,j);
531          if (j<i)
532          {
533            i = i-1;
534          }
535          j = j-1;
536        }
537      }
538    }
539  }
540  return(L);
541}
542example
543{
544  echo = 2;
545  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
546  ideal J =
547    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
548    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
549    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
550    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
551    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
552  intmat Q[5][10] =
553    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
554    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
555    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
556    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
557    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
558  list simplexSymmetryGroup = G25Action();
559  list simplexOrbitRepresentatives = intvec( 1, 2, 3, 4, 5 ),
560  intvec( 1, 2, 3, 5, 6 ),
561  intvec( 1, 2, 3, 5, 7 ),
562  intvec( 1, 2, 3, 5, 10 ),
563  intvec( 1, 2, 3, 7, 9 ),
564  intvec( 1, 2, 6, 9, 10 ),
565  intvec( 1, 2, 3, 4, 5, 6 ),
566  intvec( 1, 2, 3, 4, 5, 10 ),
567  intvec( 1, 2, 3, 5, 6, 8 ),
568  intvec( 1, 2, 3, 5, 6, 9 ),
569  intvec( 1, 2, 3, 5, 7, 10 ),
570  intvec( 1, 2, 3, 7, 9, 10 ),
571  intvec( 1, 2, 3, 4, 5, 6, 7 ),
572  intvec( 1, 2, 3, 4, 5, 6, 8 ),
573  intvec( 1, 2, 3, 4, 5, 6, 9 ),
574  intvec( 1, 2, 3, 5, 6, 9, 10 ),
575  intvec( 1, 2, 3, 4, 5, 6, 7, 8 ),
576  intvec( 1, 2, 3, 4, 5, 6, 9, 10 ),
577  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9 ),
578  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
579  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
580  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
581  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
582  apply(afaceOrbits,size);
583  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
584  apply(minAfaceOrbits,size);
585}
586
587
588static proc list2string(list L){
589  string s = "";
590
591  for(int i = 1; i <=size(L); i++){
592    s = s + string(size(L[i])) + ", ";
593  }
594
595  return(s);
596}
597
598
599
600proc fullDimImages(list afaces,intmat Q)
601"USAGE: fullDimImages(afaces, Q); afaces: list, Q: intmat
602PURPOSE: Determines the a-faces (represented as intvecs) from the list afaces which have a full-dimensional projection with respect to Q.
603RETURN: a list of intvecs
604EXAMPLE: example fullDimImages; shows an example
605"
606{
607  list L;
608  for (int i=1; i<=size(afaces); i++)
609  {
610          intvec gam0 = afaces[i];
611          intmat Qgam0[nrows(Q)][size(gam0)] = Q[intvec(1..nrows(Q)),gam0];
612          //cone c = coneViaPoints(Qgam0);
613          if(rank(Qgam0) == nrows(Q)){
614      L[size(L)+1]=afaces[i];
615    }
616    kill gam0,Qgam0;
617  }
618  return(L);
619}
620example
621{
622  echo=2;
623  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
624  ideal J =
625    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
626    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
627    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
628    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
629    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
630  intmat Q[5][10] =
631    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
632    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
633    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
634    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
635    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
636
637  list AF= afaces(J,nrows(Q));
638  size(AF);
639  size(fullDimImages(AF,Q));
640}
641
642
643
644
645proc orbitConeOrbits(list F, intmat Q)
646"USAGE: orbitConeOrbits(F, Q); F: list, Q: intmat
647PURPOSE: Projects a list F of a-face orbits to the orbit cones with respect to Q. The function checks whether the projections are of full dimension and returns an error otherwise.
648RETURN: a list of lists of cones
649EXAMPLE: example orbitConeOrbits; shows an example
650"
651{
652  list OC;
653  int j;
654  intmat Qt = transpose(Q);
655  for(int i = 1; i <= size(F); i++){
656    list Orbit = F[i];
657    list U;
658    for(j = 1; j <= size(Orbit); j++){
659      intvec aface = Orbit[j];
660      intmat Qgam0[size(aface)][ncols(Qt)] = Qt[aface,intvec(1..ncols(Qt))];
661      cone c = coneViaPoints(Qgam0);
662      if (dimension(c)!=ncols(Qt)){ERROR("cone should have full dimension");}
663      // insert it even if it is already inside (mincones will take care of this)
664      U[size(U)+1] = c;
665      kill aface;
666      kill Qgam0;
667      kill c;
668    }
669    OC[size(OC)+1] = U;
670    dbprint("current size of OC:");
671    dbprint(size(OC));
672    kill U;
673    kill Orbit;
674  }
675  return(OC);
676}
677example
678{
679  echo = 2;
680  // Note that simplexOrbitRepresentatives and simplexSymmetryGroup are subsets of the actual sets for G25. For the full example see the examples in the documentation
681  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
682  ideal J =
683    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
684    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
685    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
686    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
687    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
688  intmat Q[5][10] =
689    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
690    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
691    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
692    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
693    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
694  list simplexOrbitRepresentatives = intvec( 1, 2, 3, 4, 5 ),
695    intvec( 1, 2, 3, 5, 6 ),
696    intvec( 1, 2, 3, 5, 7 ),
697    intvec( 1, 2, 3, 5, 10 ),
698    intvec( 1, 2, 3, 7, 9 ),
699    intvec( 1, 2, 3, 4, 5, 6, 9, 10 ),
700    intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9 ),
701    intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
702  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
703  list simplexSymmetryGroup = permutationFromIntvec(intvec( 1 .. 10 )),
704    permutationFromIntvec(intvec( 1, 2, 4, 3, 5, 7, 6, 9, 8, 10 )),
705    permutationFromIntvec(intvec( 1, 3, 2, 4, 6, 5, 7, 8, 10, 9 )),
706    permutationFromIntvec(intvec( 1, 3, 4, 2, 6, 7, 5, 10, 8, 9 )),
707    permutationFromIntvec(intvec( 1, 4, 2, 3, 7, 5, 6, 9, 10, 8 )),
708    permutationFromIntvec(intvec( 1, 4, 3, 2, 7, 6, 5, 10, 9, 8 ));
709  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
710  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
711  apply(afaceOrbits,size);
712  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
713  apply(minAfaceOrbits,size);
714  list listOfOrbitConeOrbits = orbitConeOrbits(minAfaceOrbits,Q);
715}
716
717
718proc minimalOrbitConeOrbits(list listOfOrbits)
719"USAGE: minimalOrbitConeOrbits(listOfOrbits); listOfOrbits: list of lists of cones
720PURPOSE: Minimizes a list of orbit cone orbits.
721RETURN: a list of lists of cones
722EXAMPLE: example minimalOrbitConeOrbits; shows an example
723"
724{
725  int i,j;
726  list L = listOfOrbits;
727
728
729  for (i=1; i<=size(L); i++)
730  {
731    dbprint("::::: " + string(i)+" of "+string(size(L)));
732
733    for (j=1; j<=size(L); j++)
734    {
735      dbprint("outer: "+string(i)+"  inner: " + string(j));
736      if (i!=j)
737      {
738        if (containsOrbitdCone(L[i],L[j]))
739        {
740          dbprint("werfe raus, i="+string(i)+",  j="+string(j)+" (Laenge):  " + string(size(L[j])));
741          L = delete(L,j);
742          if (j<i)
743          {
744            i = i-1;
745          }
746          j = j-1;
747        }
748      }
749    }
750  }
751  return(L);
752}
753example
754{
755  echo = 2;
756  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
757  ideal J =
758    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
759    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
760    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
761    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
762    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
763  intmat Q[5][10] =
764    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
765    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
766    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
767    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
768    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
769  list simplexSymmetryGroup = G25Action();
770  list simplexOrbitRepresentatives = intvec( 1, 2, 3, 4, 5 ),
771  intvec( 1, 2, 3, 5, 6 ),
772  intvec( 1, 2, 3, 5, 7 ),
773  intvec( 1, 2, 3, 5, 10 ),
774  intvec( 1, 2, 3, 7, 9 ),
775  intvec( 1, 2, 6, 9, 10 ),
776  intvec( 1, 2, 3, 4, 5, 6 ),
777  intvec( 1, 2, 3, 4, 5, 10 ),
778  intvec( 1, 2, 3, 5, 6, 8 ),
779  intvec( 1, 2, 3, 5, 6, 9 ),
780  intvec( 1, 2, 3, 5, 7, 10 ),
781  intvec( 1, 2, 3, 7, 9, 10 ),
782  intvec( 1, 2, 3, 4, 5, 6, 7 ),
783  intvec( 1, 2, 3, 4, 5, 6, 8 ),
784  intvec( 1, 2, 3, 4, 5, 6, 9 ),
785  intvec( 1, 2, 3, 5, 6, 9, 10 ),
786  intvec( 1, 2, 3, 4, 5, 6, 7, 8 ),
787  intvec( 1, 2, 3, 4, 5, 6, 9, 10 ),
788  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9 ),
789  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
790  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
791  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
792  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
793  apply(afaceOrbits,size);
794  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
795  apply(minAfaceOrbits,size);
796  list listOfOrbitConeOrbits = orbitConeOrbits(minAfaceOrbits,Q);
797  apply(listOfOrbitConeOrbits,size);
798  list listOfMinimalOrbitConeOrbits = minimalOrbitConeOrbits(listOfOrbitConeOrbits);
799  size(listOfMinimalOrbitConeOrbits);
800}
801
802
803static proc containsOrbitdCone(list A, list B)
804{
805  cone a = A[1];
806  for (int i=1; i<=size(B); i++)
807  {
808    if (isSubcone(a,B[i]))
809    {
810      dbprint("found subcone i="+string(i));
811      return (1);
812    }
813  }
814  return (0);
815}
816
817static proc isSubcone(cone c1, cone c2)
818{
819  return(containsInSupport(c2, c1));
820}
821
822
823
824
825
826
827proc intersectOrbitsWithMovingCone(list OCmin,cone mov)
828"USAGE: intersectOrbitsWithMovingCone(OCmin, mov); OCmin: list of lists of cones, mov: cone
829PURPOSE: Intersects all cones in the orbits in OCmin with mov discarting all orbits of cones which are not of full dimension. The resulting orbits are duplicate free.
830RETURN: a list of lists of cones
831EXAMPLE: example intersectOrbitsWithMovingCone; shows an example
832"
833{
834  list OCmov;
835  cone ocmov;
836  int i,j;
837  int fulldim=dimension(mov);
838  for (i=1; i<=size(OCmin); i++)
839  {
840    dbprint("intersecting orbit "+string(i)+" with moving cone");
841    ocmov = convexIntersection(OCmin[i][1],mov);
842    if (dimension(ocmov)==fulldim)
843    {
844      list currentOrbit;
845      for (j=1; j<=size(OCmin[i]); j++)
846      {
847        dbprint("checking cone "+string(j)+" of "+string(size(OCmin[i])));
848        ocmov = convexIntersection(OCmin[i][j],mov);
849        ocmov = canonicalizeCone(ocmov);
850        if (!listContainsCone(currentOrbit,ocmov))
851        {
852          dbprint("inserting cone");
853          currentOrbit[size(currentOrbit)+1] = ocmov;
854        }
855      }
856      OCmov[size(OCmov)+1] = currentOrbit;
857      kill currentOrbit;
858    }
859    else
860    {
861      dbprint("intersection with moving cone lower-dimensional, abandoning orbit");
862    }
863  }
864  return(OCmov);
865}
866example {
867  echo=2;
868  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
869  ideal J =
870    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
871    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
872    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
873    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
874    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
875  intmat Q[5][10] =
876    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
877    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
878    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
879    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
880    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
881  list simplexSymmetryGroup = G25Action();
882  list simplexOrbitRepresentatives = intvec( 1, 2, 3, 4, 5 ),
883  intvec( 1, 2, 3, 5, 6 ),
884  intvec( 1, 2, 3, 5, 7 ),
885  intvec( 1, 2, 3, 5, 10 ),
886  intvec( 1, 2, 3, 7, 9 ),
887  intvec( 1, 2, 6, 9, 10 ),
888  intvec( 1, 2, 3, 4, 5, 6 ),
889  intvec( 1, 2, 3, 4, 5, 10 ),
890  intvec( 1, 2, 3, 5, 6, 8 ),
891  intvec( 1, 2, 3, 5, 6, 9 ),
892  intvec( 1, 2, 3, 5, 7, 10 ),
893  intvec( 1, 2, 3, 7, 9, 10 ),
894  intvec( 1, 2, 3, 4, 5, 6, 7 ),
895  intvec( 1, 2, 3, 4, 5, 6, 8 ),
896  intvec( 1, 2, 3, 4, 5, 6, 9 ),
897  intvec( 1, 2, 3, 5, 6, 9, 10 ),
898  intvec( 1, 2, 3, 4, 5, 6, 7, 8 ),
899  intvec( 1, 2, 3, 4, 5, 6, 9, 10 ),
900  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9 ),
901  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
902  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
903  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
904  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
905  apply(afaceOrbits,size);
906  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
907  apply(minAfaceOrbits,size);
908  list listOfOrbitConeOrbits = orbitConeOrbits(minAfaceOrbits,Q);
909  cone mov = movingCone(Q);
910  intersectOrbitsWithMovingCone(listOfOrbitConeOrbits,mov);
911}
912
913
914static proc coneToString(cone C){
915  bigintmat F = facets(C);
916  ring R=0,(x),dp;
917  matrix FF[nrows(F)][ncols(F)];
918  int i,j;
919  for (i=1; i<=nrows(F);i++){
920    for (j=1; j<=ncols(F);j++){
921      FF[i,j]=number(F[i,j]);
922    }
923  }
924  return("bigintmat F["+string(nrows(F))+"]["+string(ncols(F))+"]="+string(FF)+";cone C=canonicalizeCone(coneViaInequalities(F));");
925}
926
927proc storeOrbitConeOrbits(list OC, string fn)
928"USAGE: storeOrbitConeOrbits(OC, fn); OC: list of lists of cones, fn: string
929PURPOSE: Writes OC to file fn in Singular readable format. Can be importet using <.
930RETURN: nothing
931"
932{
933  int i,j;
934  write(":w "+fn,"list OC;");
935  for (i=1;i<=size(OC);i++){
936    write(":a "+fn,"list OCj;");
937    for (j=1;j<=size(OC[i]);j++){
938      write(":a "+fn,coneToString(OC[i][j]));
939      write(":a "+fn,"OCj[size(OCj)+1]=C;");
940      write(":a "+fn,"kill C;kill F;");
941    }
942    write(":a "+fn,"OC[size(OC)+1]=OCj;");
943    write(":a "+fn,"kill OCj;");
944  }
945}
946
947static proc storeCone(cone C,string fn){
948  intmat H = intmat(inequalities(C));
949  write(":w "+fn,"bigintmat H["+string(nrows(H))+"]["+string(ncols(H))+"] =");
950  write(":w "+fn,string(H)+";");
951  write(":a "+fn,"cone C= coneViaInequalities(H); kill H;");
952}
953
954static proc listToIntvec(list L){
955  intvec v;
956  for (int i = 1;i<=size(L);i++){
957    v[i]=L[i];}
958  return(v);
959}
960
961static proc intvecToList(intvec L){
962  list v;
963  for (int i = 1;i<=size(L);i++){
964    v[i]=L[i];}
965  return(v);
966}
967
968static proc stackMatrices(bigintmat M, bigintmat N){
969  if (ncols(M)!=ncols(N)){ERROR("matrices should have the same number of columns");}
970  bigintmat MN[nrows(M)+nrows(N)][ncols(N)];
971  MN[1..nrows(M),1..ncols(M)]=M[1..nrows(M),1..ncols(M)];
972  MN[(nrows(M)+1)..(nrows(M)+nrows(N)),1..ncols(M)]=N[1..nrows(N),1..ncols(N)];
973  return(MN);
974}
975
976
977proc movingCone(intmat Q)
978"USAGE: movingCone(Q); Q: intmat
979PURPOSE: Computes the moving cone from the grading matrix, with the degrees in the columns of Q.
980RETURN: a cone
981EXAMPLE: example movingCone; shows an example
982"
983{
984  cone Qgammadual = coneViaInequalities(transpose(Q));
985  bigintmat R = facets(Qgammadual);
986  list idx1=intvecToList(intvec(1..nrows(R)));
987  intvec idx2=1..ncols(R);
988  intvec idx1iv;
989  bigintmat Ri[nrows(R)-1][ncols(R)];
990  list C;
991  for (int i = 1; i<=nrows(R);i++){
992    idx1iv = listToIntvec(delete(idx1,i));
993    Ri=R[idx1iv,idx2];
994    C[i]=coneViaPoints(Ri);
995    dbprint(string(i)+"   "+string(nrows(facets(C[i]))));
996  }
997  cone mov = convexIntersection(C);
998  return(mov);
999}
1000example
1001{
1002  echo=2;
1003  intmat Q[5][10] =
1004    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1005    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1006    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
1007    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
1008    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
1009  cone mov = movingCone(Q);
1010  mov;
1011  rays(mov);
1012}
1013
1014
1015static proc pivotIndices(matrix H)
1016{
1017  intvec p;
1018  int pp;
1019  int i,j;
1020  int l=1;
1021  for (i=1; i<=ncols(H); i++)
1022  {
1023    for (j=nrows(H); j>=0; j--)
1024    {
1025      if (H[j,i]!=0)
1026      {
1027        if (j>pp)
1028        {
1029          p[l] = i;
1030          l++;
1031          pp = j;
1032        }
1033        break;
1034      }
1035    }
1036  }
1037  return (p);
1038}
1039
1040
1041
1042proc groupActionOnQImage(list G,intmat Q)
1043"USAGE: groupActionOnQImage(G,Q); G: list of permutations, Q: intmat
1044PURPOSE: Given the group G of permutations acting on the simplex on ncols(Q) objects, computes the corresponding group action on the image of Q. We assume that the basering has characteristic 0.
1045RETURN: list of matrices
1046EXAMPLE: example groupActionOnQImage; shows an example
1047"
1048{
1049  matrix Qmat = transpose(matrix(Q));
1050  matrix H = gauss_nf(Qmat);
1051  intvec indices = pivotIndices(H);
1052  intmat Qbasis[nrows(Q)][size(indices)]=Q[1..nrows(Q),indices];
1053  matrix QbasisInv = inverse(Qbasis);
1054  list L;
1055  intmat Qt = transpose(Q);
1056  for(int i = 1; i <= size(G); i++){
1057    intvec sig = permutationToIntvec(G[i]);
1058    intmat Bsig = perm2mat(sig, indices,Qt);
1059    matrix Asig = Bsig * QbasisInv;
1060    L[size(L)+1] = matrixToIntmat(Asig);
1061    kill sig;
1062    kill Bsig;
1063    kill Asig;
1064  }
1065  return(L);
1066}
1067example {
1068  echo=2;
1069  ring R = 0,(x),dp;
1070  intmat Q[5][10] =
1071    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1072    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1073    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
1074    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
1075    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
1076list generatorsG = permutationFromIntvec(intvec( 1, 3, 2, 4, 6, 5, 7, 8, 10, 9 )),
1077permutationFromIntvec(intvec( 5, 7, 1, 6, 9, 2, 8, 4, 10, 3 ));
1078groupActionOnQImage(generatorsG,Q);
1079}
1080
1081
1082
1083static proc perm2mat(intvec sig, intvec indices, intmat Q){
1084  intvec sigind = 1:size(indices);
1085  for(int i = 1; i <= size(indices); i++){
1086    if(indices[i] > size(sig)){
1087      sigind[i] = indices[i];
1088    } else {
1089      sigind[i] = sig[indices[i]];
1090    }
1091  }
1092  intmat Asig[size(indices)][ncols(Q)];
1093  for(i = 1; i <= size(sigind); i++){
1094    Asig[i,1..ncols(Q)] = Q[sigind[i], 1..ncols(Q)];
1095  }
1096  // the new basis must be in the cols:
1097  return(transpose(Asig));
1098}
1099
1100///////
1101
1102
1103
1104
1105static proc imageCone(cone c, intmat A){
1106  bigintmat ineqs = inequalities(c);
1107  cone cc = coneViaInequalities (ineqs * A);
1108  return(cc);
1109}
1110
1111
1112static proc matrixToIntmat(matrix A){
1113  int i,j;
1114  intmat Aint[nrows(A)][ncols(A)];
1115  for(i = 1; i<=nrows(A); i++){
1116    for(j = 1; j<=ncols(A); j++){
1117      if (deg(A[i,j])>0){ERROR("entries should be constants");}
1118      if (denominator(number(A[i,j]))!=1){ERROR("entries should be integers");}
1119      Aint[i,j]=int(number(A[i,j]));
1120    }
1121  }
1122  return(Aint);
1123}
1124
1125
1126proc groupActionOnHashes(list Asigma, list OCmov)
1127"USAGE: groupActionOnHashes(Asigma,OCmov); Asigma: list, OCmov: list of list of cones
1128PURPOSE: From the list of orbits of orbitcones, and the symmetry group represenation given by the matrices in Asigma, compute the corresponding permutation representation of the symmetry group on the orbit cones. The permutations are specified in a map representation of length the sum of the size of the orbits of OCmov.
1129RETURN: list of permutations
1130EXAMPLE: example groupActionOnHashes; shows an example
1131"
1132{
1133// for each A in S6:
1134// for each c in OC90:
1135// store index of A*c
1136// --> intvec v_A
1137// store this in the list Ind
1138  list Ind;
1139  int i,j,b,k,sizepreviousorbits;
1140  list remaining;
1141  intmat A;
1142  cone c,Ac;
1143  for(i = 1; i<=size(Asigma); i++){
1144    intvec vA;
1145    A = intmat(Asigma[i]);
1146    dbprint("element "+string(i)+" of symmetry group");
1147    sizepreviousorbits=0;
1148    for(b = 1; b <= size(OCmov); b++){
1149      remaining = intvecToList(intvec(1..size(OCmov[b])));
1150      for(j = 1; j <= size(OCmov[b]); j++){
1151        Ac = imageCone(OCmov[b][j], A);
1152
1153        // find out index:
1154        for(k= 1; k <= size(remaining); k++){
1155          if(OCmov[b][remaining[k]] == Ac){
1156            vA[j+sizepreviousorbits] = remaining[k]+sizepreviousorbits;
1157            remaining = delete(remaining,k);
1158            break;
1159          }
1160        }
1161      }
1162
1163      sizepreviousorbits=size(vA);
1164    }
1165    Ind[size(Ind)+1] = permutationFromIntvec(vA);
1166    dbprint("vA: "+string(vA));
1167    kill vA;
1168  }
1169  return(Ind);
1170}
1171example
1172{
1173  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
1174  ideal J =
1175    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
1176    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
1177    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
1178    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
1179    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
1180  intmat Q[5][10] =
1181    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1182    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1183    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
1184    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
1185    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
1186  list AF= afaces(J);
1187  list OC = orbitCones(AF,Q);
1188  list generatorsG = permutationFromIntvec(intvec( 1, 3, 2, 4, 6, 5, 7, 8, 10, 9 )),
1189                     permutationFromIntvec(intvec( 5, 7, 1, 6, 9, 2, 8, 4, 10, 3 ));
1190  list Asigmagens = groupActionOnQImage(generatorsG,Q);
1191groupActionOnHashes(Asigmagens,list(OC));
1192
1193
1194  list simplexSymmetryGroup = G25Action();
1195  list orb = findOrbits(simplexSymmetryGroup,nrows(Q));
1196  list simplexOrbitRepresentatives;
1197  for (int i=1;i<=size(orb);i++){simplexOrbitRepresentatives[i]=orb[i][1];}
1198  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
1199  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
1200  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
1201  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
1202  list listOfOrbitConeOrbits = orbitConeOrbits(minAfaceOrbits,Q);
1203  list listOfMinimalOrbitConeOrbits = minimalOrbitConeOrbits(listOfOrbitConeOrbits);
1204  list Asigma = groupActionOnQImage(simplexSymmetryGroup,Q);
1205  groupActionOnHashes(Asigma,listOfOrbitConeOrbits);
1206
1207}
1208
1209
1210
1211
1212
1213
1214
1215
1216static proc composePermutationsGAP(permutation sigma, permutation tau){
1217  intvec sigmaTauImage;
1218
1219  for (int i=1;i<=size(sigma.image);i++){
1220    sigmaTauImage[i]=tau.image[sigma.image[i]];
1221  }
1222
1223  permutation sigmaTau;
1224  sigmaTau.image = sigmaTauImage;
1225  return(sigmaTau);
1226}
1227
1228static proc composePermutations(permutation sigma, permutation tau){
1229  intvec sigmaTauImage;
1230
1231  for (int i=1;i<=size(sigma.image);i++){
1232    sigmaTauImage[i]=sigma.image[tau.image[i]];
1233  }
1234
1235  permutation sigmaTau;
1236  sigmaTau.image = sigmaTauImage;
1237  return(sigmaTau);
1238}
1239
1240
1241static proc permutationPower(permutation sigma, int k){
1242  int i;
1243  if (k==0)
1244  {
1245    permutation identity;
1246    identity.image = intvec(1..size(sigma.image));
1247    return (identity);
1248  }
1249  if (k<0)
1250  {
1251    // if k<0 invert sigma and replace k with -k
1252    intvec sigmaImage = sigma.image;
1253    for (i=1; i<=size(sigmaImage); i++)
1254    {
1255      sigma.image[sigmaImage[i]] = i;
1256    }
1257    k = -k;
1258  }
1259  permutation sigmaToPowerK = sigma;
1260  for (i=2; i<=k; i++)
1261  {
1262    sigmaToPowerK = composePermutations(sigmaToPowerK, sigma);
1263  }
1264  return (sigmaToPowerK);
1265}
1266
1267proc permutationFromIntvec(intvec sigmaImage)
1268"USAGE: permutationFromIntvec(sigmaImage); sigmaImage: intvec
1269PURPOSE: Create a permutation from an intvec of images.
1270RETURN: permutation
1271EXAMPLE: example permutationFromIntvec; shows an example
1272"
1273{
1274  permutation sigma;
1275  sigma.image = sigmaImage;
1276  return (sigma);
1277}
1278
1279
1280proc evaluateProduct(list generatorsGperm, string st)
1281"USAGE: evaluateProduct(generatorsGperm,st); generatorsGperm: list, st: string
1282PURPOSE: Evaluates a formal product of variables xi in st, where xi corresponds to the permutation generatorsGperm[i].
1283RETURN: permutation
1284EXAMPLE: example evaluateProduct; shows an example
1285"
1286{
1287  for (int i=1;i<=size(generatorsGperm);i++){
1288    execute("permutation x"+string(i)+"= generatorsGperm[i];");
1289  }
1290  if (st==""){
1291    st="x1^0";
1292  }
1293  execute("permutation sigma = "+st);
1294  return(sigma);}
1295example
1296{
1297  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
1298  ideal J =
1299    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
1300    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
1301    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
1302    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
1303    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
1304  intmat Q[5][10] =
1305    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1306    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1307    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
1308    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
1309    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
1310  list AF= afaces(J);
1311  list OC = orbitCones(AF,Q);
1312  list generatorsG = permutationFromIntvec(intvec( 1, 3, 2, 4, 6, 5, 7, 8, 10, 9 )),
1313                     permutationFromIntvec(intvec( 5, 7, 1, 6, 9, 2, 8, 4, 10, 3 ));
1314  list Asigmagens = groupActionOnQImage(generatorsG,Q);
1315//list actionOnOrbitconeIndicesForGenerators = groupActionOnHashes(Asigmagens,OC);
1316string elementInTermsOfGenerators =
1317"(x2^-1*x1^-1)^3*x1^-1";
1318//evaluateProduct(actionOnOrbitconeIndicesForGenerators, elementInTermsOfGenerators);
1319}
1320
1321
1322proc permutationToIntvec(permutation sigma)
1323"USAGE: permutationToIntvec(sigma); sigma: permutation
1324PURPOSE: Convert a permutation to an intvec of images.
1325RETURN: intvec
1326EXAMPLE: example permutationToIntvec; shows an example
1327"
1328{return(sigma.image);}
1329example
1330{
1331permutation sigma = permutationFromIntvec(intvec( 1, 2, 4, 3, 5, 7, 6, 9, 8, 10 ));
1332sigma;
1333permutationToIntvec(sigma);
1334}
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347proc storeActionOnOrbitConeIndices(list Ind,string fn)
1348"USAGE: storeActionOnOrbitConeIndices(generatorsGperm,st); generatorsGperm: list, fn: string
1349PURPOSE: Write the action on the set of orbit cones to the file fn in Singular readable format.
1350RETURN: nothing
1351"
1352{
1353  string s = "list actionOnOrbitconeIndices;";
1354  for(int i =1; i <= size(Ind); i++){
1355    s = s + "intvec v = " + string(Ind[i]) + ";" + newline;
1356    s = s + "actionOnOrbitconeIndices[size(actionOnOrbitconeIndices)+1] = permutationFromIntvec(v);" + newline + "kill v;" + newline;
1357  }
1358  write(":w "+fn, s);
1359}
1360
1361
1362
1363
1364
1365static proc getNeighborHash(list OC, bigintmat w, bigintmat v, int mu)
1366{
1367  int success = 0;
1368  int zz;
1369  intvec Jtmp;
1370  bigintmat wtmp;
1371
1372  while(!success)
1373  {
1374    mu = mu*2;
1375    wtmp = mu*w - v;
1376    success = 1;
1377    for(zz = 1; zz <= size(OC); zz++)
1378    {
1379      if(containsInSupport(OC[zz], wtmp))
1380      {
1381        if(!containsInSupport(OC[zz], w))
1382        {
1383          success = 0;
1384          Jtmp = 0;
1385          break;
1386        }
1387        // insert index zz:
1388        if(size(Jtmp) ==1 && Jtmp[1] == 0)
1389        {
1390          Jtmp[1] = zz;
1391        }
1392        else
1393        {
1394          Jtmp[size(Jtmp)+1] = zz;
1395        }
1396      }
1397    }
1398  }
1399
1400  return(Jtmp);
1401}
1402
1403
1404
1405
1406///////////////////////////////////////
1407
1408proc GITfanSymmetric(list OC, bigintmat Q, cone Qgamma, list actiononorbitcones, list #)
1409  "USAGE: GITfanSymmetric(OC, Q, Qgamma, actiononorbitcones [, file1, file2]); OC:list, Q:bigintmat, Qgamma:cone, actiononorbitcones: list of intvec, file1:string, file2:string
1410PURPOSE: Returns the common refinement of the cones given in
1411the list OC which is supposed to contain the orbit cones intersected with Qgamma. The list actiononorbitcones is supposed to contain the symmetry group acting as permutations of on the list of orbit cones in OC. The optional argument can be used to specify one or two strings with file names, where the first file will contain the hashes of the GIT-cones and the second argument the actual cones in their H-representation.
1412To obtain the whole GIT-fan Qgamma has to be take the cone generated by the columns of Q.
1413RETURN: a list containing the bigint hashes of the GIT cones.
1414EXAMPLE: example GITfanSymmetric; shows an example
1415"
1416{
1417  actiononorbitcones=apply(actiononorbitcones,permutationToIntvec);
1418  /**
1419   * stores the hashes of all maximal GIT cones computed
1420   */
1421  list hashesOfCones;
1422  /**
1423   * stores to the corresponding maximal GIT cone in hashesOfCones
1424   * - 0, if guaranteed that all adjacent GIT cones are known
1425   *        or are to be computed in the next iteration       (*)
1426   * - hash as intvec, otherwise
1427   */
1428  list workingList;
1429
1430
1431  /**
1432   * compute starting cone
1433   */
1434  bigintmat w,v;
1435  cone lambda;
1436  intvec lambdaHash;
1437  while(dimension(lambda) <> nrows(Q)){
1438    w = randConeEl(transpose(Q),100);
1439    dbprint("testing "+string(w));
1440    if (containsRelatively(Qgamma,w)) {
1441      lambda,lambdaHash = GITcone(OC,w);
1442      dbprint("computed cone of dimension "+string(dimension(lambda)));
1443    }
1444  }
1445  int nCones = 1;     // essentially size(hashesOfCones)
1446  int nConesOpen = 1; // essentially size(workingList)+1, see (*) above
1447
1448
1449  /**
1450   * initialize lists
1451   */
1452  int posToInsert = 1;
1453  bigint hashToInsert = binaryToBigint(lambdaHash);
1454  intvec sigLambdaHash;
1455  for(int i = 2; i <= size(actiononorbitcones); i++){
1456    sigLambdaHash = composeIntvecs(actiononorbitcones[i],lambdaHash);
1457    hashToInsert = min(hashToInsert,binaryToBigint(sigLambdaHash));
1458  }
1459  hashesOfCones[1] = hashToInsert;
1460  workingList[1] = int(0);
1461  if (size(#)>0) {write(":w "+#[1],string(hashesOfCones[1]) + ",");}
1462  if (size(#)>1) {write(":w "+#[2],"");writeGitconeToFile(lambda,#[2]);}
1463
1464
1465  /**
1466   * traverse fan
1467   */
1468  int t,tt;
1469  list FL;
1470  intvec neighbourHash;
1471  int mu = 1024;
1472  while (lambdaHash>0)
1473  {
1474    tt=timer;
1475
1476    /**
1477     * compute all facets of lambda
1478     */
1479    t = timer;
1480    FL = listOfFacetsAndInteriorVectors(lambda, Qgamma);
1481    dbprint("time for facets: "+string(timer - t));
1482
1483    /**
1484     * compute all neighbours of lambda
1485     */
1486    for (i=size(FL[1]); i>0; i--)
1487    {
1488      v = FL[1][i][1]; // interior facet normal
1489      w = FL[1][i][2]; // interior facet point
1490      neighbourHash = getNeighborHash(OC,w,v,mu);
1491      posToInsert,hashToInsert = findPosToInsertSymmetric(hashesOfCones,neighbourHash,actiononorbitcones);
1492      if(posToInsert > 0)
1493      {
1494        if (size(#)>0){write(":a "+#[1],string(binaryToBigint(neighbourHash)) + ",");}
1495        hashesOfCones = insertToList(hashesOfCones,hashToInsert,posToInsert);
1496        workingList = insertToList(workingList,neighbourHash,posToInsert);
1497        nConesOpen++;
1498        nCones++;
1499      }
1500    }
1501
1502    /**
1503     * pick lambdaHash and lambda for next iteration,
1504     * set respective entry in workingList to 0
1505     */
1506    lambdaHash = 0;
1507    for (i=size(workingList); i>0; i--)
1508    {
1509      if (typeof(workingList[i])=="intvec")
1510      {
1511        lambdaHash = workingList[i];
1512        lambda = gitConeFromHash(OC,lambdaHash);
1513        if (size(#)>1) {writeGitconeToFile(lambda,#[2]);}
1514        workingList[i] = int(0);
1515        break;
1516      }
1517    }
1518    nConesOpen--;
1519
1520    dbprint("overall: "+string(nCones)+"   open: "+string(nConesOpen)+"   time for loop: "+string(timer-tt));
1521  }
1522  return(hashesOfCones);
1523}
1524example
1525{
1526  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
1527  ideal J =
1528    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
1529    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
1530    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
1531    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
1532    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
1533  intmat Q[5][10] =
1534    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1535    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1536    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
1537    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
1538    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
1539  list simplexSymmetryGroup = G25Action();
1540  list simplexOrbitRepresentatives = intvec( 1, 2, 3, 4, 5 ),
1541  intvec( 1, 2, 3, 5, 6 ),
1542  intvec( 1, 2, 3, 5, 7 ),
1543  intvec( 1, 2, 3, 5, 10 ),
1544  intvec( 1, 2, 3, 7, 9 ),
1545  intvec( 1, 2, 6, 9, 10 ),
1546  intvec( 1, 2, 3, 4, 5, 6 ),
1547  intvec( 1, 2, 3, 4, 5, 10 ),
1548  intvec( 1, 2, 3, 5, 6, 8 ),
1549  intvec( 1, 2, 3, 5, 6, 9 ),
1550  intvec( 1, 2, 3, 5, 7, 10 ),
1551  intvec( 1, 2, 3, 7, 9, 10 ),
1552  intvec( 1, 2, 3, 4, 5, 6, 7 ),
1553  intvec( 1, 2, 3, 4, 5, 6, 8 ),
1554  intvec( 1, 2, 3, 4, 5, 6, 9 ),
1555  intvec( 1, 2, 3, 5, 6, 9, 10 ),
1556  intvec( 1, 2, 3, 4, 5, 6, 7, 8 ),
1557  intvec( 1, 2, 3, 4, 5, 6, 9, 10 ),
1558  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9 ),
1559  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
1560  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
1561  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
1562  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
1563  apply(afaceOrbits,size);
1564  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
1565  apply(minAfaceOrbits,size);
1566  list listOfOrbitConeOrbits = orbitConeOrbits(minAfaceOrbits,Q);
1567  apply(listOfOrbitConeOrbits,size);
1568  list listOfMinimalOrbitConeOrbits = minimalOrbitConeOrbits(listOfOrbitConeOrbits);
1569  size(listOfMinimalOrbitConeOrbits);
1570  list Asigma = groupActionOnQImage(simplexSymmetryGroup,Q);
1571  list actionOnOrbitconeIndices = groupActionOnHashes(Asigma,listOfOrbitConeOrbits);
1572  list OClist = listOfOrbitConeOrbits[1];
1573  for (int i =2;i<=size(listOfOrbitConeOrbits);i++){
1574    OClist = OClist + listOfOrbitConeOrbits[i];
1575  }
1576cone mov = coneViaPoints(transpose(Q));
1577mov = canonicalizeCone(mov);
1578printlevel = 3;
1579list Sigma = GITfanSymmetric(OClist, Q, mov, actionOnOrbitconeIndices);
1580Sigma;
1581}
1582
1583
1584proc GITfanParallelSymmetric(list OC, bigintmat Q, cone Qgamma, list actiononorbitcones, list #)
1585  "USAGE: GITfanParallelSymmetric(OC, Q, Qgamma, actiononorbitcones [, file1]); OC:list, Q:bigintmat, Qgamma:cone, actiononorbitcones: list of intvec, file1:string
1586PURPOSE: Returns the common refinement of the cones given in
1587the list OC which is supposed to contain the orbit cones intersected with Qgamma. The list actiononorbitcones is supposed to contain the symmetry group acting as permutations of on the list of orbit cones in OC. The optional argument can be used to specify a name for a file which will contain the hashes of the GIT-cones.
1588To obtain the whole GIT-fan Qgamma has to be take the cone generated by the columns of Q.
1589RETURN: a list containing the bigint hashes of the GIT cones.
1590NOTE: The proceduce uses parallel computation for the construction of the GIT-cones.
1591EXAMPLE: example GITfanParallelSymmetric; shows an example
1592"
1593{
1594  actiononorbitcones=apply(actiononorbitcones,permutationToIntvec);
1595  /**
1596   * stores the hashes of all maximal GIT cones computed
1597   */
1598  list hashesOfCones;
1599  /**
1600   * stores to the corresponding maximal GIT cone in hashesOfCones
1601   * - 0, if guaranteed that all adjacent GIT cones are known
1602   *        or are to be computed in the next iteration       (*)
1603   * - hash as intvec, otherwise
1604   */
1605  list workingList;
1606
1607
1608  /**
1609   * compute starting cone
1610   */
1611  bigintmat w,v;
1612  cone lambda;
1613  intvec lambdaHash;
1614  while(dimension(lambda) <> nrows(Q)){
1615    w = randConeEl(transpose(Q),100);
1616    dbprint("testing "+string(w));
1617    if (containsRelatively(Qgamma,w)) {
1618      lambda,lambdaHash = GITcone(OC,w);
1619      dbprint("computed cone of dimension "+string(dimension(lambda)));
1620    }
1621  }
1622  int nCones = 1;     // essentially size(hashesOfCones)
1623  int nConesOpen = 1; // essentially size(workingList)+1, see (*) above
1624
1625
1626  /**
1627   * initialize lists
1628   */
1629  bigint hashToInsert = binaryToBigint(lambdaHash);
1630  int posToInsert = 1;
1631  intvec sigLambdaHash;
1632  for(int i = 2; i <= size(actiononorbitcones); i++){
1633    sigLambdaHash = composeIntvecs(actiononorbitcones[i],lambdaHash);
1634    hashToInsert = min(hashToInsert,binaryToBigint(sigLambdaHash));
1635  }
1636  hashesOfCones[1] = hashToInsert;
1637  workingList[1] = int(0);
1638  if (size(#)>0) {write(":w "+#[1],string(binaryToBigint(lambdaHash)) + ",");}
1639  //if (size(#)>1) {write(":w "+#[2],"list listOfMaximalCones;");writeGitconeToFile(lambda,#[2]);}
1640
1641
1642  list iterationArgs = list(list(lambdaHash,OC,Qgamma,actiononorbitcones));
1643  list iterationRes;
1644
1645  /**
1646   * traverse fan
1647   */
1648  int j,t,tloop;
1649  list FL;
1650  list neighbourHashes;
1651  intvec neighbourHash;
1652  while (size(iterationArgs)>0)
1653  {
1654    tloop=rtimer;
1655
1656    /**
1657     * compute all neighbours of lambda
1658     */
1659    t = rtimer;
1660    iterationRes = parallelWaitAll("computeNeighbourMinimalHashes",iterationArgs);
1661    dbprint("time neighbours: "+string(rtimer - t));
1662
1663    /**
1664     * central book keeping
1665     */
1666    t = rtimer;
1667    for (i=1; i<=size(iterationRes); i++)
1668    {
1669      neighbourHashes = iterationRes[i];
1670      for (j=1; j<=size(neighbourHashes); j++)
1671      {
1672        neighbourHash = neighbourHashes[j];
1673        hashToInsert = binaryToBigint(neighbourHash);
1674        posToInsert = findPlaceToInsert(hashesOfCones,hashToInsert);
1675        if(posToInsert > 0)
1676        {
1677          if (size(#)>0){write(":a "+#[1],string(binaryToBigint(neighbourHash)) + ",");}
1678          hashesOfCones = insertToList(hashesOfCones,hashToInsert,posToInsert);
1679          workingList = insertToList(workingList,neighbourHash,posToInsert);
1680          nConesOpen++;
1681          nCones++;
1682        }
1683      }
1684    }
1685    nConesOpen = nConesOpen - size(iterationArgs);
1686    dbprint("time bookkeeping: "+string(rtimer - t));
1687
1688    /**
1689     * pick arguments for next iteration,
1690     * set respective entry in workingList to 0
1691     */
1692    t = rtimer;
1693    iterationArgs = list();
1694    for (i=size(workingList); i>0; i--)
1695    {
1696      if (typeof(workingList[i])=="intvec")
1697      {
1698        iterationArgs[size(iterationArgs)+1] = list(workingList[i],OC,Qgamma,actiononorbitcones);
1699        workingList[i] = int(0);
1700        if (size(iterationArgs) >= getcores())
1701        {
1702          break;
1703        }
1704      }
1705    }
1706    dbprint("time preparation: "+string(rtimer - t));
1707
1708    dbprint("overall: "+string(nCones)+"   open: "+string(nConesOpen)+"   time loop: "+string(rtimer-tloop));
1709  }
1710  return(hashesOfCones);
1711}
1712example
1713{
1714  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
1715  ideal J =
1716    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
1717    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
1718    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
1719    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
1720    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
1721  intmat Q[5][10] =
1722    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1723    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1724    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
1725    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
1726    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
1727  list simplexSymmetryGroup = G25Action();
1728  list simplexOrbitRepresentatives = intvec( 1, 2, 3, 4, 5 ),
1729  intvec( 1, 2, 3, 5, 6 ),
1730  intvec( 1, 2, 3, 5, 7 ),
1731  intvec( 1, 2, 3, 5, 10 ),
1732  intvec( 1, 2, 3, 7, 9 ),
1733  intvec( 1, 2, 6, 9, 10 ),
1734  intvec( 1, 2, 3, 4, 5, 6 ),
1735  intvec( 1, 2, 3, 4, 5, 10 ),
1736  intvec( 1, 2, 3, 5, 6, 8 ),
1737  intvec( 1, 2, 3, 5, 6, 9 ),
1738  intvec( 1, 2, 3, 5, 7, 10 ),
1739  intvec( 1, 2, 3, 7, 9, 10 ),
1740  intvec( 1, 2, 3, 4, 5, 6, 7 ),
1741  intvec( 1, 2, 3, 4, 5, 6, 8 ),
1742  intvec( 1, 2, 3, 4, 5, 6, 9 ),
1743  intvec( 1, 2, 3, 5, 6, 9, 10 ),
1744  intvec( 1, 2, 3, 4, 5, 6, 7, 8 ),
1745  intvec( 1, 2, 3, 4, 5, 6, 9, 10 ),
1746  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9 ),
1747  intvec( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 );
1748  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
1749  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
1750  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
1751  apply(afaceOrbits,size);
1752  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
1753  apply(minAfaceOrbits,size);
1754  list listOfOrbitConeOrbits = orbitConeOrbits(minAfaceOrbits,Q);
1755  apply(listOfOrbitConeOrbits,size);
1756  list listOfMinimalOrbitConeOrbits = minimalOrbitConeOrbits(listOfOrbitConeOrbits);
1757  size(listOfMinimalOrbitConeOrbits);
1758  list Asigma = groupActionOnQImage(simplexSymmetryGroup,Q);
1759  list actionOnOrbitconeIndices = groupActionOnHashes(Asigma,listOfOrbitConeOrbits);
1760  list OClist = listOfOrbitConeOrbits[1];
1761  for (int i =2;i<=size(listOfOrbitConeOrbits);i++){
1762    OClist = OClist + listOfOrbitConeOrbits[i];
1763  }
1764  cone mov = coneViaPoints(transpose(Q));
1765  mov = canonicalizeCone(mov);
1766  list Sigma = GITfanParallelSymmetric(OClist, Q, mov, actionOnOrbitconeIndices);
1767  Sigma;
1768}
1769
1770
1771// not static to be used in parallel.lib
1772proc computeNeighbourMinimalHashes(intvec lambdaHash, list OC, cone Qgamma, list actiononorbitcones)
1773{
1774  /**
1775   * compute all facets of lambda
1776   */
1777  cone lambda = gitConeFromHash(OC,lambdaHash);
1778  list FL = listOfFacetsAndInteriorVectors(lambda, Qgamma);
1779
1780  /**
1781   * compute all minimal hashes of neighbours of lambda
1782   */
1783  int i,j;
1784  bigintmat v,w;
1785  intvec neighbourHash;
1786  intvec neighbourHashPerm;
1787  bigint nPerm;
1788  intvec neighbourHashMin;
1789  bigint nMin;
1790  list neighbourHashes;
1791  for (i=size(FL[1]); i>0; i--)
1792  {
1793    v = FL[1][i][1]; // interior facet normal
1794    w = FL[1][i][2]; // interior facet point
1795    neighbourHash = getNeighborHash(OC,w,v,1024);
1796    neighbourHashMin = neighbourHash;
1797    nMin = binaryToBigint(neighbourHash);
1798    for (j=size(actiononorbitcones); j>1; j--)
1799    {
1800      neighbourHashPerm = composeIntvecs(actiononorbitcones[j],neighbourHash);
1801      nPerm = binaryToBigint(neighbourHashPerm);
1802      if (nPerm < nMin)
1803      {
1804        nMin = nPerm;
1805        neighbourHashMin = neighbourHashPerm;
1806      }
1807    }
1808    neighbourHashes[i] = neighbourHashMin;
1809  }
1810
1811  return (neighbourHashes);
1812}
1813
1814
1815
1816static proc writeGitconeToFile(cone lambda,string fn)
1817{
1818  bigintmat H = facets(lambda);
1819
1820  int rows = nrows(H);
1821  int cols = ncols(H);
1822  string toBeWritten = "bigintmat H["+string(rows)+"]["+string(cols)+"]=";
1823  int i,j;
1824  for (i=1; i<=rows; i++)
1825  {
1826    for (j=1; j<=cols; j++)
1827    {
1828      toBeWritten = toBeWritten + string(H[i,j]) + ",";
1829    }
1830  }
1831  toBeWritten = toBeWritten[1..size(toBeWritten)-1];
1832  toBeWritten = toBeWritten + ";";
1833  write(":a "+fn,toBeWritten);
1834
1835  toBeWritten = "listOfMaximalCones[size(listOfMaximalCones)+1] = coneViaInequalities(V);";
1836  write(":a "+fn,toBeWritten);
1837
1838  toBeWritten = "kill V;";
1839  write(":a "+fn,toBeWritten);
1840
1841  toBeWritten = "";
1842  write(":a "+fn,toBeWritten);
1843}
1844
1845
1846
1847static proc listOfFacetsAndInteriorVectors(cone lambda, cone Qgamma, list #){
1848  list FL;
1849  int numboundary;
1850
1851  bigintmat FL0 = facets(lambda);
1852  bigintmat H[1][ncols(FL0)];
1853  bigintmat FL1[nrows(FL0)-1][ncols(FL0)]; // delete row of H from FL0
1854
1855  bigintmat w;
1856  cone facetCone;
1857  for(int i = 1; i <= nrows(FL0); i++){
1858    H = FL0[i,1..ncols(FL0)];
1859
1860    if(i > 1 and i < nrows(FL0)){
1861      FL1 = FL0[1..i-1, 1..ncols(FL0)], FL0[i+1..nrows(FL0), 1..ncols(FL0)];
1862    } else {
1863      if(i == nrows(FL0)){
1864        FL1 = FL0[1..i-1, 1..ncols(FL0)];
1865      } else { // i = 1:
1866        FL1 = FL0[2..nrows(FL0), 1..ncols(FL0)];
1867      }
1868    }
1869
1870    facetCone = coneViaInequalities(FL1, H);
1871
1872    if (size(#)>0)
1873    {
1874      if (containsInSupport(facetCone,#[1]))
1875      {
1876        i++;
1877        continue;
1878      }
1879    }
1880
1881    w = relativeInteriorPoint(facetCone);
1882
1883    if(containsRelatively(Qgamma,w)){
1884      FL[size(FL) + 1] = list(H,w);
1885    } else {
1886      numboundary=numboundary+1;
1887    }
1888  }
1889
1890  return(list(FL,numboundary));
1891}
1892
1893
1894
1895
1896
1897////////////////////////////////
1898
1899// CAREFUL: we assume that actiononorbitcones[1] = id.
1900static proc findPosToInsertSymmetric(list hashesOfCones, intvec J, list actiononorbitcones){
1901
1902  // 1.: compute minimal hash sigJ
1903  bigint n = binaryToBigint(J);
1904  intvec sigJ;
1905  for(int i = 2; i <= size(actiononorbitcones); i++){
1906    sigJ = composeIntvecs(actiononorbitcones[i],J);
1907    n = min(n,binaryToBigint(sigJ));
1908  }
1909
1910  // 2.:check if minimal hash is already in list
1911  return(findPlaceToInsert(hashesOfCones,n),n);
1912}
1913
1914//////////////////////
1915
1916// insert n at position pos and move bigger elements by one index
1917proc insertToList(list L, def elementToInsert, int posToInsert){
1918  if(posToInsert == 1){
1919    return(list(elementToInsert)+L);
1920  }
1921  if(posToInsert == size(L)+1){
1922    return(L+list(elementToInsert));
1923  }
1924  return(list(L[1..(posToInsert-1)],elementToInsert,L[posToInsert..size(L)]));
1925}
1926
1927proc GITcone(list OCcones, bigintmat w)
1928"USAGE: GITcone(OCcones, w); OCcones: list of orbit cones, w: bigintmat with one row
1929PURPOSE: Returns the intersection of all orbit cones containing w.
1930RETURN: cone,intvec with the GIT cone containing w, and the hash of this cone (the indices of the orbit cones contributing to the intersection)
1931EXAMPLE: example GITcone; shows an example
1932"
1933{
1934  list OCrelcones;
1935  intvec Hash;
1936  for(int i = 1; i <= size(OCcones); i++){
1937    if(containsInSupport(OCcones[i], w)){
1938      OCrelcones[size(OCrelcones)+1]=OCcones[i];
1939      Hash[size(Hash)+1] = i;
1940    }
1941  }
1942  Hash = intvec(Hash[2..size(Hash)]);
1943  return(convexIntersection(OCrelcones),Hash);
1944}
1945example {
1946  echo=2;
1947  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
1948  ideal J =
1949    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
1950    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
1951    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
1952    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
1953    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
1954  intmat Q[5][10] =
1955    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
1956    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
1957    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
1958    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
1959    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
1960
1961  list AF= afaces(J,nrows(Q));
1962  AF=fullDimImages(AF,Q);
1963  AF = minimalAfaces(AF);
1964  list OC = orbitCones(AF,Q);
1965  bigintmat w[1][nrows(Q)];
1966  for(int i = 1; i <= nrows(Q); i++){
1967    w = w + Q[1..nrows(Q),i];
1968  }
1969  GITcone(OC,w);
1970}
1971
1972
1973static proc gitConeFromHash(list OC, intvec Hash)
1974{
1975  list OCtoIntersect = OC[Hash];
1976  return (convexIntersection(OCtoIntersect));
1977}
1978
1979
1980
1981
1982
1983static proc randConeEl(bigintmat Q, int bound){
1984  bigintmat w[1][ncols(Q)];
1985
1986  for(int i = 1; i <= nrows(Q); i++){
1987    bigintmat v[1][ncols(Q)] = Q[i,1..ncols(Q)];
1988
1989    w = w + random(1,bound) * v;
1990
1991    kill v;
1992  }
1993
1994  return(w);
1995}
1996
1997
1998
1999static proc subdividelist(list OC,int ncores){
2000  if (ncores>size(OC)){ncores=size(OC);}
2001  int percore = size(OC) div (ncores);
2002  int lastcore = size(OC) mod (ncores);
2003  list OCLL;
2004  int j=1;
2005  int starti=1;
2006  int endi;
2007  for (int i=1;i<=ncores;i++){
2008    endi = starti+percore-1;
2009    if (i<=lastcore) {endi=endi+1;}
2010    list OCLLi=OC[starti..endi];
2011    starti=endi+1;
2012    OCLL[i]=OCLLi;
2013    kill OCLLi;
2014  }
2015  return(OCLL);
2016}
2017//list OC = 1,2,3,4,5,6,7,8,9,10,11,12;
2018//subdividelist(OC,4);
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031proc orbitCones(list AF, intmat Q, list #)
2032"USAGE: orbitCones(AF, Q[, d]); AF: list of intvecs, Q: intmat, d: int
2033PURPOSE: Returns the list consisting of all cones Q(gam0) where gam0 in AF. If the optional argument d is given then the function returns only the orbit cones of dimension at least d
2034RETURN: a list of cones
2035EXAMPLE: example orbitCones; shows an example
2036"
2037{
2038  list OC;
2039  intvec gam0;
2040  int j;
2041  cone c;
2042  int d = 0;
2043  if (size(#)>0) {
2044    d = #[1];
2045  }
2046
2047  for(int i = 1; i <= size(AF); i++){
2048    gam0 = AF[i];
2049
2050    if(gam0 == 0){
2051      bigintmat M[1][nrows(Q)];
2052    } else {
2053      bigintmat M[size(gam0)][nrows(Q)];
2054
2055      for (j = 1; j <= size(gam0); j++){
2056        M[j,1..ncols(M)] = Q[1..nrows(Q),gam0[j]];
2057      }
2058    }
2059
2060    c = coneViaPoints(M);
2061
2062    if(listContainsCone(OC, c) == 0 && dimension(c)>=d){
2063      OC[size(OC)+1] = c;
2064    }
2065
2066    kill M;
2067  }
2068
2069  return(OC);
2070}
2071example
2072{
2073  echo=2;
2074  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
2075  ideal J =
2076    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
2077    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
2078    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
2079    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
2080    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
2081  intmat Q[5][10] =
2082    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2083    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2084    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2085    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2086    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2087
2088  list AF= afaces(J);
2089  print(size(AF));
2090  list OC = orbitCones(AF,Q);
2091  size(OC);
2092}
2093
2094
2095
2096///////////////////////////////////////
2097
2098proc GITfanFromOrbitCones(list OC, bigintmat Q, cone Qgamma, list #)
2099  "USAGE: GITfanFromOrbitCones(OC, Q, Qgamma [, file1, file2]); OC:list, Q:bigintmat, Qgamma:cone, file1:string, file2:string
2100PURPOSE: Returns the common refinement of the cones given in
2101the list OC which is supposed to contain the orbit cones intersected with Qgamma. The optional argument can be used
2102to specify one or two strings with file names, where the first file will contain the hashes of the
2103GIT-cones and the second argument the actual cones in their H-representation.
2104To obtain the whole GIT-fan Qgamma has to be take the cone generated by the columns of Q.
2105RETURN: a list containing the bigint hashes of the GIT cones.
2106EXAMPLE: example GITfanFromOrbitCones; shows an example
2107"
2108{
2109  /**
2110   * stores the hashes of all maximal GIT cones computed
2111   */
2112  list hashesOfCones;
2113  /**
2114   * stores to the corresponding maximal GIT cone in hashesOfCones
2115   * - 0, if guaranteed that all adjacent GIT cones are known
2116   *        or are to be computed in the next iteration       (*)
2117   * - hash as intvec, otherwise
2118   */
2119  list workingList;
2120
2121
2122  /**
2123   * compute starting cone
2124   */
2125  bigintmat w,v;
2126  cone lambda;
2127  intvec lambdaHash;
2128  while(dimension(lambda) <> nrows(Q)){
2129    w = randConeEl(transpose(Q),100);
2130    dbprint("testing "+string(w));
2131    if (containsRelatively(Qgamma,w)) {
2132      lambda,lambdaHash = GITcone(OC,w);
2133      dbprint("computed cone of dimension "+string(dimension(lambda)));
2134    }
2135  }
2136  int nCones = 1;     // essentially size(hashesOfCones)
2137  int nConesOpen = 1; // essentially size(workingList)+1, see (*) above
2138
2139
2140  /**
2141   * initialize lists
2142   */
2143  int posToInsert = 1;
2144  bigint hashToInsert = binaryToBigint(lambdaHash);
2145  hashesOfCones[1] = hashToInsert;
2146  workingList[1] = int(0);
2147  if (size(#)>0) {write(":w "+#[1],string(hashesOfCones[1]) + ",");}
2148  if (size(#)>1) {write(":w "+#[2],"list listOfMaximalCones;");writeGitconeToFile(lambda,#[2]);}
2149
2150
2151  /**
2152   * traverse fan
2153   */
2154  int i,t,tt;
2155  list FL;
2156  intvec neighbourHash;
2157  int mu = 1024;
2158  while (lambdaHash>0)
2159  {
2160    tt=timer;
2161
2162    /**
2163     * compute all facets of lambda
2164     */
2165    t = timer;
2166    FL = listOfFacetsAndInteriorVectors(lambda, Qgamma);
2167    dbprint("time for facets: "+string(timer - t));
2168
2169    /**
2170     * compute all neighbours of lambda
2171     */
2172    for (i=size(FL[1]); i>0; i--)
2173    {
2174      v = FL[1][i][1]; // interior facet normal
2175      w = FL[1][i][2]; // interior facet point
2176      neighbourHash = getNeighborHash(OC,w,v,mu);
2177      hashToInsert = binaryToBigint(neighbourHash);
2178      posToInsert = findPlaceToInsert(hashesOfCones,hashToInsert);
2179
2180      if(posToInsert > 0)
2181      {
2182        if (size(#)>0){write(":a "+#[1],string(binaryToBigint(neighbourHash)) + ",");}
2183        hashesOfCones = insertToList(hashesOfCones,hashToInsert,posToInsert);
2184        workingList = insertToList(workingList,neighbourHash,posToInsert);
2185        nConesOpen++;
2186        nCones++;
2187      }
2188    }
2189
2190    /**
2191     * pick lambdaHash and lambda for next iteration,
2192     * set respective entry in workingList to 0
2193     */
2194    lambdaHash = 0;
2195    for (i=size(workingList); i>0; i--)
2196    {
2197      if (typeof(workingList[i])=="intvec")
2198      {
2199        lambdaHash = workingList[i];
2200        lambda = gitConeFromHash(OC,lambdaHash);
2201        if (size(#)>1) {writeGitconeToFile(lambda,#[2]);}
2202        workingList[i] = int(0);
2203        break;
2204      }
2205    }
2206    nConesOpen--;
2207
2208    dbprint("overall: "+string(nCones)+"   open: "+string(nConesOpen)+"   time for loop: "+string(timer-tt));
2209  }
2210  return(hashesOfCones);
2211}
2212example
2213{
2214  echo=2;
2215  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
2216  ideal J =
2217    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
2218    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
2219    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
2220    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
2221    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
2222  intmat Q[5][10] =
2223    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2224    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2225    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2226    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2227    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2228
2229  list AF= afaces(J,nrows(Q));
2230  AF=fullDimImages(AF,Q);
2231  AF = minimalAfaces(AF);
2232  list OC = orbitCones(AF,Q);
2233  cone Qgamma = coneViaPoints(transpose(Q));
2234  list GIT = GITfanFromOrbitCones(OC,Q,Qgamma);
2235  size(GIT);
2236}
2237
2238
2239
2240
2241
2242proc GITfanParallel(list OC, intmat Q, cone Qgamma, list #)
2243  "USAGE: GITfanParallel(OC, Q, Qgamma [, file1]); OC:list, Q:intmat, Qgamma:cone, file1:string
2244PURPOSE: Returns the common refinement of the cones given in
2245the list OC which is supposed to contain the orbit cones intersected with Qgamma. The optional argument can be used to specify a name for a file which will contain the hashes of the GIT-cones.
2246To obtain the whole GIT-fan Qgamma has to be take the cone generated by the columns of Q.
2247RETURN: a list containing the bigint hashes of the GIT cones.
2248NOTE: The proceduce uses parallel computation for the construction of the GIT-cones.
2249EXAMPLE: example GITfanParallel; shows an example
2250"
2251{
2252  /**
2253   * stores the hashes of all maximal GIT cones computed
2254   */
2255  list hashesOfCones;
2256  /**
2257   * stores to the corresponding maximal GIT cone in hashesOfCones
2258   * - 0, if guaranteed that all adjacent GIT cones are known
2259   *        or are to be computed in the next iteration       (*)
2260   * - hash as intvec, otherwise
2261   */
2262  list workingList;
2263
2264
2265  /**
2266   * compute starting cone
2267   */
2268  bigintmat w,v;
2269  cone lambda;
2270  intvec lambdaHash;
2271  while(dimension(lambda) <> nrows(Q)){
2272    w = randConeEl(transpose(Q),100);
2273    dbprint("testing "+string(w));
2274    if (containsRelatively(Qgamma,w)) {
2275      lambda,lambdaHash = GITcone(OC,w);
2276      dbprint("computed cone of dimension "+string(dimension(lambda)));
2277    }
2278  }
2279  int nCones = 1;     // essentially size(hashesOfCones)
2280  int nConesOpen = 1; // essentially size(workingList)+1, see (*) above
2281
2282
2283  /**
2284   * initialize lists
2285   */
2286  bigint hashToInsert = binaryToBigint(lambdaHash);
2287  int posToInsert = 1;
2288  hashesOfCones[1] = hashToInsert;
2289  workingList[1] = int(0);
2290  if (size(#)>0) {write(":w "+#[1],string(binaryToBigint(lambdaHash)) + ",");}
2291  //if (size(#)>1) {write(":w "+#[2],"list listOfMaximalCones;");writeGitconeToFile(lambda,#[2]);}
2292
2293
2294  list iterationArgs = list(list(lambdaHash,OC,Qgamma));
2295  list iterationRes;
2296
2297  /**
2298   * traverse fan
2299   */
2300  int i,j,t,tloop;
2301  list FL;
2302  list neighbourHashes;
2303  intvec neighbourHash;
2304  while (size(iterationArgs)>0)
2305  {
2306    tloop=rtimer;
2307
2308    /**
2309     * compute all neighbours of lambda
2310     */
2311    t = rtimer;
2312    iterationRes = parallelWaitAll("computeNeighbourHashes",iterationArgs);
2313    dbprint("time neighbours: "+string(rtimer - t));
2314
2315    /**
2316     * central book keeping
2317     */
2318    t = rtimer;
2319    for (i=1; i<=size(iterationRes); i++)
2320    {
2321      neighbourHashes = iterationRes[i];
2322      for (j=1; j<=size(neighbourHashes); j++)
2323      {
2324        neighbourHash = neighbourHashes[j];
2325        hashToInsert = binaryToBigint(neighbourHash);
2326        posToInsert = findPlaceToInsert(hashesOfCones,hashToInsert);
2327        if(posToInsert > 0)
2328        {
2329          if (size(#)>0){write(":a "+#[1],string(binaryToBigint(neighbourHash)) + ",");}
2330          hashesOfCones = insertToList(hashesOfCones,hashToInsert,posToInsert);
2331          workingList = insertToList(workingList,neighbourHash,posToInsert);
2332          nConesOpen++;
2333          nCones++;
2334        }
2335      }
2336    }
2337    nConesOpen = nConesOpen - size(iterationArgs);
2338    dbprint("time bookkeeping: "+string(rtimer - t));
2339
2340    /**
2341     * pick arguments for next iteration,
2342     * set respective entry in workingList to 0
2343     */
2344    t = rtimer;
2345    iterationArgs = list();
2346    for (i=size(workingList); i>0; i--)
2347    {
2348      if (typeof(workingList[i])=="intvec")
2349      {
2350        iterationArgs[size(iterationArgs)+1] = list(workingList[i],OC,Qgamma);
2351        workingList[i] = int(0);
2352        if (size(iterationArgs) >= getcores())
2353        {
2354          break;
2355        }
2356      }
2357    }
2358    dbprint("time preparation: "+string(rtimer - t));
2359
2360    dbprint("overall: "+string(nCones)+"   open: "+string(nConesOpen)+"   time loop: "+string(rtimer-tloop));
2361  }
2362
2363  if (size(#)==0)
2364  {
2365    return(hashesOfCones);
2366  }
2367}
2368example
2369{
2370  echo=2;
2371  setcores(4);
2372  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
2373  ideal J =
2374    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
2375    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
2376    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
2377    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
2378    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
2379  intmat Q[5][10] =
2380    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2381    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2382    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2383    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2384    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2385
2386  list AF= afaces(J);
2387  print(size(AF));
2388  list OC = orbitCones(AF,Q);
2389  cone Qgamma = coneViaPoints(transpose(Q));
2390  list GIT = GITfanParallel(OC,Q,Qgamma);
2391  size(GIT);
2392}
2393
2394// not static to be used in parallel.lib
2395proc computeNeighbourHashes(intvec lambdaHash, list OC, cone Qgamma)
2396{
2397  /**
2398   * compute all facets of lambda
2399   */
2400  cone lambda = gitConeFromHash(OC,lambdaHash);
2401  list FL = listOfFacetsAndInteriorVectors(lambda, Qgamma);
2402
2403  /**
2404   * compute all minimal hashes of neighbours of lambda
2405   */
2406  bigintmat v,w;
2407  intvec neighbourHash;
2408  list neighbourHashes;
2409  for (int i=size(FL[1]); i>0; i--)
2410  {
2411    v = FL[1][i][1]; // interior facet normal
2412    w = FL[1][i][2]; // interior facet point
2413    neighbourHash = getNeighborHash(OC,w,v,1024);
2414    neighbourHashes[i] = neighbourHash;
2415  }
2416
2417  return (neighbourHashes);
2418}
2419
2420
2421
2422proc minimalAfaces(list listOfAfaces)
2423"USAGE: minimalAfaces(listOfAfaces); listOfAfaces: list
2424PURPOSE: Returns a list of all minimal a-faces. Note that listOfAfaces must only contain
2425afaces which project to full dimension.
2426RETURN: a list of intvecs
2427EXAMPLE: example minimalAfaces; shows an example
2428"
2429{
2430  int i,j;
2431  for (i=1; i<=size(listOfAfaces); i++)
2432  {
2433    for (j=1; j<=size(listOfAfaces); j++)
2434    {
2435      if (i!=j)
2436      {
2437        if (isSubset(listOfAfaces[i],listOfAfaces[j]))
2438        {
2439          listOfAfaces = delete(listOfAfaces,j);
2440          if (j<i)
2441          {
2442            i = i-1;
2443          }
2444          j = j-1;
2445        }
2446      }
2447    }
2448  }
2449  return(listOfAfaces);
2450}
2451example
2452{
2453  echo=2;
2454  setcores(4);
2455  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
2456  ideal J =
2457    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
2458    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
2459    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
2460    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
2461    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
2462  intmat Q[5][10] =
2463    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2464    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2465    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2466    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2467    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2468  list AF= afaces(J,nrows(Q));
2469  size(AF);
2470  AF=fullDimImages(AF,Q);
2471  size(AF);
2472  AF=minimalAfaces(AF);
2473  size(AF);
2474}
2475
2476
2477
2478proc GITfan(ideal J, intmat Q, list #)
2479"USAGE: GITfan(J,Q [, G]); J:ideal, Q:intmat, G:list
2480PURPOSE: Computes the GIT fan associated to J and Q. Optionally a symmetry group action on the column space of Q can be specified.
2481RETURN: a fan, the GIT fan.
2482NOTE: The proceduce uses parallel computation for the construction of the GIT-cones. The a-faces are not computed in parallel. This can be done by calling the aface procedure specifying a list of simplex faces. If used with the optional argument G, the orbit decomposition of the simplex of columns of Q is computed. Refer to the Singular documentation on how to do this more efficiently using GAP.
2483EXAMPLE: example GITfan; shows an example
2484"
2485{
2486  list GIT;
2487  list OC;
2488  if (size(#)>0){
2489      (GIT,OC) = GITfanWrapperWithSymmetry(J,Q,#);
2490  } else {
2491  list AF= afaces(J,nrows(Q));
2492  AF=fullDimImages(AF,Q);
2493  AF = minimalAfaces(AF);
2494  OC = orbitCones(AF,Q);
2495  cone Qgamma = coneViaPoints(transpose(Q));
2496  GIT = GITfanParallel(OC,Q,Qgamma);
2497  }
2498  fan Sigma = hashesToFan(GIT,OC);
2499  return(Sigma);
2500}
2501example
2502{
2503  echo=2;
2504  setcores(4);
2505  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
2506  ideal J =
2507    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
2508    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
2509    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
2510    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
2511    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
2512  intmat Q[5][10] =
2513    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2514    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2515    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2516    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2517    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2518  fan GIT = GITfan(J,Q);
2519
2520  intmat Q[5][10] =
2521    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2522    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2523    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2524    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2525    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2526  list simplexSymmetryGroup = G25Action();
2527  fan GIT2 = GITfan(J,Q,simplexSymmetryGroup);
2528
2529}
2530
2531
2532proc hashToCone(bigint v, list OC)
2533"USAGE: hashToCone(v, OC): v bigint, OC list of cones.
2534ASSUME: the elements of OC are the orbit cones used in the hash representation of the GIT cones.
2535RETURN: a cone, the intersection of the cones in OC according to the binary representation of the hash v.
2536EXAMPLE: example hashToCone; shows an example
2537"
2538{
2539  intvec J = bigintToBinary(v, size(OC));
2540  return(convexIntersection(list(OC[J])));
2541}
2542example
2543{
2544  echo = 2;
2545  setcores(4);
2546  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
2547  ideal J =
2548    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
2549    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
2550    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
2551    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
2552    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
2553  intmat Q[5][10] =
2554    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2555    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2556    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2557    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2558    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2559  list AF= afaces(J,nrows(Q));
2560  AF=fullDimImages(AF,Q);
2561  AF = minimalAfaces(AF);
2562  list OC = orbitCones(AF,Q);
2563  bigint v = 21300544;
2564  hashToCone(v, OC);
2565}
2566
2567
2568proc bigintToBinary(bigint n, int r)
2569"
2570USAGE: bigintToBinary(n, r): n bigint, r int.
2571ASSUME: n is smaller then 2^r.
2572RETURN: an intvec, with entries the positions of 1 in the binary representation of n with r bits.
2573EXAMPLE: example bigintToBinary; shows an example
2574"
2575{
2576  int k = r-1;
2577
2578  intvec v;
2579  bigint n0 = n;
2580
2581  while(n0 > 0){
2582    bigint tmp = bigint(2)^k;
2583
2584    while(tmp > n0){
2585      k--;
2586      tmp = bigint(2)^k;
2587    }
2588
2589    v = k+1,v;
2590    n0 = n0 - tmp;
2591    k--;
2592
2593    kill tmp;
2594  }
2595
2596  v = v[1..size(v)-1];
2597  return(v);
2598}
2599example
2600{
2601  echo = 2;
2602  bigintToBinary(bigint(2)^90-1, 90);
2603}
2604
2605
2606
2607
2608proc hashesToFan(list hashes, list OC)
2609"USAGE: hashesToFan(hashes, OC): hashes list of bigint, OC list of cones.
2610ASSUME: the elements of OC are the orbit cones used in the hash representation of the GIT cones.
2611RETURN: a fan, with maximal cones the intersections of the cones in OC according to the binary representation of the hashes.
2612EXAMPLE: example hashesToFan; shows an example
2613"
2614{
2615  fan Sigma = emptyFan(ambientDimension(OC[1]));
2616  for (int i=1;i<=size(hashes);i++){
2617    insertCone(Sigma,hashToCone(hashes[i],OC),0);
2618  }
2619  return(Sigma);
2620}
2621example
2622{
2623  echo = 2;
2624  setcores(4);
2625  ring R = 0,T(1..10),wp(1,1,1,1,1,1,1,1,1,1);
2626  ideal J =
2627    T(5)*T(10)-T(6)*T(9)+T(7)*T(8),
2628    T(1)*T(9)-T(2)*T(7)+T(4)*T(5),
2629    T(1)*T(8)-T(2)*T(6)+T(3)*T(5),
2630    T(1)*T(10)-T(3)*T(7)+T(4)*T(6),
2631    T(2)*T(10)-T(3)*T(9)+T(4)*T(8);
2632  intmat Q[5][10] =
2633    1, 1, 1, 1, 0, 0, 0, 0, 0, 0,
2634    1, 0, 0, 0, 1, 1, 1, 0, 0, 0,
2635    0, 1, 1, 0, 0, 0, -1, 1, 0, 0,
2636    0, 1, 0, 1, 0, -1, 0, 0, 1, 0,
2637    0, 0, 1, 1, -1, 0, 0, 0, 0, 1;
2638  list AF= afaces(J,nrows(Q));
2639  AF=fullDimImages(AF,Q);
2640  AF = minimalAfaces(AF);
2641  list OC = orbitCones(AF,Q);
2642  cone Qgamma = coneViaPoints(transpose(Q));
2643  list GIT = GITfanParallel(OC,Q,Qgamma);
2644  fan Sigma = hashesToFan(GIT,OC);
2645}
2646
2647
2648
2649
2650/////////////////////////////////////
2651
2652proc gkzFan(intmat Q)
2653"USAGE: gkzFan(Q); a: ideal, Q:intmat
2654PURPOSE: Returns the GKZ-fan of the matrix Q.
2655RETURN: a fan.
2656EXAMPLE: example gkzFan; shows an example
2657"
2658{
2659  // only difference to gitFan:
2660  // it suffices to consider all faces
2661  // that are simplicial:
2662  list OC = simplicialToricOrbitCones(Q);
2663  print(size(OC));
2664  cone Qgamma = coneViaPoints(transpose(Q));
2665  list GIT = GITfanParallel(OC,Q,Qgamma);
2666  fan Sigma = hashesToFan(GIT,OC);
2667  return(Sigma);
2668}
2669example
2670{
2671  echo=2;
2672  intmat Q[3][4] =
2673    1,0,1,0,
2674    0,1,0,1,
2675    0,0,1,1;
2676
2677  gkzFan(Q);
2678}
2679
2680
2681
2682/////////////////////////////////////
2683
2684// Computes all simplicial orbit cones
2685// w.r.t. the 0-ideal:
2686static proc simplicialToricOrbitCones(bigintmat Q){
2687  intvec gam0;
2688  list OC;
2689  cone c;
2690  int r = ncols(Q);
2691  int j;
2692
2693  for(int i = 1; i < 2^r; i++ ){
2694    gam0 = int2face(i,r);
2695
2696    // each simplicial cone is generated by
2697    // exactly nrows(Q) many columns of Q:
2698    if(size(gam0) == nrows(Q)){
2699      bigintmat M[size(gam0)][nrows(Q)];
2700
2701      for(j = 1; j <= size(gam0); j++){
2702        M[j,1..ncols(M)] = Q[1..nrows(Q),gam0[j]];
2703      }
2704
2705      c = coneViaPoints(M);
2706
2707      if((dimension(c) == nrows(Q)) and (!(listContainsCone(OC, c)))){
2708        OC[size(OC)+1] = c;
2709      }
2710
2711      kill M;
2712    }
2713  }
2714
2715  return(OC);
2716}
2717example
2718{
2719  echo = 2;
2720  bigintmat Q[3][4] =
2721  1,0,1,0,
2722  0,1,0,1,
2723  0,0,1,1;
2724
2725  list OC = simplicialToricOrbitCones(Q);
2726  print(OC);
2727
2728  bigintmat Q[5][15] =
2729    1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,
2730    0,1,0,0,0,1,0,0,0,1,1,1,0,0,0,
2731    0,0,1,0,0,0,1,0,0,1,0,0,1,1,0,
2732    0,0,0,1,0,0,0,1,0,0,1,0,1,0,1,
2733    0,0,0,0,1,0,0,0,1,0,0,1,0,1,1;
2734
2735  list OC = simplicialToricOrbitCones(Q);
2736  print(size(OC));
2737}
2738
2739
2740proc G25Action()
2741"USAGE: G25Action(Q);
2742PURPOSE: Returns a representation of S5 as a subgroup of S10 with the action on the Grassmannian G25.
2743RETURN: list of with elements of type permutation.
2744EXAMPLE: example G25Action; shows an example
2745"
2746{
2747list simplexSymmetryGroup = permutationFromIntvec(intvec( 1 .. 10 )),
2748permutationFromIntvec(intvec( 1, 2, 4, 3, 5, 7, 6, 9, 8, 10 )),
2749permutationFromIntvec(intvec( 1, 3, 2, 4, 6, 5, 7, 8, 10, 9 )),
2750permutationFromIntvec(intvec( 1, 3, 4, 2, 6, 7, 5, 10, 8, 9 )),
2751permutationFromIntvec(intvec( 1, 4, 2, 3, 7, 5, 6, 9, 10, 8 )),
2752permutationFromIntvec(intvec( 1, 4, 3, 2, 7, 6, 5, 10, 9, 8 )),
2753permutationFromIntvec(intvec( 1, 5, 6, 7, 2, 3, 4, 8, 9, 10 )),
2754permutationFromIntvec(intvec( 1, 5, 7, 6, 2, 4, 3, 9, 8, 10 )),
2755permutationFromIntvec(intvec( 1, 6, 5, 7, 3, 2, 4, 8, 10, 9 )),
2756permutationFromIntvec(intvec( 1, 6, 7, 5, 3, 4, 2, 10, 8, 9 )),
2757permutationFromIntvec(intvec( 1, 7, 5, 6, 4, 2, 3, 9, 10, 8 )),
2758permutationFromIntvec(intvec( 1, 7, 6, 5, 4, 3, 2, 10, 9, 8 )),
2759permutationFromIntvec(intvec( 2, 1, 3, 4, 5, 8, 9, 6, 7, 10 )),
2760permutationFromIntvec(intvec( 2, 1, 4, 3, 5, 9, 8, 7, 6, 10 )),
2761permutationFromIntvec(intvec( 2, 3, 1, 4, 8, 5, 9, 6, 10, 7 )),
2762permutationFromIntvec(intvec( 2, 3, 4, 1, 8, 9, 5, 10, 6, 7 )),
2763permutationFromIntvec(intvec( 2, 4, 1, 3, 9, 5, 8, 7, 10, 6 )),
2764permutationFromIntvec(intvec( 2, 4, 3, 1, 9, 8, 5, 10, 7, 6 )),
2765permutationFromIntvec(intvec( 2, 5, 8, 9, 1, 3, 4, 6, 7, 10 )),
2766permutationFromIntvec(intvec( 2, 5, 9, 8, 1, 4, 3, 7, 6, 10 )),
2767permutationFromIntvec(intvec( 2, 8, 5, 9, 3, 1, 4, 6, 10, 7 )),
2768permutationFromIntvec(intvec( 2, 8, 9, 5, 3, 4, 1, 10, 6, 7 )),
2769permutationFromIntvec(intvec( 2, 9, 5, 8, 4, 1, 3, 7, 10, 6 )),
2770permutationFromIntvec(intvec( 2, 9, 8, 5, 4, 3, 1, 10, 7, 6 )),
2771permutationFromIntvec(intvec( 3, 1, 2, 4, 6, 8, 10, 5, 7, 9 )),
2772permutationFromIntvec(intvec( 3, 1, 4, 2, 6, 10, 8, 7, 5, 9 )),
2773permutationFromIntvec(intvec( 3, 2, 1, 4, 8, 6, 10, 5, 9, 7 )),
2774permutationFromIntvec(intvec( 3, 2, 4, 1, 8, 10, 6, 9, 5, 7 )),
2775permutationFromIntvec(intvec( 3, 4, 1, 2, 10, 6, 8, 7, 9, 5 )),
2776permutationFromIntvec(intvec( 3, 4, 2, 1, 10, 8, 6, 9, 7, 5 )),
2777permutationFromIntvec(intvec( 3, 6, 8, 10, 1, 2, 4, 5, 7, 9 )),
2778permutationFromIntvec(intvec( 3, 6, 10, 8, 1, 4, 2, 7, 5, 9 )),
2779permutationFromIntvec(intvec( 3, 8, 6, 10, 2, 1, 4, 5, 9, 7 )),
2780permutationFromIntvec(intvec( 3, 8, 10, 6, 2, 4, 1, 9, 5, 7 )),
2781permutationFromIntvec(intvec( 3, 10, 6, 8, 4, 1, 2, 7, 9, 5 )),
2782permutationFromIntvec(intvec( 3, 10, 8, 6, 4, 2, 1, 9, 7, 5 )),
2783permutationFromIntvec(intvec( 4, 1, 2, 3, 7, 9, 10, 5, 6, 8 )),
2784permutationFromIntvec(intvec( 4, 1, 3, 2, 7, 10, 9, 6, 5, 8 )),
2785permutationFromIntvec(intvec( 4, 2, 1, 3, 9, 7, 10, 5, 8, 6 )),
2786permutationFromIntvec(intvec( 4, 2, 3, 1, 9, 10, 7, 8, 5, 6 )),
2787permutationFromIntvec(intvec( 4, 3, 1, 2, 10, 7, 9, 6, 8, 5 )),
2788permutationFromIntvec(intvec( 4, 3, 2, 1, 10, 9, 7, 8, 6, 5 )),
2789permutationFromIntvec(intvec( 4, 7, 9, 10, 1, 2, 3, 5, 6, 8 )),
2790permutationFromIntvec(intvec( 4, 7, 10, 9, 1, 3, 2, 6, 5, 8 )),
2791permutationFromIntvec(intvec( 4, 9, 7, 10, 2, 1, 3, 5, 8, 6 )),
2792permutationFromIntvec(intvec( 4, 9, 10, 7, 2, 3, 1, 8, 5, 6 )),
2793permutationFromIntvec(intvec( 4, 10, 7, 9, 3, 1, 2, 6, 8, 5 )),
2794permutationFromIntvec(intvec( 4, 10, 9, 7, 3, 2, 1, 8, 6, 5 )),
2795permutationFromIntvec(intvec( 5, 1, 6, 7, 2, 8, 9, 3, 4, 10 )),
2796permutationFromIntvec(intvec( 5, 1, 7, 6, 2, 9, 8, 4, 3, 10 )),
2797permutationFromIntvec(intvec( 5, 2, 8, 9, 1, 6, 7, 3, 4, 10 )),
2798permutationFromIntvec(intvec( 5, 2, 9, 8, 1, 7, 6, 4, 3, 10 )),
2799permutationFromIntvec(intvec( 5, 6, 1, 7, 8, 2, 9, 3, 10, 4 )),
2800permutationFromIntvec(intvec( 5, 6, 7, 1, 8, 9, 2, 10, 3, 4 )),
2801permutationFromIntvec(intvec( 5, 7, 1, 6, 9, 2, 8, 4, 10, 3 )),
2802permutationFromIntvec(intvec( 5, 7, 6, 1, 9, 8, 2, 10, 4, 3 )),
2803permutationFromIntvec(intvec( 5, 8, 2, 9, 6, 1, 7, 3, 10, 4 )),
2804permutationFromIntvec(intvec( 5, 8, 9, 2, 6, 7, 1, 10, 3, 4 )),
2805permutationFromIntvec(intvec( 5, 9, 2, 8, 7, 1, 6, 4, 10, 3 )),
2806permutationFromIntvec(intvec( 5, 9, 8, 2, 7, 6, 1, 10, 4, 3 )),
2807permutationFromIntvec(intvec( 6, 1, 5, 7, 3, 8, 10, 2, 4, 9 )),
2808permutationFromIntvec(intvec( 6, 1, 7, 5, 3, 10, 8, 4, 2, 9 )),
2809permutationFromIntvec(intvec( 6, 3, 8, 10, 1, 5, 7, 2, 4, 9 )),
2810permutationFromIntvec(intvec( 6, 3, 10, 8, 1, 7, 5, 4, 2, 9 )),
2811permutationFromIntvec(intvec( 6, 5, 1, 7, 8, 3, 10, 2, 9, 4 )),
2812permutationFromIntvec(intvec( 6, 5, 7, 1, 8, 10, 3, 9, 2, 4 )),
2813permutationFromIntvec(intvec( 6, 7, 1, 5, 10, 3, 8, 4, 9, 2 )),
2814permutationFromIntvec(intvec( 6, 7, 5, 1, 10, 8, 3, 9, 4, 2 )),
2815permutationFromIntvec(intvec( 6, 8, 3, 10, 5, 1, 7, 2, 9, 4 )),
2816permutationFromIntvec(intvec( 6, 8, 10, 3, 5, 7, 1, 9, 2, 4 )),
2817permutationFromIntvec(intvec( 6, 10, 3, 8, 7, 1, 5, 4, 9, 2 )),
2818permutationFromIntvec(intvec( 6, 10, 8, 3, 7, 5, 1, 9, 4, 2 )),
2819permutationFromIntvec(intvec( 7, 1, 5, 6, 4, 9, 10, 2, 3, 8 )),
2820permutationFromIntvec(intvec( 7, 1, 6, 5, 4, 10, 9, 3, 2, 8 )),
2821permutationFromIntvec(intvec( 7, 4, 9, 10, 1, 5, 6, 2, 3, 8 )),
2822permutationFromIntvec(intvec( 7, 4, 10, 9, 1, 6, 5, 3, 2, 8 )),
2823permutationFromIntvec(intvec( 7, 5, 1, 6, 9, 4, 10, 2, 8, 3 )),
2824permutationFromIntvec(intvec( 7, 5, 6, 1, 9, 10, 4, 8, 2, 3 )),
2825permutationFromIntvec(intvec( 7, 6, 1, 5, 10, 4, 9, 3, 8, 2 )),
2826permutationFromIntvec(intvec( 7, 6, 5, 1, 10, 9, 4, 8, 3, 2 )),
2827permutationFromIntvec(intvec( 7, 9, 4, 10, 5, 1, 6, 2, 8, 3 )),
2828permutationFromIntvec(intvec( 7, 9, 10, 4, 5, 6, 1, 8, 2, 3 )),
2829permutationFromIntvec(intvec( 7, 10, 4, 9, 6, 1, 5, 3, 8, 2 )),
2830permutationFromIntvec(intvec( 7, 10, 9, 4, 6, 5, 1, 8, 3, 2 )),
2831permutationFromIntvec(intvec( 8, 2, 5, 9, 3, 6, 10, 1, 4, 7 )),
2832permutationFromIntvec(intvec( 8, 2, 9, 5, 3, 10, 6, 4, 1, 7 )),
2833permutationFromIntvec(intvec( 8, 3, 6, 10, 2, 5, 9, 1, 4, 7 )),
2834permutationFromIntvec(intvec( 8, 3, 10, 6, 2, 9, 5, 4, 1, 7 )),
2835permutationFromIntvec(intvec( 8, 5, 2, 9, 6, 3, 10, 1, 7, 4 )),
2836permutationFromIntvec(intvec( 8, 5, 9, 2, 6, 10, 3, 7, 1, 4 )),
2837permutationFromIntvec(intvec( 8, 6, 3, 10, 5, 2, 9, 1, 7, 4 )),
2838permutationFromIntvec(intvec( 8, 6, 10, 3, 5, 9, 2, 7, 1, 4 )),
2839permutationFromIntvec(intvec( 8, 9, 2, 5, 10, 3, 6, 4, 7, 1 )),
2840permutationFromIntvec(intvec( 8, 9, 5, 2, 10, 6, 3, 7, 4, 1 )),
2841permutationFromIntvec(intvec( 8, 10, 3, 6, 9, 2, 5, 4, 7, 1 )),
2842permutationFromIntvec(intvec( 8, 10, 6, 3, 9, 5, 2, 7, 4, 1 )),
2843permutationFromIntvec(intvec( 9, 2, 5, 8, 4, 7, 10, 1, 3, 6 )),
2844permutationFromIntvec(intvec( 9, 2, 8, 5, 4, 10, 7, 3, 1, 6 )),
2845permutationFromIntvec(intvec( 9, 4, 7, 10, 2, 5, 8, 1, 3, 6 )),
2846permutationFromIntvec(intvec( 9, 4, 10, 7, 2, 8, 5, 3, 1, 6 )),
2847permutationFromIntvec(intvec( 9, 5, 2, 8, 7, 4, 10, 1, 6, 3 )),
2848permutationFromIntvec(intvec( 9, 5, 8, 2, 7, 10, 4, 6, 1, 3 )),
2849permutationFromIntvec(intvec( 9, 7, 4, 10, 5, 2, 8, 1, 6, 3 )),
2850permutationFromIntvec(intvec( 9, 7, 10, 4, 5, 8, 2, 6, 1, 3 )),
2851permutationFromIntvec(intvec( 9, 8, 2, 5, 10, 4, 7, 3, 6, 1 )),
2852permutationFromIntvec(intvec( 9, 8, 5, 2, 10, 7, 4, 6, 3, 1 )),
2853permutationFromIntvec(intvec( 9, 10, 4, 7, 8, 2, 5, 3, 6, 1 )),
2854permutationFromIntvec(intvec( 9, 10, 7, 4, 8, 5, 2, 6, 3, 1 )),
2855permutationFromIntvec(intvec( 10, 3, 6, 8, 4, 7, 9, 1, 2, 5 )),
2856permutationFromIntvec(intvec( 10, 3, 8, 6, 4, 9, 7, 2, 1, 5 )),
2857permutationFromIntvec(intvec( 10, 4, 7, 9, 3, 6, 8, 1, 2, 5 )),
2858permutationFromIntvec(intvec( 10, 4, 9, 7, 3, 8, 6, 2, 1, 5 )),
2859permutationFromIntvec(intvec( 10, 6, 3, 8, 7, 4, 9, 1, 5, 2 )),
2860permutationFromIntvec(intvec( 10, 6, 8, 3, 7, 9, 4, 5, 1, 2 )),
2861permutationFromIntvec(intvec( 10, 7, 4, 9, 6, 3, 8, 1, 5, 2 )),
2862permutationFromIntvec(intvec( 10, 7, 9, 4, 6, 8, 3, 5, 1, 2 )),
2863permutationFromIntvec(intvec( 10, 8, 3, 6, 9, 4, 7, 2, 5, 1 )),
2864permutationFromIntvec(intvec( 10, 8, 6, 3, 9, 7, 4, 5, 2, 1 )),
2865permutationFromIntvec(intvec( 10, 9, 4, 7, 8, 3, 6, 2, 5, 1 )),
2866permutationFromIntvec(intvec( 10, 9, 7, 4, 8, 6, 3, 5, 2, 1 ));
2867return(simplexSymmetryGroup);
2868}
2869example
2870{
2871  echo = 2;
2872  G25Action();
2873}
2874
2875
2876proc findOrbits(list G, int #)
2877"USAGE: findOrbits(G [,d]); G list of permutations in a subgroup of the symmetric group; d int minimum cardinality of simplices to be considered; if d is not specified all orbits are computed.
2878PURPOSE: Computes the orbit decomposition of the action of G.
2879RETURN: list of intvec.
2880EXAMPLE: example findOrbits; shows an example
2881"
2882{
2883int d;
2884if (size(#)>0){d=#;}
2885int n = size(permutationToIntvec(G[1]));
2886list listOrbits;
2887list finished;
2888int tst;
2889bigint startel;
2890intvec startelbin;
2891list neworbit,neworbitint;
2892int i,posToInsert;
2893bigint nn;
2894while (size(finished)<2^n){
2895   startel=0;
2896   if (size(finished)>0){
2897      tst=0;
2898      while ((tst==0) and (startel+1<=size(finished))){
2899        if (finished[int(startel+1)]<>startel){
2900          tst=1;
2901        } else {
2902          startel=startel+1;
2903        }
2904      }
2905   }
2906   if (startel==0){
2907     neworbit[1]= list();
2908     neworbitint[1]=0;
2909   } else {
2910      startelbin=bigintToBinary(startel,n);
2911       neworbitint=list(startel);
2912       for (i=2;i<=size(G);i++){
2913         nn=binaryToBigint(applyPermutationToIntvec(startelbin,G[i]));
2914         //nn;neworbitint;
2915         //"place to insert";
2916         posToInsert = findPlaceToInsert(neworbitint,nn);
2917         //"pos";posToInsert;
2918         if(posToInsert > 0)
2919         {
2920          //"vorher";neworbitint;
2921          neworbitint = insertToList(neworbitint,nn,posToInsert);
2922          //"nachher";neworbitint;
2923         }
2924       }
2925       for (i=1;i<=size(neworbitint);i++){
2926          neworbit[i]=bigintToBinary(neworbitint[i],n);
2927       }
2928   }
2929   if (size(neworbit[1])>=d){
2930     listOrbits[size(listOrbits)+1]=neworbit;
2931   }
2932   finished=sort(finished+neworbitint)[1];
2933}
2934return(listOrbits);}
2935example
2936{
2937list G = G25Action();
2938list orb = findOrbits(G);
2939for (int i=1;i<=size(orb);i++){orb[i][1];}
2940}
2941
2942
2943
2944static proc GITfanWrapperWithSymmetry(ideal J, intmat Q, list simplexSymmetryGroup){
2945  list orb = findOrbits(simplexSymmetryGroup,nrows(Q));
2946  list simplexOrbitRepresentatives;
2947  for (int i=1;i<=size(orb);i++){simplexOrbitRepresentatives[i]=orb[i][1];}
2948  list afaceOrbitRepresentatives=afaces(J,simplexOrbitRepresentatives);
2949  list fulldimAfaceOrbitRepresentatives=fullDimImages(afaceOrbitRepresentatives,Q);
2950  list afaceOrbits=computeAfaceOrbits(fulldimAfaceOrbitRepresentatives,simplexSymmetryGroup);
2951  list minAfaceOrbits = minimalAfaceOrbits(afaceOrbits);
2952  list listOfOrbitConeOrbits = orbitConeOrbits(minAfaceOrbits,Q);
2953  list listOfMinimalOrbitConeOrbits = minimalOrbitConeOrbits(listOfOrbitConeOrbits);
2954  list Asigma = groupActionOnQImage(simplexSymmetryGroup,Q);
2955  list actionOnOrbitconeIndices = groupActionOnHashes(Asigma,listOfOrbitConeOrbits);
2956  list OClist = listOfOrbitConeOrbits[1];
2957  for (i =2;i<=size(listOfOrbitConeOrbits);i++){
2958    OClist = OClist + listOfOrbitConeOrbits[i];
2959  }
2960  cone mov = coneViaPoints(transpose(Q));
2961  mov = canonicalizeCone(mov);
2962  list Sigma = GITfanParallelSymmetric(OClist, Q, mov, actionOnOrbitconeIndices);
2963  return(Sigma, OClist);
2964}
2965///////////////////////////////////////
2966
2967proc gitCone(ideal a, bigintmat Q, bigintmat w)
2968"USAGE: gitCone(a, Q, w); a: ideal, Q:bigintmat, w:bigintmat
2969PURPOSE: Returns the GIT-cone lambda(w), i.e. the intersection of all
2970orbit cones containing the vector w.
2971NOTE: call this only if you are interested in a single GIT-cone.
2972RETURN: a cone.
2973EXAMPLE: example gitCone; shows an example
2974"
2975{
2976  list OC =  orbitConesOld(a, intmat(Q));
2977  cone lambda = nrows(Q);
2978
2979  for(int i = 1; i <= size(OC); i++)
2980  {
2981    cone c = OC[i];
2982
2983    if(containsInSupport(c, w))
2984    {
2985      lambda = convexIntersectionOld(lambda, c);
2986    }
2987
2988    kill c;
2989  }
2990
2991  return(lambda);
2992}
2993example
2994{
2995  echo=2;
2996  intmat Q[3][4] =
2997    1,0,1,0,
2998    0,1,0,1,
2999    0,0,1,1;
3000
3001  ring R = 0,T(1..4),dp;
3002  ideal a = 0;
3003
3004  bigintmat w[1][3] = 3,3,1;
3005  cone lambda = gitCone(a, Q, w);
3006  rays(lambda);
3007
3008  bigintmat w2[1][3] = 1,1,1;
3009  cone lambda2 = gitCone(a, Q, w2);
3010  rays(lambda2);
3011}
3012
3013proc orbitConesOld(ideal a, bigintmat Q, list #)
3014"USAGE:  orbitConesOld(a, Q, b, c); a: ideal, Q: bigintmat, b: int, c: int
3015PURPOSE: Returns a list consisting of all cones Q(gam0) where gam0 is an a-face.
3016         Moreover, it is possible to specify a dimensional bound b,
3017         upon which only cones of that dimension and above are returned.
3018         Lastly, as the computation is parallizable, one can specify c,
3019         the number of cores to be used by the computation.
3020RETURN:  a list of cones
3021EXAMPLE: example orbitConesOld; shows an example
3022"
3023{
3024  list AF;
3025
3026  if((size(#) > 1) and (typeof(#[2]) == "int"))
3027  {
3028    AF = afaces(a, nrows(Q), #[2]);
3029  }
3030  else
3031  {
3032    AF = afaces(a, nrows(Q));
3033  }
3034
3035  int dimensionBound = 0;
3036  if((size(#) > 0) and (typeof(#[1]) == "int"))
3037  {
3038    dimensionBound = #[1];
3039  }
3040
3041  list OC;
3042  intvec gam0;
3043  int j;
3044
3045  for(int i = 1; i <= size(AF); i++)
3046  {
3047    gam0 = AF[i];
3048
3049    if(gam0 == 0)
3050    {
3051      bigintmat M[1][nrows(Q)];
3052    }
3053    else
3054    {
3055      bigintmat M[size(gam0)][nrows(Q)];
3056      for (j = 1; j <= size(gam0); j++)
3057      {
3058        M[j,1..ncols(M)] = Q[1..nrows(Q),gam0[j]];
3059      }
3060    }
3061    cone c = coneViaPoints(M);
3062
3063    if((dimension(c) >= dimensionBound) and (!(listContainsCone(OC, c))))
3064    {
3065      OC[size(OC)+1] = c;
3066    }
3067
3068    kill M, c;
3069  }
3070
3071  return(OC);
3072}
3073example
3074{
3075  echo=2;
3076  intmat Q[3][4] =
3077    1,0,1,0,
3078    0,1,0,1,
3079    0,0,1,1;
3080
3081  ring R = 0,T(1..4),dp;
3082  ideal a = 0;
3083
3084  orbitConesOld(a, Q);
3085}
3086
Note: See TracBrowser for help on using the repository browser.