34#ifndef _CHOMP_HOMOLOGY_CUBACYCL_H_
35#define _CHOMP_HOMOLOGY_CUBACYCL_H_
82 int answerKnown = known ? known -> check (b) : -1;
86 return (!!answerKnown);
90 if (dim > tCube::MaxDim)
91 throw "Cube dimension too high for acyclicity verification.";
92 short c [tCube::MaxDim];
93 for (
int i = 0; i < dim; ++ i)
98 typedef tCube::CellType tCell;
105 known -> add (b, answerBool);
112template <
class tCube>
120 if (cset. size () == 1)
127 if (theset. size () == 1)
132 int_t size = cset. size ();
133 for (
int_t i = 0; i < size; ++ i)
134 ccompl. add (
typename tCube::CellType (cset [i]));
150template <
class tCube,
class tCubeSet1,
class tCubeSet2>
151inline bool acyclic (
const tCube &q,
int dim,
const tCubeSet1 &cset,
162 if ((n == 0) || (n == maxneighbors))
173template <
class tCube,
class tCubeSet>
174inline bool acyclic (
const tCube &q,
int dim,
const tCubeSet &cset,
182template <
class tCube,
class tSet1,
class tSet2>
201 bool otheracyclic = (nother < maxneighbors) &&
202 ((nother == 1) || (nother &&
acyclic (dim, *b)));
218 if ((ncset + nother > 1) && ((ncset + nother == maxneighbors) ||
234template <
class tCube,
class tCell,
class tSet>
240 typename tCell::CoordType left [tCell::MaxDim];
241 face. leftcoord (left);
242 typename tCell::CoordType right [tCell::MaxDim];
243 face. rightcoord (right);
246 int spacedim = face. spacedim ();
247 typename tCell::CoordType leftb [tCell::MaxDim];
248 typename tCell::CoordType rightb [tCell::MaxDim];
249 for (
int j = 0; j < spacedim; ++ j)
251 typename tCell::CoordType diff =
252 (left [j] == right [j]) ? 1 : 0;
253 leftb [j] = (left [j] - diff);
254 rightb [j] = (right [j] + diff);
257 const typename tCell::CoordType *c;
258 int_t countimages = 0;
259 while ((c = r. get ()) != NULL)
261 if (!tCube::PointBase::check (c, spacedim))
263 tCube q (c, spacedim);
266 if (!cset. check (q))
279template <
class tCube,
class tSet>
284 if (map. getdomain (). empty ())
292 static int_t _maxneighbors = 0;
294 if (maxneighbors != _maxneighbors)
296 _maxneighbors = maxneighbors;
297 buffer. reset (
new unsigned char [(maxneighbors + 7) >> 3]);
298 b. define (buffer. get (), maxneighbors);
302 b. clearall (maxneighbors);
314 int startdim = faces. dim ();
315 for (
int d = startdim; d >= 0; -- d)
317 for (
int_t i = 0; i < faces [d]. size (); ++ i)
331 imgsurplus. remove (img);
333 if (!imgsurplus. empty ())
344template <
class tCube>
355 template <
class tSet>
356 bool operator () (
const tCube &q,
const tSet &cset)
const;
364template <
class tCube>
374template <
class tCube>
377 const tSet &cset)
const
390template <
class tCube>
397 bool _indexmap,
bool _checkacyclic,
bool _quiet);
403 template <
class tSet1,
class tSet2>
404 bool operator () (
const tCube &c,
const tSet1 &cset,
405 const tSet2 &other)
const;
428template <
class tCube>
431 bool _indexmap,
bool _checkacyclic,
bool _quiet):
432 map (_map), imgsrc (_imgsrc), img (_img),
433 indexmap (_indexmap), checkacyclic (_checkacyclic),
439template <
class tCube>
440template <
class tSet1,
class tSet2>
442 const tSet1 &cset,
const tSet2 &other)
const
449 ximage. remove (img);
453 if (!ximage. empty ())
461 if (!quiet && !cubimage. empty ())
464 for (
int_t j = 0; j < cubimage. size (); ++ j)
465 sseq <<
'2' << cubimage [j] <<
'\n';
467 sseq <<
'2' << c <<
'\n';
474 imgsrc. remove (cubimage);
485template <
class tCube>
493 template <
class tSet1,
class tSet2>
494 bool operator () (
const tCube &q,
const tSet1 &cset,
495 const tSet2 &other)
const;
499template <
class tCube>
505template <
class tCube>
506template <
class tSet1,
class tSet2>
508 const tSet1 &,
const tSet2 &)
const
An auto_array template that mimics selected behaviors of the std::auto_ptr template,...
This file contains functions generated using Binary Decision Diagrams for checking the acyclicity of ...
This file contains the definition of a bitfield class which works an array of bits.
This file includes header files with various definitions of cubical cells and defines the standard ty...
This file contains classes and functions related to algebraic chain complexes and chain maps,...
This class defines a bit field that is part of some larger array or that uses an allocated piece of m...
A dummy class that substitutes MapCanExpand if there is no map to check, so the verification always r...
bool operator()(const tCube &q, const tSet1 &cset, const tSet2 &other) const
Dummy verification. Always returns 'true'.
MapCanExpandDummy()
The only allowed constructor.
A class for the procecure checking if the image of a given map can be expanded without any harm to th...
bool checkacyclic
Should it be checked that the map acyclicity is preserved?
const mvmap< tCube, tCube > & map
A reference to the map being verified.
bool indexmap
Is theis the index map?
bool quiet
Should any messages be suppressed?
MapCanExpand(const mvmap< tCube, tCube > &_map, hashedset< tCube > &_imgsrc, hashedset< tCube > &_img, bool _indexmap, bool _checkacyclic, bool _quiet)
The only allowed constructor.
bool operator()(const tCube &c, const tSet1 &cset, const tSet2 &other) const
Verifies if the map remains acyclic after the addition or removal of the given cube to/from the given...
hashedset< tCube > & img
A reference to image of the map, previously computed, modified.
hashedset< tCube > & imgsrc
A reference to the source of image cubes. (?)
A wrapper class for the procecure checking if a given map remains acyclic when a given full cube is r...
const mvmap< tCube, tCube > & map
A reference to the map being verified.
bool operator()(const tCube &q, const tSet &cset) const
Verifies if the map remains acyclic after the addition or removal of the given cube to/from the given...
MapRemainsAcyclic(const mvmap< tCube, tCube > &the_map)
The only allowed constructor.
This class defines a set of bit fields of the same length which are to be stored in a contiguous piec...
static int get(const char *table, int_t bitnumber)
Retrieve the given bit from the given table.
An auto_array template that mimics selected behaviors of the std::auto_ptr template,...
The class that defines a geometric complex - a set of cells (cubes, simplices, etc).
This class defines a hypercube in R^n with edges parallel to the axes and with size 1 in each directi...
This class can be used for iterating point's neighbors.
This class can be used for iterating a rectangular set of points, given its left and right bound.
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
This file includes header files with various definitions of full cubes and defines the standard types...
This file contains some procedures defined for cubical maps.
This file contains a definition of a general geometric complex which represents a polyhedron.
int int_t
Index type for indexing arrays, counting cubes, etc.
This file contains the definition of the container "hashedset" which can be used to represent a set o...
This file defines a class "integer" which represents the ring of integers or the field of integers mo...
This file contains the definition of a tabulated set of configurations of full cubical neighborhood u...
outputstream sseq
An auxiliary stream which captures sequences of processed data.
int MaxBddDim
The maximal dimension for which binary decision diagrams are used.
int_t getneighbors(const tCube &q, BitField *bits, const tCubeSet1 &theset, tCubeSet2 *neighbors, int_t limit)
Gets neighbors of the given cube from the given set and indicates them in the bit field provided.
bool acyclic(int dim, BitField &b)
Checks whether this cube's nieghbors form an acyclic set.
bool acyclic_rel(const tCube &q, int dim, const tSet1 &cset, const tSet2 &other, BitField *b, int_t maxneighbors, hashedset< tCube > *neighbors_main, hashedset< tCube > *neighbors_other)
Verifies whether a cube from the other set can be removed.
setunion< set1type, set2type > makesetunion(const set1type &set1, const set2type &set2)
Creates an object which represents the union of two sets.
int_t computeimage(hashedset< tCube > &img, const tCell &face, const mvmap< tCube, tCube > &map, const tSet &cset, const tCube &ignore)
Computes the image of the face under the combinatorial cubical multivalued map, but doesn't take the ...
int bits2int(const BitField &field, int_t length)
int_t getmaxneighbors(int dim)
Returns the maximal number of neighbors of a cube: 3^dim - 1.
int_t cubreducequiet(hashedset< tCube > &cset, hashedset< tCube > &other, mvmap< tCube, tCube > &cubmap, const hashedset< tCube > &keep, bool quiet=true)
Reduces a pair of sets of cubes for relative homology computation.
void addneighbors(const int &c, const SetT &s, QueueT &q)
Adds the neighbors of the cube 'c' in the set 's' to the set 'q'.
BitFields knownbits
The global table of BitFields which store the acyclicity information for reducing full cubical sets.
Tabulated tabulated
The global instance of this class which stores tabulated configurations to use in the full cube reduc...
void addboundaries(gcomplex< cell, euclidom > &Xcompl, gcomplex< cell, euclidom > &Acompl, int minlevel, bool bothsets, const char *Xname, const char *Aname)
Adds boundaries to the geometric complex X or to both X and A.
tNeighbors< coordinate > neighbors
The neighbors class with the default type of coordinates.
bool remainsacyclic(const mvmap< tCube, tCube > &map, const tCube &q, const tSet &cset)
Verifies if the map remains acyclic after the addition or removal of the given cube to/from the union...
bool bddacyclic(const tCube &q, int dim, const tCubeSet &s, BitField &b)
Uses binary decision diagrams to verify whether the neighborhood of the given cube in the given set i...
This namespace contains the entire CHomP library interface.
This file contains various procedures relating to neighborhoods of cubes in full cubical sets.
This file contains the definition of a point base class which is used for indexing all the points (n-...
This file contains the definition of a set of n-dimensional points with integer coordinates and sever...
This file contains the definition of the container "setunion".
This file contains the definition of a class which stores tabulated configuration of full cubical nei...
This file contains some useful functions related to the text input/output procedures.