File: app_topolyhedralfan.cpp

package info (click to toggle)
gfan 0.3dfsg-1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 2,012 kB
  • ctags: 1,935
  • sloc: cpp: 17,728; makefile: 251
file content (80 lines) | stat: -rw-r--r-- 2,697 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "parser.h"
#include "printer.h"
#include "polynomial.h"
#include "wallideal.h"
#include "lp.h"
#include "polyhedralcone.h"
#include "gfanapplication.h"
#include "polyhedralfan.h"
#include "halfopencone.h"
#include "symmetry.h"

class ToPolyhedralFanApplication : public GFanApplication
{
  SimpleOption optionRestrict;
  //  SimpleOption optionPair;
  SimpleOption optionSymmetry;
public:
  const char *helpText()
  {
    return "This program takes a list of reduced Groebner bases and produces the fan of all faces of these. In this way by giving the complete list of reduced Groebner bases, the Groebner fan can be computed as a polyhedral complex. The option --restrict lets the user choose between computing the Groebner fan or the restricted Groebner fan.\n";
  }
  ToPolyhedralFanApplication():
    optionSymmetry("--symmetry",
		   "Tell the program to read in generators for a group of symmetries (subgroup of $S_n$) after having read in the ring. The output is grouped according to these symmetries. Only one representative for each orbit is needed on the input.\n"),
    optionRestrict("--restrict","Add an inequality for each coordinate, so that the the cones are restricted to the non-negative orthant.")
    //    optionPair("--pair","The Groebner cone is given by a pair of compatible Groebner bases. The first basis is for the initial ideal and the second for the ideal itself. See the tropical section of the manual.")
  {
    registerOptions();
  }

  char *name()
  {
    return "_topolyhedralfan";
  }

  int main()
  {
    PolynomialRing r=FileParser(Stdin).parsePolynomialRing();

    int n=r.getNumberOfVariables();
    
    SymmetryGroup s(n);
    if(optionSymmetry.getValue())
      s.computeClosure(FileParser(Stdin).parseIntegerVectorList());

    PolyhedralFan F(n);

    PolynomialSetList l=FileParser(Stdin).parsePolynomialSetList(r);

    for(PolynomialSetList::const_iterator i=l.begin();i!=l.end();i++)
      {
	PolynomialSet g=*i;
	PolynomialSet m=g.markedTermIdeal();

	IntegerVectorList equalities=wallInequalities(m);
	IntegerVectorList normals=algebraicTest(wallInequalities(g),g);
	if(optionRestrict.getValue())
	  {
	    for(int i=0;i<n;i++)
	      normals.push_back(IntegerVector::standardVector(n,i));
	  }

	PolyhedralCone c(normals,equalities,n);
	c.canonicalize();
	//      AsciiPrinter(Stdout).printPolyhedralCone(c);

	/*	IntegerVectorList empty;
	HalfOpenCone C(n,c.getEquations(),c.getHalfSpaces(),empty,true);
	PolyhedralFan F=faceComplexOfCone(C);
	*/
	F.insert(c);
      }

    AsciiPrinter P(Stdout);
    F.printWithIndices(&P,false,&s,optionSymmetry.getValue());
    return 0;
  }
};

static ToPolyhedralFanApplication theApplication;