4
#include "gfanapplication.h"
5
#include "intsinpolytope.h"
7
#include "determinant.h"
9
class IntsInPolytopeApplication : public GFanApplication
12
bool includeInDefaultInstallation()
16
IntsInPolytopeApplication()
22
return "_intsinpolytope";
25
// a is a squarematrix whose rows span a simplicial cone
26
bool isInSimplicialCone(IntegerMatrix const &a, IntegerVector const &v)
29
for(int i=0;i<a.getHeight();i++)
33
IntegerVectorList A=a.getRows();
34
IntegerVectorList B=b.getRows();
35
if((determinantSign(A)*determinantSign(B))<0)return false;
41
set<set<int> > partsOfZBases(set<set<int> > const &s, IntegerMatrix const &M)
43
set<set<int> > setsToCheck;
45
for(set<set<int> >::const_iterator i=s.begin();i!=s.end();i++)
47
for(int j=0;j<M.getHeight();j++)
51
if(temp.size()!=i->size())
56
IntegerMatrix MM(5,5);
58
for(set<int>::const_iterator k=temp.begin();k!=temp.end();k++,I++)
63
v[0]=2;//?????????????????????????????????????????????????
68
if(!isInSimplicialCone(MM,v))
73
for(set<int>::const_iterator k=temp.begin();k!=temp.end();k++)
87
if(!(c&4095))fprintf(stderr,"tocheck:%i\n",c);
91
IntegerMatrix MM(5,5);
93
for(set<int>::const_iterator k=temp.begin();k!=temp.end();k++,I++)
98
fprintf(stderr,"Candidate:\n");
99
AsciiPrinter(Stderr).printVectorList(MM.getRows());
101
setsToCheck.insert(temp);
107
fprintf(stderr,"Sets to test: %i\n",setsToCheck.size());
110
for(set<set<int> >::const_iterator i=setsToCheck.begin();i!=setsToCheck.end();i++)
114
if(!(c&4095))fprintf(stderr,"%i\n",c);
116
for(set<int>::const_iterator j=i->begin();j!=i->end();j++)
118
if(isPartOfAZBasis(l))ret.insert(*i);
121
fprintf(stderr,"Produced sets: %i\n",ret.size());
130
IntegerVectorList ivl=p.parseIntegerVectorList();
131
IntegerMatrix A=rowsToIntegerMatrix(ivl);//.transposed();
133
IntegerVector rightHandSide=p.parseIntegerVector();
134
IntegerVector v=p.parseIntegerVector();
136
AsciiPrinter P(stdout);
138
fprintf(Stdout,"Lattice Kernel:\n");
139
IntegerVectorList l=intsInPolytopeGivenIneqAndPt(A,rightHandSide,v);
140
P.printVectorList(l);
142
// return 0;//!!!!!!!!!!!!!!!!!!!!!!!!
144
// P.printVectorList(intsInPolytopeGivenIneq(A,rightHandSide));
153
IntegerVectorList l2;
154
for(IntegerVectorList::const_iterator i=l.begin();i!=l.end();i++)
156
IntegerVector temp(i->size()+1);
158
for(int j=0;j<i->size();j++)temp[j+1]=(*i)[j];
160
/* IntegerVectorList k;
162
if(isPartOfAZBasis(k))
167
IntegerVectorList l3;
168
for(IntegerVectorList::const_iterator i=l2.begin();i!=l2.end();i++)
169
//if(((*i)[1]<=2)&&((*i)[2]<=2)&&((*i)[3]<=17)&&((*i)[4]<=8))
171
// if(((*i)[0]<=2)&&((*i)[1]<=2)&&((*i)[2]<=17)&&((*i)[3]<=8))l3.push_back(*i);
173
IntegerMatrix M=rowsToIntegerMatrix(l3);
175
P.printVectorList(M.getRows());
176
fprintf(stdout,"size:%i\n",M.getHeight());
179
s.insert(set<int>());
182
s=partsOfZBases(s,M);
185
for(set<set<int> >::const_iterator i=s.begin();i!=s.end();i++)
187
for(set<int>::const_iterator j=i->begin();j!=i->end();j++)
189
// fprintf(stderr,"%i ",*j);
191
// fprintf(stderr,"\n");
194
// fprintf(stderr,"\n\n\n\n");
203
const char *helpText()
205
return "This program computes the integer points in a polytope.\n";
209
static IntsInPolytopeApplication theApplication;