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

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