28 #ifndef _CHAINCON_BOUNDARY_H_ 29 #define _CHAINCON_BOUNDARY_H_ 45 #include "chomp/system/config.h" 46 #include "chomp/struct/multitab.h" 61 template <
class CellT>
62 bool check (
const CellT &c)
const;
66 template <
class CellT>
76 template <
class CellRestrT>
86 template <
class CellT>
87 bool check (
const CellT &c)
const;
95 template <
class CellRestrT>
102 template <
class CellRestrT>
103 template <
class CellT>
117 template <
class CellT,
class CellRestrT>
119 const CellRestrT &restr)
122 int length = c. boundaryLength ();
125 for (
int i = 0; i < length; ++ i)
131 if (!restr.
check (bc))
143 template <
class CellT,
class CellRestrT>
147 int_t size = c. size ();
148 for (int_t i = 0; i < size; ++ i)
155 template <
class CellT,
class CellRestrT>
157 const CellRestrT &restr)
177 template <
class CellT,
class CoefT,
class CellRestrT>
179 const CoefT &coef,
const CellRestrT &restr)
182 int length = c. boundaryLength ();
185 for (
int i = 0; i < length; ++ i)
191 if (!restr.
check (bc))
195 CoefT bcoef (c. boundaryCoef (i));
207 template <
class CellT,
class CoefT,
class CellRestrT>
211 int_t size = c. size ();
212 for (int_t i = 0; i < size; ++ i)
219 template <
class CellT,
class CoefT,
class CellRestrT>
221 const CellRestrT &restr)
246 template <
class Cell1T,
class Cell2T,
class CellRestrT>
250 int_t size = c. size ();
251 for (int_t i = 0; i < size; ++ i)
257 b. add (left, right);
263 template <
class Cell1T,
class Cell2T,
class CellRestrT>
283 template <
class Cell1T,
class Cell2T,
class CoefT,
class CellRestrT>
287 int_t size = c. size ();
288 for (int_t i = 0; i < size; ++ i)
294 b. add (left, right);
300 template <
class Cell1T,
class Cell2T,
class CoefT,
class CellRestrT>
322 template <
class CellArray,
class CellT,
class CellRestrT>
327 chomp::homology::hashedset<CellT> waiting;
331 int_t inputCellNumber = 0;
332 const int_t inputCellCount = cells. size ();
336 bool useInput = (inputCellNumber < inputCellCount);
340 if (!useInput && waiting. empty ())
344 int_t waitingPosition = waiting. size () - 1;
345 const CellT &c = useInput ? cells [inputCellNumber] :
346 waiting [waitingPosition];
349 int length = c. boundaryLength ();
352 for (
int b = 0; b < length; ++ b)
358 if (!restr.
check (bc))
362 if (bc. boundaryLength () &&
363 f. getImage (bc). empty ())
378 waiting. removenum (waitingPosition);
391 template <
class CellArray,
class CellT,
class CoefT,
class CellRestrT>
396 chomp::homology::hashedset<CellT> waiting;
400 int_t inputCellNumber = 0;
401 const int_t inputCellCount = cells. size ();
405 bool useInput = (inputCellNumber < inputCellCount);
409 if (!useInput && waiting. empty ())
413 int_t waitingPosition = waiting. size () - 1;
414 const CellT &c = useInput ? cells [inputCellNumber] :
415 waiting [waitingPosition];
418 int length = c. boundaryLength ();
421 for (
int b = 0; b < length; ++ b)
427 if (!restr.
check (bc))
431 if (bc. boundaryLength () &&
432 f. getImage (bc). empty ())
438 f. add (c, bc, CoefT (c. boundaryCoef (b)));
447 waiting. removenum (waitingPosition);
458 template <
class CellT,
class CellRestrT>
460 const CellRestrT &restr)
463 using chomp::homology::scon;
470 chomp::homology::multitable<std::vector<int_t> > cellsByDim (32);
472 int_t Ksize = K. size ();
473 for (int_t i = 0; i < Ksize; ++ i)
475 int dim (K [i]. dim ());
478 cellsByDim [dim]. push_back (i);
487 int_t Lsize (L. size ());
495 for (int_t n = 0; (n < K. size ()) || (Lused < Lsize); ++ n)
501 if ((curDim >= 0) && ((n >= K. size ()) ||
502 (K [K. size () - n - 1]. dim () - 1 <= curDim)))
504 size_t curDimSize (cellsByDim [curDim]. size ());
507 for (
size_t i = 0; i < curDimSize; ++ i)
509 K. add (L [cellsByDim [curDim] [i]]);
511 if (!(counter % 5347))
512 scon << std::setw (15) << counter <<
513 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
522 const CellT &c = K [K. size () - n - 1];
526 int len = c. boundaryLength ();
527 for (
int i = 0; i < len; ++ i)
533 if (!restr.
check (bc))
537 int_t cn = K. add (bc);
539 if (!(counter % 5347))
540 scon << std::setw (15) << counter <<
541 "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b";
546 throw "A boundary cell appears too early " 556 #endif // _CHAINCON_BOUNDARY_H_ A linear map for coefficients in an arbitrary commutative ring.
A combinatorial chain, that is, a chain with Z_2 coefficients.
tCombChain< CellT > boundary(const tCombChain< CellT > &c, const CellRestrT &restr)
Returns the boundary of a given chain (takes boundary cells restricted by the given object...
A chain with coefficients in an arbitrary ring.
A combinatorial linear map (for coefficients in Z_2).
NegateRestr(const CellRestrT &p)
Creates an object of the class based on another object whose decisions will be negated.
A tensor of chains with coefficients in an arbitrary commutative ring.
void computeBoundaryMap(const CellArray &cells, tCombLinMap< CellT, CellT > &f, const CellRestrT &restr)
Computes the full boundary map for a cellular complex that contains the cells in a provided set and a...
A template of a simple class for negating the cell restriction given by another object for the bounda...
bool check(const CellT &c) const
Checks whether the given cell satisfies the negation of the restriction given by the parent object...
const CellRestrT & parent
The parent object whose decisions will be negated.
Combinatorial tensor of cells.
void computeBoundary(const CellT &c, tCombChain< CellT > &b, const CellRestrT &restr)
Adds the boundary of a given cell to the provided chain (takes boundary cells restricted by the given...
A combinatorial tensor (for coefficients in Z_2).
void addBoundaries(tFilteredComplex< CellT > &K, const CellRestrT &restr)
Adds boundaries to all the cells in the given filtered complex.
A chain with coefficients in an arbitrary commutative ring.
bool check(const CellT &c) const
Checks whether the given cell satisfies the restriction.
A template of a simple class for unrestricted cell selection in the boundary computation procedures...
A combinatorial linear map.