17 #ifndef LATTICE_ALGS_GUARD 18 #define LATTICE_ALGS_GUARD 51 cout << "Check condition on line " \ 52 << __LINE__ << " of file " << __FILE__ \ 53 << " not satisfied:\n "#X << endl; \ 99 return _lat == neighbor.
_lat && getRow() == neighbor.
getRow();
102 const mpq_class& getH(
size_t i)
const;
103 size_t getHDim()
const;
105 const mpq_class& getY(
size_t i)
const;
106 size_t getYDim()
const;
112 bool isSpecial()
const;
113 bool isGenerator()
const;
115 string getName()
const;
129 ASSERT(row < getNeighborCount());
134 ASSERT(_h.getRowCount() == _y.getRowCount());
135 return _y.getRowCount();
145 vector<mpq_class> sum(getHDim());
146 for (
size_t i = 0; i < getHDim(); ++i)
148 for (
size_t row = 0; row < _h.getRowCount(); ++row) {
150 for (
size_t col = 0; col < _h.getColCount(); ++col)
151 if (sum[col] != _h(row, col))
160 vector<mpq_class> sum(getHDim());
161 for (
size_t i = 0; i < getHDim(); ++i)
162 sum[i] = _h(a, i) + _h(b, i);
163 for (
size_t row = 0; row < _h.getRowCount(); ++row) {
165 for (
size_t col = 0; col < _h.getColCount(); ++col)
166 if (sum[col] != _h(row, col))
175 ASSERT(_y.getColCount() == _ideal.getVarCount());
176 return _y.getColCount();
180 return _h.getColCount();
184 return _ideal.hasZeroEntry();
188 _ideal.getInitialIdeal(ideal);
195 return _isSumRow[n.
getRow()];
197 const vector<Neighbor>&
getNonSums()
const {
return _nonSums;}
198 const mpq_class&
getZero()
const {
return _zero;}
203 return _ideal.isPointFreeBody(_ideal.getGenerator(a.
getRow()),
204 _ideal.getGenerator(b.
getRow()));
210 return _ideal.isPointFreeBody(_ideal.getGenerator(a.
getRow()),
211 _ideal.getGenerator(b.
getRow()),
212 _ideal.getGenerator(c.
getRow()));
216 if (!isPointFreeBody(a, b))
218 for (
size_t var = 1; var < a.
getYDim(); ++var)
219 if (a.
getY(var) <= 0 && b.
getY(var) <= 0)
238 const vector<Mlfb>& mlfbs,
const GrobLat& lat);
261 const vector<Mlfb>& mlfbs,
const GrobLat& lat):
262 tri(a, b, sum, mlfbs, lat) {}
264 size_t getTypeCount(
size_t type)
const;
265 size_t getMaxType()
const;
267 bool inPlane(
Neighbor neighbor)
const;
268 bool isPivot(
const Mlfb&
mlfb)
const;
269 bool isSidePivot(
const Mlfb& mlfb)
const;
270 bool isFlat(
const Mlfb& mlfb)
const;
271 bool is22(
const Mlfb& mlfb)
const;
272 size_t getType(
const Mlfb& mlfb)
const;
275 return getTypeCount(4) > 0;
292 return minInitialFacet;
296 for (
size_t i = 0; i < _points.size(); ++i)
303 ASSERT(offset < getPointCount());
304 return _points[offset];
308 return _points.size();
312 return _offset == mlfb.
_offset;
319 const vector<mpz_class>&
getRhs()
const {
325 name <<
'm' << (getOffset() + 1);
331 return getName() +
'P';
333 return getName() +
'F';
338 ASSERT(indexParam < edgeHitsFacet.size());
339 return getPoint(getHitsFacet(indexParam));
343 ASSERT(indexParam < edgeHitsFacet.size());
344 return edgeHitsFacet[indexParam];
348 ASSERT(indexParam < edges.size());
349 return edges[indexParam];
353 ASSERT(indexParam < edges.size());
354 return edges[indexParam];
358 for (
size_t i = 0; i < 4; ++i)
359 if (*getEdge(i) == adjacent)
365 return _isParallelogram;
374 void reset(
size_t offset,
const vector<Neighbor>& points);
386 _a(a), _b(b), _c(c) {
389 for (
size_t col = 0; col < 3; ++col) {
390 mat(0, col) = a.
getH(col) - c.
getH(col);
391 mat(1, col) = b.
getH(col) - c.
getH(col);
396 _line = (_normal.getRowCount() != 1);
405 mpz_class dn = dotNormal(a);
406 return dn == 0 || dn == 1 || dn == -1;
410 return dotNormal(a) == 0;
415 for (
size_t i = 0; i < 3; ++i)
416 prod += a.
getH(i) * _normal(0, i);
444 void checkPlanes(
const vector<TriPlane>& thinPlanes,
445 const vector<Plane>& dtPlanes);
448 const vector<mpz_class>& rhs,
457 vector<vector<SeqPos> >& right,
458 const vector<Mlfb>& mlfbs,
466 void checkSeqs(
const vector<vector<SeqPos> >& left,
467 const vector<vector<SeqPos> >& right,
469 const vector<Mlfb>& mlfbs);
471 const vector<Mlfb>& mlfbs);
473 const vector<Mlfb>& mlfbs);
476 const vector<Mlfb>& mlfbs);
483 const vector<Mlfb>& mlfbs,
484 const vector<SeqPos>& flatSeq);
487 const vector<Mlfb>& mlfbs,
488 const vector<const Mlfb*>& pivots,
493 vector<Mlfb>& mlfbs);
499 map<size_t, size_t>& typeCounts);
501 bool disjointSeqs(
const vector<SeqPos>& a,
const vector<SeqPos>& b);
507 const vector<Mlfb>& mlfbs,
509 const vector<SeqPos>& flatSeq);
523 const vector<Mlfb>& mlfbs);
const vector< const Mlfb * > & getASideMlfbs() const
bool isPivot(const Mlfb &mlfb) const
void checkPlanes(const vector< TriPlane > &thinPlanes, const vector< Plane > &dtPlanes)
void computeMlfbs(vector< Mlfb > &mlfbs, const GrobLat &lat)
const vector< Neighbor > & getNonSums() const
bool operator==(const Neighbor &neighbor) const
bool operator<(const SeqPos &pos) const
bool isInterior(Neighbor a, Neighbor b) const
Represents a saturated binomial ideal.
size_t getMinInitialFacet() const
void checkGraph(const vector< Mlfb > &mlfbs)
bool isParallel(const TriPlane &plane) const
bool hasZeroEntryY() const
void computePlanes(vector< Plane > &planes, const GrobLat &lat, vector< Mlfb > &mlfbs)
Neighbor getNeighbor(size_t row) const
bool isParallel(const Plane &plane) const
Neighbor getSum(size_t a, size_t b) const
size_t pushOutFacetPositive(size_t facetPushOut, const vector< mpz_class > &rhs, const GrobLat &lat)
Neighbor getHitsNeighbor(size_t indexParam) const
void getInitialIdeal(BigIdeal &ideal) const
vector< const Mlfb * > pivots
const mpq_class & getZero() const
size_t getFacetOf(const Mlfb &adjacent) const
size_t getHitsFacet(size_t indexParam) const
void setupPlaneCountsAndOrder(vector< Mlfb > &mlfbs, const Plane &plane, map< size_t, size_t > &typeCounts)
Set the plane vertex count for each mlfb and count how many MLFBs have each possible number of vertic...
size_t getNeighborCount() const
bool hasPoint(Neighbor n) const
vector< Neighbor > _nonSums
void checkPlane(const Plane &plane, const vector< Mlfb > &mlfbs)
const char * getEdgePos(size_t index)
void checkFlatSeq(const vector< SeqPos > &flatSeq, const GrobLat &lat, const Plane &plane)
Mlfb * getEdge(size_t indexParam)
const Matrix & getMatrix() const
bool isFlat(const Mlfb &mlfb) const
string getName(const Plane &plane) const
const Matrix & getYMatrix() const
bool closeToPlane(Neighbor a)
A lattice with associated Grobner basis/neighbors.
void checkPlaneTri(const GrobLat &lat, const vector< Mlfb > &mlfbs, const vector< const Mlfb *> &pivots, const Plane &plane)
void transpose(Matrix &trans, const Matrix &mat)
Sets trans to the transpose of mat.
bool isValid(const Word *a, size_t varCount)
The unused bits at the end of the last word must be zero for the functions here to work correctly...
const Mlfb * getEdge(size_t indexParam) const
bool isParallelogram() const
char getPlaceCode(NeighborPlace place)
mpz_class dotNormal(Neighbor a) const
size_t getBackFacet() const
Neighbor getPoint(size_t offset) const
size_t pushOutFacetZero(const vector< mpz_class > &rhs, const GrobLat &lat)
const Matrix & getHMatrix() const
void computePivotSeqs(vector< vector< SeqPos > > &seqs, const Mlfb &pivot, const Plane &plane)
Starting at pivot (which must be a pivot), follow the three non-flat sequences starting at pivot...
size_t getPointCount() const
bool disjointSeqs(const vector< SeqPos > &a, const vector< SeqPos > &b)
void checkDoubleTriangle(const Plane &plane, const vector< Mlfb > &mlfbs)
Plane(Neighbor a, Neighbor b, Neighbor sum, const vector< Mlfb > &mlfbs, const GrobLat &lat)
const Matrix & getNormal() const
returns the normal of the plane as the row of a matrix.
vector< Neighbor > _interior
bool isPointFreeBody(Neighbor a, Neighbor b, Neighbor c) const
Returns true if the smallest body containing zero, a, b and c has no neighbor in its interior...
bool isSum(Neighbor n) const
const vector< Neighbor > & getNeighborsOnBoundary() const
size_t getForwardFacet() const
bool inPlane(Neighbor a) const
void checkMlfbs(const vector< Mlfb > &mlfbs, const GrobLat &lat)
bool operator==(const Mlfb &mlfb) const
void checkGraphOnPlane(const Plane &plane, const vector< Mlfb > &mlfbs)
const vector< mpz_class > & getRhs() const
void computeSeqs(vector< vector< SeqPos > > &left, vector< vector< SeqPos > > &right, const vector< Mlfb > &mlfbs, const Plane &plane)
const vector< Neighbor > & getNeighborsInInterior() const
Neighbor & operator=(const Neighbor &neighbor)
void getThinPlanes(vector< TriPlane > &planes, const GrobLat &lat)
vector< NeighborPlace > neighborPlace
void checkSeqs(const vector< vector< SeqPos > > &left, const vector< vector< SeqPos > > &right, const Plane &plane, const vector< Mlfb > &mlfbs)
const mpq_class & getY(size_t i) const
void checkNonSums(const GrobLat &lat)
void checkPivotSeqs(vector< vector< SeqPos > > &pivotSeqs, const Plane &plane, const vector< Mlfb > &mlfbs, const vector< SeqPos > &flatSeq)
Perform checks where pivotSeqs are the 3 non-flat sequences on one side.
const GrobLat & getGrobLat() const
void checkDoubleTrianglePlanes(const vector< Plane > &planes, const GrobLat &lat, const vector< Mlfb > &mlfbs)
void computePivots(vector< const Mlfb *> &pivots, const vector< Mlfb > &mlfbs, const Plane &plane, const vector< SeqPos > &flatSeq)
Put all pivots into pivots.
const vector< const Mlfb * > & getBSideMlfbs() const
void checkMiddle(const Plane &plane, const vector< Mlfb > &mlfbs)
TriPlane(Neighbor a, Neighbor b, Neighbor c)
vector< const Mlfb * > _bSideMlfbs
const mpq_class & getH(size_t i) const
vector< Neighbor > _points
vector< const Mlfb * > _aSideMlfbs
Neighbor getSum(Neighbor a, Neighbor b) const
map< size_t, size_t > typeCounts
void nullSpace(Matrix &basis, const Matrix &matParam)
Sets the columns of basis to a basis of the null space of mat.
const SatBinomIdeal & getIdeal() const
bool isPointFreeBody(Neighbor a, Neighbor b) const
Returns true if the smallest body containing zero, a and b has no neighbor in its interior...
vector< size_t > edgeHitsFacet
vector< Neighbor > _boundary
SeqPos getReverse() const
mpq_class getIndexSum(const vector< Mlfb > &mlfbs)