29 #ifndef _CHAINCON_ATMODEL0_H_ 30 #define _CHAINCON_ATMODEL0_H_ 38 #include "chomp/system/config.h" 39 #include "chomp/system/textfile.h" 40 #include "chomp/system/timeused.h" 41 #include "chomp/struct/hashsets.h" 59 template <
class CellT,
class CellArray1,
class CellArray2,
class CellRestrT>
64 const CellRestrT &restr)
66 using chomp::homology::sout;
67 using chomp::homology::scon;
68 using chomp::homology::sbug;
75 sbug <<
"[AT Model Algorithm 0.]\n";
76 sout <<
"Computing an algebraic topological model...\n";
79 chomp::homology::timeused compTime;
83 chomp::homology::hashedset<CellT> homGener;
86 int_t KSize = K. size ();
87 for (int_t i = 0; i < KSize; ++ i)
91 scon << i <<
" out of " << KSize <<
", " <<
92 (i * 100 / KSize) <<
"% done.\r";
95 const CellT &c = K [i];
128 sout <<
"Debug: c = " << c <<
".\n";
129 sout <<
"Debug: bd_c = " <<
131 sout <<
"Debug: ch = " << ch <<
".\n";
132 sout <<
"Debug: bd_ch = " << bd_ch <<
".\n";
133 throw "Empty boundary in the homology algorithm.";
137 const CellT &u = d. getCell (0);
146 for (int_t j = 0; j < i; ++ j)
149 const CellT &cj = K [j];
162 int_t pos = xi. position (u);
167 phiAdd. add (cj, ch);
172 combination +=
boundary (phi (cj), restr);
173 combination += phiAdd (
boundary (cjChain, restr));
174 combination +=
boundary (phiAdd (cj), restr);
175 piAdd. add (cj, pi (combination));
183 for (int_t j = 0; j < i; ++ j)
186 const CellT &cj = K [j];
192 cjh += phi (
boundary (cjChain, restr));
198 int_t pos = xi. position (u);
205 combination +=
boundary (phi (cj), restr);
206 combination += phiAdd (
boundary (cjChain, restr));
207 combination +=
boundary (phiAdd (cj), restr);
208 piAddTest. add (cj, pi (combination));
212 if (!(piAdd == piAddTest))
214 sout <<
"ERROR: The computed two versions " 215 "of the map pi are not the same!\n";
216 sout <<
"i = " << i <<
", c_i = " << c <<
217 ", u = " << u <<
".\n";
218 sout <<
"The wrong map piAdd:\n" << piAdd;
219 sout <<
"The correct map piAdd:\n" << piAddTest;
220 throw "Wrong map pi detected.\n";
231 homGener.
remove (u);
236 sout <<
"AT model computed in " << compTime <<
".\n";
239 int_t genSize = homGener. size ();
240 for (int_t i = 0; i < genSize; ++ i)
241 H. push_back (homGener [i]);
247 #endif // _CHAINCON_ATMODEL0_H_ void algTopModel0(const CellArray1 &K, CellArray2 &H, tCombLinMap< CellT, CellT > &pi, tCombLinMap< CellT, CellT > &incl, tCombLinMap< CellT, CellT > &phi, const CellRestrT &restr)
Computes an algebraic topological model for a given filtered finite cell complex "K".
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 combinatorial linear map (for coefficients in Z_2).
A combinatorial linear map.