source: git/Singular/LIB/gitfan.lib

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