41 gfan::ZCone c =
f.eta;
42 gfan::ZVector
v =
f.interiorPoint;
43 gfan::ZVector
w =
f.facetNormal;
44 assume(c.ambientDimension() == (
int)
v.size());
45 assume(c.ambientDimension() == (
int)
w.size());
51 facet::facet(
const gfan::ZCone &c,
const gfan::ZVector &
v,
const gfan::ZVector &
w):
57 assume(c.ambientDimension() == (
int)
v.size());
58 assume(c.ambientDimension() == (
int)
w.size());
67 gfan::ZCone c = this->
eta;
70 assume(c.ambientDimension() == (
int)
v.size());
71 assume(c.ambientDimension() == (
int)
w.size());
79 std::pair<facets::iterator,bool>
check(newFacets.begin(),
false);
80 for(facets::iterator
p=newFacets.begin();
p!=newFacets.end();
p++)
91static gfan::ZCone
subcone(
const lists &cones,
const gfan::ZVector &point)
93 gfan::ZCone sigma = gfan::ZCone(gfan::ZMatrix(1,point.size()), gfan::ZMatrix(1,point.size()));
95 for (
int i=0;
i<=cones->
nr;
i++)
97 zc = (gfan::ZCone*) cones->
m[
i].
Data();
98 if (zc->contains(point))
99 sigma = gfan::intersection(sigma,*zc);
107 gfan::ZMatrix
equations = zc.getImpliedEquations();
121 gfan::ZMatrix newInequalities =
inequalities.submatrix(1,0,r,c);
124 gfan::ZCone eta = gfan::ZCone(newInequalities,newEquations);
126 gfan::ZVector
v = eta.getRelativeInteriorPoint();
129 if (bound.containsRelatively(
v))
133 for (
int i=1;
i<r-1;
i++)
139 eta = gfan::ZCone(newInequalities,newEquations);
141 v = eta.getRelativeInteriorPoint();
143 if (bound.containsRelatively(
v))
151 eta = gfan::ZCone(newInequalities,newEquations);
154 v = eta.getRelativeInteriorPoint();
156 if (bound.containsRelatively(
v))
173 gfan::ZCone
support = gfan::ZCone::givenByRays(*zm, gfan::ZMatrix(0, zm->getWidth()));
184 gfan::ZCone
lambda; gfan::ZVector point;
191 int iterationNumber = 1;
192 std::cout <<
"cones found: " << iterationNumber++ << std::endl;
195 gfan::ZFan* Sigma =
new gfan::ZFan(
lambda.ambientDimension());
201 res->data = (
void*) Sigma;
208 gfan::ZVector interiorPoint;
209 gfan::ZVector facetNormal;
218 interiorPoint =
f.getInteriorPoint();
219 facetNormal =
f.getFacetNormal();
226 point =
mu * interiorPoint - facetNormal;
227 while (!
support.containsRelatively(point))
230 point =
mu * interiorPoint - facetNormal;
234 while ((
lambda.dimension() <
lambda.ambientDimension()) && !(
lambda.contains(interiorPoint)))
237 point =
mu * interiorPoint - facetNormal;
240 std::cout <<
"cones found: " << iterationNumber++ << std::endl;
249 mergeFacets(F,newFacets);
253 res->data = (
void*) Sigma;
257 WerrorS(
"refineCones: unexpected parameters");
266 gfan::Integer
num = 1;
267 gfan::Integer
den = 1;
268 for (
int i=1;
i<=
k;
i++)
270 for (
int j=n-
k+1;
j<=n;
j++)
272 gfan::Integer bin =
num/
den;
281 for (
int i=0;
i<n;
i++)
298 int n = (int)(
long) u->
Data();
299 int k = (int)(
long)
v->Data();
301 for (
int i=0;
i<
k;
i++)
307 while (!(
v & (1<<n)))
316 v = (t + 1) | (((~t & -~t) - 1) >> (__builtin_ctz(
v) + 1));
319 res->data = (
void*) L;
323 WerrorS(
"listOfAfacesToCheck: unexpected parameter");
345 af |= 1<<((*aface)[
i]-1);
347 unsigned int t = af | (af - 1);
348 af = (t + 1) | (((~t & -~t) - 1) >> (__builtin_ctz(af) + 1));
363 WerrorS(
"nextAfaceToCheck: unexpected parameter");
388 if ( (*hash)[
i]<0 && n_GreaterZero((*interiorPoint)[
i],interiorPoint->
basecoeffs()) )
390 res->data = (
void*) (
long) 0;
393 if ( (*hash)[
i]>0 && !n_IsZero((*interiorPoint)[
i],interiorPoint->
basecoeffs()) )
395 number neg = n_Copy((*interiorPoint)[
i],interiorPoint->
basecoeffs());
396 neg = n_InpNeg(neg,interiorPoint->
basecoeffs());
397 if (n_GreaterZero(neg,interiorPoint->
basecoeffs()))
400 res->data = (
void*) (
long) 0;
406 res->data = (
void*) (
long) 1;
408 delete interiorPoint;
412 WerrorS(
"checkSigns: unexpected parameter");
427 for (
int i=1;
i<
l;
i++)
429 number endResultCache;
435 endResult = endResultCache;
436 endResultCache =
NULL;
440 res->data = (
void*) endResult;
443 WerrorS(
"binaryToBigint: unexpected parameter");
460 for (
int i=0;
i<
k;
i++)
461 (*composedIntvec)[
i] = (*iv1)[(*iv2)[
i]-1];
463 res->data = (
void*) composedIntvec;
467 WerrorS(
"composeIntvecs: unexpected parameter");
481 number numberToInsert = (number)
v->Data();
483 int upperBound =
lSize(listOfNumbers);
487 res->data = (
void*) (
long) (lowerBound+1);
491 number lowerNumber = (number) listOfNumbers->
m[lowerBound].
Data();
495 res->data = (
void*) (
long) (-1);
501 res->data = (
void*) (
long) (lowerBound+1);
505 number upperNumber = (number) listOfNumbers->
m[upperBound].
Data();
509 res->data = (
void*) (
long) (-1);
515 res->data = (
void*) (
long) (upperBound+2);
519 while (lowerBound+1<upperBound)
521 int middle = lowerBound + (upperBound-lowerBound) / 2;
522 number lowerNumber = (number) listOfNumbers->
m[lowerBound].
Data();
523 number upperNumber = (number) listOfNumbers->
m[upperBound].
Data();
524 number middleNumber = (number) listOfNumbers->
m[middle].
Data();
530 res->data = (
void*) (
long) -1;
540 res->data = (
void*) (
long) (upperBound+1);
544 WerrorS(
"findPlaceToInsert: unexpected parameter");
551 gfan::initializeCddlibIfRequired();
BOOLEAN ambientDimension(leftv res, leftv args)
BOOLEAN equations(leftv res, leftv args)
BOOLEAN dimension(leftv res, leftv args)
gfan::ZVector randomPoint(const gfan::ZCone *zc, const int b)
BOOLEAN inequalities(leftv res, leftv args)
bigintmat * iv2bim(intvec *b, const coeffs C)
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
void lambda(int **points, int sizePoints)
void mu(int **points, int sizePoints)
coeffs basecoeffs() const
gfan::ZVector facetNormal
gfan::ZVector interiorPoint
INLINE_THIS void Init(int l=0)
static BOOLEAN support(leftv res, leftv args)
const Variable & v
< [in] a sqrfree bivariate poly
void WerrorS(const char *s)
static int binomial(int n, int k)
static gitfan::facets interiorFacets(const gfan::ZCone &zc, const gfan::ZCone &bound)
intvec * intToAface(unsigned int v0, int n, int k)
BOOLEAN listOfAfacesToCheck(leftv res, leftv args)
BOOLEAN findPlaceToInsert(leftv res, leftv args)
BOOLEAN checkSigns(leftv res, leftv args)
BOOLEAN refineCones(leftv res, leftv args)
BOOLEAN binaryToBigint(leftv res, leftv args)
static gfan::ZCone subcone(const lists &cones, const gfan::ZVector &point)
BOOLEAN nextAfaceToCheck(leftv res, leftv args)
BOOLEAN composeIntvecs(leftv res, leftv args)
void mergeFacets(facets &F, const facets &newFacets)
std::set< facet, facet_compare > facets
int status int void size_t count