30 #ifndef _CHAINCON_ATMODEL2R_H_ 31 #define _CHAINCON_ATMODEL2R_H_ 39 #include "chomp/system/config.h" 40 #include "chomp/system/textfile.h" 41 #include "chomp/system/timeused.h" 42 #include "chomp/struct/hashsets.h" 61 template <
class CellT,
class CoefT,
class CellArray1,
class CellArray2,
67 const CellRestrT &restr)
69 using chomp::homology::sout;
70 using chomp::homology::scon;
71 using chomp::homology::sbug;
78 sbug <<
"[AT Model Algorithm 2r.]\n";
79 sout <<
"Computing an algebraic topological model...\n";
82 chomp::homology::timeused compTime;
86 chomp::homology::hashedset<CellT> homGener;
94 int_t KSize = K. size ();
95 for (int_t i = 0; i < KSize; ++ i)
99 scon << i <<
" out of " << KSize <<
", " <<
100 (i * 100 / KSize) <<
"% done.\r";
103 const CellT &c = K [i];
108 cChain. add (c, CoefT (1));
110 ch. add (c, CoefT (1));
112 ch += phi (
boundary (cChain, restr));
131 pi. add (c, c, CoefT (1));
142 int_t dsize = d. size ();
148 sout <<
"Debug: c = " << c <<
".\n";
149 sout <<
"Debug: bd_c = " <<
151 sout <<
"Debug: ch = " << ch <<
".\n";
152 sout <<
"Debug: bd_ch = " << bd_ch <<
".\n";
153 throw "Empty boundary in the homology algorithm 2r.";
157 const CellT &u = d. getCell (0);
160 CoefT lambdaInv (d. getCoef (0));
161 lambdaInv. invert ();
166 int_t size = piTu. size ();
167 for (int_t j = 0; j < size; ++ j)
170 const CellT &cj = piTu. getCell (j);
176 int_t pos = picj. position (u);
178 throw "ATmodel: u not found in pi(cj).";
179 CoefT etaLambdaInv (picj. getCoef (pos));
180 etaLambdaInv *= lambdaInv;
184 elich *= etaLambdaInv;
185 phi. add (cj, elich);
194 etaLambdaInv. negate ();
195 melid *= etaLambdaInv;
201 for (int_t k = 0; k < dsize; ++ k)
204 const CellT &dk (d. getCell (k));
206 (picj. position (dk) >= 0);
208 (prev. position (dk) >= 0);
209 if (newContains != prevContains)
215 homGener.
remove (u);
221 int_t genSize = homGener. size ();
222 for (int_t i = 0; i < genSize; ++ i)
223 H. push_back (homGener [i]);
226 sout <<
"AT model computed in " << compTime <<
".\n";
232 #endif // _CHAINCON_ATMODEL2R_H_ A linear map for coefficients in an arbitrary commutative ring.
void algTopModel2(const CellArray1 &K, CellArray2 &H, tLinMap< CellT, CellT, CoefT > &pi, tLinMap< CellT, CellT, CoefT > &incl, tLinMap< CellT, CellT, CoefT > &phi, const CellRestrT &restr)
Computes an algebraic topological model for the 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 chain with coefficients in an arbitrary ring.
A combinatorial linear map (for coefficients in Z_2).
A chain with coefficients in an arbitrary commutative ring.
A combinatorial linear map.