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

« back to all changes in this revision

Viewing changes to app_fvector.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:
1
 
#include "parser.h"
2
 
#include "printer.h"
3
 
#include "polynomial.h"
4
 
#include "division.h"
5
 
#include "buchberger.h"
6
 
#include "wallideal.h"
7
 
#include "lp.h"
8
 
#include "reversesearch.h"
9
 
#include "polyhedralfan.h"
10
 
#include "breadthfirstsearch.h"
11
 
#include "termorder.h"
12
 
#include "ep_standard.h"
13
 
#include "ep_xfig.h"
14
 
#include "gfanapplication.h"
15
 
#include "timer.h"
16
 
#include "dimension.h"
17
 
#include "tropical.h"
18
 
#include "tropical2.h"
19
 
 
20
 
class FVectorApplication : public GFanApplication
21
 
{
22
 
  IntegerOption debugOption;
23
 
  SimpleOption listInitialIdealsOption;
24
 
  SimpleOption checkBgOption;
25
 
public:
26
 
  bool includeInDefaultInstallation()
27
 
  {
28
 
    return false;
29
 
  }
30
 
  const char *helpText()
31
 
  {
32
 
    return "This program takes the complete list of reduced Groebner bases for a homogeneous ideal and outputs the f-vector for the Groebner fan.\n";
33
 
  }
34
 
  FVectorApplication():
35
 
    checkBgOption("--bg","Check BG theorem.\n"),
36
 
    listInitialIdealsOption("-l","List all initial ideals.\n"),
37
 
    debugOption("-d","Tell the program to print out the partial f-vector for every nth Groebner basis. Besides printing the partial f-vector on the stderr the program also tries to write it to the file gfan_fvector_temporary.",0)
38
 
  {
39
 
    registerOptions();
40
 
  }    
41
 
 
42
 
  char *name()
43
 
  {
44
 
    return "_fvector";
45
 
  }
46
 
 
47
 
  int main()
48
 
  {
49
 
    //    Field::printList(Stderr);
50
 
 
51
 
    LpSolver::printList(Stderr);
52
 
    lpSetSolver("cddgmp");
53
 
     
54
 
    FileParser p(Stdin);
55
 
 
56
 
    PolynomialRing r=p.parsePolynomialRing();
57
 
    int c=p.nextNonBlank();
58
 
    
59
 
    IntegerVector f(0);
60
 
    IntegerVector fTrop(0);
61
 
    int homog=-1;
62
 
    int n=-1;
63
 
 
64
 
    bool first=true;
65
 
    int counter=0;
66
 
    assert(p.isLeftBracket(c));
67
 
    if(listInitialIdealsOption.getValue())fprintf(Stdout,"{");
68
 
    do
69
 
      {
70
 
        PolynomialSet g=p.parsePolynomialSet(r);
71
 
        if(f.size()==0)
72
 
          {
73
 
            n=g.numberOfVariablesInRing();
74
 
            homog=dimensionOfHomogeneitySpace(g);
75
 
            f=IntegerVector(n-homog+1);
76
 
            fTrop=IntegerVector(n-homog+1);
77
 
            //      fprintf(Stderr,"Dimensions computed.\n");
78
 
          }
79
 
        PolyhedralCone c=groebnerCone(g,true);
80
 
        PolyhedralFan F(n);
81
 
        F.insert(c);
82
 
        for(int i=0;i<n-homog+1;i++)
83
 
          {
84
 
            F.removeAllLowerDimensional();
85
 
            //      IntegerVectorList l=F.getRelativeInteriorPoints();
86
 
            //      if(i==n-homog)
87
 
            //  {
88
 
            //  assert(l.size()==1);
89
 
            //  }
90
 
            PolyhedralFan F2(n);
91
 
            while(!F.isEmpty())
92
 
              {
93
 
                //              fprintf(Stderr,"checking cone\n");
94
 
                PolyhedralCone K=F.highestDimensionalCone();
95
 
                F.remove(K);
96
 
 
97
 
                IntegerVector w=K.getRelativeInteriorPoint();
98
 
                WeightTermOrder myOrder(w);
99
 
                if(g.checkMarkings(myOrder))
100
 
                  {
101
 
                    f[n-homog-i]++;
102
 
                    F2.insert(K);
103
 
                    if(checkBgOption.getValue())
104
 
                      {
105
 
                        if(!containsMonomial(initialFormsAssumeMarked(g,w)))
106
 
                          {
107
 
                            fTrop[n-homog-i]++;
108
 
                            PolynomialSet g2=saturatedIdeal(initialFormsAssumeMarked(g,w));
109
 
                            fprintf(Stderr,"Checking BG theorem\n");
110
 
                            AsciiPrinter(Stderr).printPolynomialSet(g2);
111
 
                            assert(krullDimension(g2)==krullDimension(g));
112
 
                          }
113
 
                      }
114
 
                    if(listInitialIdealsOption.getValue())
115
 
                      {
116
 
                        if(!first)fprintf(Stdout,",\n");
117
 
                        first=false;
118
 
                        AsciiPrinter(Stdout).printPolynomialSet(initialFormsAssumeMarked(g,w));
119
 
                      }
120
 
                  }
121
 
              }
122
 
            F=F2.facetComplex();
123
 
            //      fprintf(Stderr,"facetComplex computed\n");
124
 
          }
125
 
        counter++;
126
 
        if(debugOption.getValue())
127
 
          {
128
 
            if((counter%debugOption.getValue())==0)
129
 
              {
130
 
                AsciiPrinter(Stderr).printVector(f);
131
 
                AsciiPrinter(Stderr).printNewLine();
132
 
 
133
 
                FILE *p=fopen("gfan_fvector_temporary","w");
134
 
                if(p)
135
 
                  {
136
 
                    AsciiPrinter(p).printVector(f);
137
 
                    AsciiPrinter(p).printNewLine();
138
 
                    fclose(p);
139
 
                  }
140
 
              }
141
 
          }
142
 
      }
143
 
    while((c=p.nextNonBlank())==',');
144
 
    assert(p.isRightBracket(c));
145
 
    if(listInitialIdealsOption.getValue())fprintf(Stdout,"}\n");
146
 
 
147
 
    AsciiPrinter(Stdout).printVector(f);
148
 
    if(checkBgOption.getValue())
149
 
      {
150
 
        fprintf(Stdout,"F-vector of tropical variety:\n");
151
 
        AsciiPrinter(Stdout).printVector(fTrop);
152
 
      }
153
 
    return 0;
154
 
  }
155
 
};
156
 
 
157
 
static FVectorApplication theApplication;
158