~ubuntu-branches/ubuntu/saucy/gfan/saucy-proposed

« back to all changes in this revision

Viewing changes to app_main.cpp

  • Committer: Package Import Robot
  • Author(s): Cédric Boutillier
  • Date: 2013-07-09 10:44:01 UTC
  • mfrom: (2.1.2 experimental)
  • Revision ID: package-import@ubuntu.com-20130709104401-5q66ozz5j5af0dak
Tags: 0.5+dfsg-3
* Upload to unstable.
* modify remove_failing_tests_on_32bits.patch to replace command of
  0009RenderStairCase test with an empty one instead of deleting it.
* remove lintian override about spelling error

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include "termorder.h"
18
18
#include "ep_standard.h"
19
19
#include "ep_xfig.h"
 
20
#include "field_rationalfunctions2.h"
20
21
#include "gfanapplication.h"
21
22
#include "timer.h"
22
23
#include "log.h"
23
24
 
 
25
#include "traverser_groebnerfan.h"
 
26
 
24
27
static Timer globalTimer("Global-timer",1);
25
28
 
26
29
class GCats : public GFanApplication
27
30
{
 
31
  const char *name1;
28
32
  SimpleOption optionInputIsGroebnerBasis;
29
33
  SimpleOption optionSymmetry;
30
34
  SimpleOption optionEchoSymmetry;
31
35
  SimpleOption optionSubspace;
32
36
  //  SimpleOption optionPerformanceTimer;
33
37
  SimpleOption optionDisableSymmetryTest;
 
38
  IntegerOption optionParameters;
34
39
public:
 
40
  bool includeInDefaultInstallation()
 
41
  {
 
42
    return name1[0]!=0;//Make sure that "gfan" itself does not go to the documentation section of the manual.
 
43
  }
35
44
  const char *helpText()
36
45
  {
37
 
    return "This is a program for computing all reduced Groebner bases of a polynomial ideal. It takes a generating set for the ideal as input. By default the enumeration is done by an almost memoryless reverse search. If the ideal is symmetric the symmetry option is useful and enumeration will be done up to symmetry using a breadth first search. The program needs a starting Groebner basis to do its computations. If the -g option is not specified it will compute one using Buchberger's algorithm.\n";
 
46
#define HELP "This is a program for computing all reduced Groebner bases of a polynomial ideal. It takes the ring and a generating set for the ideal as input. By default the enumeration is done by an almost memoryless reverse search. If the ideal is symmetric the symmetry option is useful and enumeration will be done up to symmetry using a breadth first search. The program needs a starting Groebner basis to do its computations. If the -g option is not specified it will compute one using Buchberger's algorithm.\n"
 
47
//    if(name1[0])
 
48
//      return "This is the Gfan program for computing Groebner fans and tropical vaieties"HELP;
 
49
    return HELP;
38
50
  }
39
 
  GCats():
 
51
  GCats(const char *name2):
 
52
    name1(name2),
40
53
    //    optionPerformanceTimer("-T",
41
54
    //                     "Enable performance timer.\n"),
42
55
    optionInputIsGroebnerBasis("-g",
48
61
    optionEchoSymmetry("-e","Echo. Output the generators for the symmetry group.\n"),
49
62
    optionSubspace("--subspace",
50
63
                   "Only do breadth first search on cones with their interior intersecting a specified subspace. The subspace is given by a list of hyperplane normals at the end of the input. The intersection of the hyperplanes is the subspace being specified. Note that the set of Groebner cones intersecting the subspace could be disconnected and that only one connected component is computed. Works only together with --symmetry.\n"),
51
 
    optionDisableSymmetryTest("--disableSymmetryTest","When using --symmetry this option will disable the check that the group read off from the input actually is a symmetry group with respect to the input ideal.\n")
 
64
    optionDisableSymmetryTest("--disableSymmetryTest","When using --symmetry this option will disable the check that the group read off from the input actually is a symmetry group with respect to the input ideal.\n"),
 
65
    optionParameters("--parameters","With this option you can specify how many variables to treat as parameters instead of variables. This makes it possible to do computations where the coefficient field is the field of rational functions in the parameters. This does not work well at the moment.",0)
52
66
  {
53
67
    registerOptions();
54
 
  }    
 
68
    optionSubspace.hide();//Is not supported anymore
 
69
  }
55
70
 
56
 
  char *name()
 
71
  const char *name()
57
72
  {
58
 
    return "";
 
73
    return name1;
 
74
    //    return "";
59
75
  }
60
76
 
61
77
  int main()
62
78
  {
63
 
    bool minkowski=false;//Does the Minkowski sum trick work?
64
 
    //    Field::printList(Stderr);
65
 
 
66
 
    //    LpSolver::printList(Stderr);
67
 
    //    lpSetSolver("cddgmp");
68
 
     
69
 
    /*    FieldElement a(2);
70
 
    FieldElement b(3);
71
 
    b*=a;
72
 
    AsciiPrinter(Stdout).printFieldElement(a+b);
73
 
 
74
 
    return 1;
75
 
    */
 
79
    if(name1[0]==0)
 
80
      {
 
81
        debug<<"This is the Gfan program for computing Groebner fans and tropical varieties.\n"
 
82
        "Use the command \"gfan list\" to view all subcommands.\n"
 
83
        "The command \"gfan\" is deprecate for computing all Groebner bases of an ideal.\n"
 
84
        "Please use subcommand \"gfan _bases\" instead. Awaiting input. <Ctrl>-D to end.\n";
 
85
      }
 
86
 
76
87
    LexicographicTermOrder myOrder;
77
 
    
 
88
 
78
89
    PolynomialSet g=FileParser(Stdin).parsePolynomialSetWithRing();
79
 
    
 
90
    if(optionParameters.getValue())g=makeVariablesParameters(makeVariablesParameters(g.getRing(),optionParameters.getValue()),g);
 
91
 
80
92
    log3 AsciiPrinter(Stderr).printPolynomialSet(g);
81
93
    AsciiPrinter(Stdout).printPolynomialRing(g.getRing());
82
94
 
90
102
 
91
103
 
92
104
    bool outputLatex=true;
93
 
    
 
105
 
94
106
    Printer *P;
95
107
    LatexPrinter *Q;
96
 
    FILE *latexFile;    
 
108
    FILE *latexFile;
97
109
 
98
110
    globalTimer.on();
99
 
    if(!minkowski)
100
111
    {
101
112
      if(optionInputIsGroebnerBasis.getValue())
102
113
        {
112
123
        }
113
124
      log1 fprintf(Stderr,"A reduced Groebner basis has been computed\n");
114
125
    }
115
 
      
 
126
 
116
127
    SymmetryGroup s(g.numberOfVariablesInRing());
117
128
 
 
129
    IntegerVectorList generators;
118
130
    {
119
131
      EnumerationAlgorithm *rs;
120
132
      if(optionSymmetry.getValue())
121
133
        {
122
 
          IntegerVectorList generators=FileParser(Stdin).parseIntegerVectorList();
123
 
          if(!minkowski)
 
134
          generators=FileParser(Stdin).parseIntegerVectorList();
124
135
            if(!optionDisableSymmetryTest.getValue())
125
136
              {
126
137
                for(IntegerVectorList::iterator i=generators.begin();i!=generators.end();i++)
132
143
 
133
144
          s.computeClosure(generators);
134
145
          log1 s.print(Stderr);
135
 
          BreadthFirstSearch *bs=new BreadthFirstSearch(s,minkowski);
136
 
          if(optionSubspace.getValue())
137
 
            bs->setSubspace(FileParser(Stdin).parseIntegerVectorList());
138
 
          rs=bs;
139
 
 
140
 
          if(optionEchoSymmetry.getValue())
141
 
            AsciiPrinter(Stdout).printVectorList(generators);
 
146
 
 
147
          if(0)
 
148
          {//using old breadth first traversal
 
149
                  BreadthFirstSearch *bs=new BreadthFirstSearch(s,/*minkowski*/0);
 
150
                  /*      if(optionSubspace.getValue())
 
151
                        bs->setSubspace(FileParser(Stdin).parseIntegerVectorList());
 
152
                   */
 
153
                  rs=bs;
 
154
 
 
155
                  if(optionEchoSymmetry.getValue())AsciiPrinter(Stdout).printVectorList(generators);
 
156
                  ep->open(Stdout);
 
157
 
 
158
                  rs->setEnumerationTarget(ep);
 
159
                  rs->enumerate(g);
 
160
                  delete rs;
 
161
          }
 
162
          else
 
163
          {//using new traversal
 
164
                GroebnerFanTraverser traverser(g);
 
165
                TargetGlue target(*ep);
 
166
                if(optionEchoSymmetry.getValue())AsciiPrinter(Stdout).printVectorList(generators);
 
167
                ep->open(Stdout);
 
168
                symmetricTraverse(traverser,target,&s);
 
169
          }
 
170
 
142
171
        }
143
172
      else
144
 
        rs=new ReverseSearch(myOrder);
145
 
 
146
 
      //      rs->setProgressPrinting(true);
 
173
      {
 
174
          rs=new ReverseSearch(myOrder);
147
175
      ep->open(Stdout);
148
176
      rs->setEnumerationTarget(ep);
149
 
      log1
150
 
        {
151
 
          fprintf(Stderr,"Enumerating...\n");
152
 
        }
153
177
      rs->enumerate(g);
154
178
      delete rs;
155
 
    }      
 
179
      }
 
180
    }
156
181
 
157
182
    ep->close();
158
183
    delete ep;
159
184
 
160
185
    printf("\n");
 
186
 
161
187
    globalTimer.off();
162
188
        //    if(optionPerformanceTimer.getValue())Timer::printList();
163
 
 
 
189
 
164
190
    return 0;
165
191
  }
166
192
};
167
193
 
168
 
static GCats theApplication;
 
194
static GCats theApplication("_bases");
 
195
static GCats theApplication2("");
169
196