47 #include "chomp/system/config.h" 48 #include "chomp/system/textfile.h" 49 #include "chomp/system/timeused.h" 50 #include "chomp/struct/hashsets.h" 66 template <
class CellT,
class CoefT,
class CellArray1,
class CellArray2,
67 class CellArray3,
class CoefArray,
class CellNames>
70 CellArray1 &H, CellArray2 &A, CellArray3 &B, CoefArray &Q,
74 CellNames &homCellNames, CellNames &cohomCellNames,
75 bool displayPi,
bool displayIncl,
bool displayPhi,
76 bool displayD,
bool verify)
78 using chomp::homology::sout;
87 std::vector<std::vector<CellT> > representants;
88 std::vector<int> bettiNumbers;
89 std::vector<std::vector<CoefT> > torsion;
90 getHomCohom (H, A, B, Q, &representants, &bettiNumbers, &torsion,
92 sout <<
"Homology groups:\n";
96 std::vector<std::vector<CellT> > cohomRepresentants;
97 std::vector<int> cohomBettiNumbers;
98 std::vector<std::vector<CoefT> > cohomTorsion;
99 getHomCohom (H, A, B, Q, &cohomRepresentants, &cohomBettiNumbers,
100 &cohomTorsion,
true);
101 sout <<
"Cohomology groups:\n";
102 sout <<
homcohom2text (cohomBettiNumbers, cohomTorsion,
"H^",
false);
105 int homReprSize = representants. size ();
106 for (
int dim = 0; dim < homReprSize; ++ dim)
108 int size = representants [dim]. size ();
109 for (
int i = 0; i < size; ++ i)
110 homCellNames (representants [dim] [i]);
114 int cohomReprSize = cohomRepresentants. size ();
115 for (
int dim = 0; dim < cohomReprSize; ++ dim)
117 int size = cohomRepresentants [dim]. size ();
118 for (
int i = 0; i < size; ++ i)
119 cohomCellNames (cohomRepresentants [dim] [i]);
126 sout <<
"The projection map pi:\n" <<
131 sout <<
"The inclusion map incl:\n" <<
136 sout <<
"The chain contraction phi:\n" << phi;
140 sout <<
"The boundary map in the minimal model:\n";
141 for (int_t i = 0; i < A. size (); ++ i)
143 sout << homCellNames (A [i]) <<
" -> " << Q [i] <<
144 " * " << homCellNames (B [i]) <<
"\n";
158 if (phi * boundaryMap * phi == phi)
159 sout <<
"Verified: 'phi bd phi = phi'.\n";
161 sout <<
"Failed to verify that " 162 "'phi pd phi = phi'.\n";
164 if (boundaryMap * phi * boundaryMap == boundaryMap)
165 sout <<
"Verified: 'bd phi bd = bd'.\n";
168 sout <<
"Failed to verify that 'bd phi bd = bd', " 169 "which is OK if there is torsion.\n";
173 if (phi * phi == zeroMap)
174 sout <<
"Verified: 'phi phi = 0'.\n";
176 sout <<
"Failed to verify that 'phi phi = 0'.\n";
178 LinMap composition (boundaryMap * phi);
179 composition += phi * boundaryMap;
180 composition. negate ();
182 if (incl * pi == composition)
183 sout <<
"Verified: 'i pi = id - bd phi - phi bd'.\n";
185 sout <<
"Failed to verify that " 186 "'i pi = id - bd phi - phi bd'.\n";
192 if (pi * incl == idHAB)
193 sout <<
"Verified: 'pi i = id_H+A+B'.\n";
195 sout <<
"Failed to verify that 'pi i = id_H+A+B'.\n";
197 if (pi * phi == zeroMap)
198 sout <<
"Verified: 'pi phi = 0'.\n";
200 sout <<
"Failed to verify that 'pi phi = 0'.\n";
202 if (phi * incl == zeroMap)
203 sout <<
"Verified: 'phi i = 0'.\n";
205 sout <<
"Failed to verify that 'phi i = 0'.\n";
212 #endif // _AMMODCOMP_H_ Boundary computation at the level of chains of cells.
std::string homcohom2text(int bettiNumber, const std::vector< CoefT > &torsion, bool torsion_subscript)
Returns a text description of one (co)homology group.
A linear map for coefficients in an arbitrary commutative ring.
Computation of the algebraic minimal model using the SNF.
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 class for providing the cells as their names.
void getHomCohom(const CellArray1 &H, const CellArray2 &A, const CellArray3 &B, const CoefArray &Q, std::vector< std::vector< CellT > > *representants, std::vector< int > *bettiNumbers, std::vector< std::vector< CoefT > > *torsion, bool cohomology)
Computes Betti numbers and torsion coefficients for (co)homology from an algebraic minimal model (set...
A class for naming cells for nice text data output.
NamesT::NameType cells2names(const CellT &in, NamesT &names)
Returns the name of a cell according to the given naming object.
void computeAlgMinModel(const tFilteredComplex< CellT > &K, bool relativeComplex, CellArray1 &H, CellArray2 &A, CellArray3 &B, CoefArray &Q, tLinMap< CellT, CellT, CoefT > &pi, tLinMap< CellT, CellT, CoefT > &incl, tLinMap< CellT, CellT, CoefT > &phi, CellNames &homCellNames, CellNames &cohomCellNames, bool displayPi, bool displayIncl, bool displayPhi, bool displayD, bool verify)
Computes the homology of a cellular complex.
A generic procedure for reading a filtered cell complex or a pair of filtered cell complexes from tex...
void algMinModel(const tFilteredComplex< CellT > &K, CellArray1 &H, CellArray2 &A, CellArray3 &B, CoefArray &Q, tLinMap< CellT, CellT, CoefT > &pi, tLinMap< CellT, CellT, CoefT > &incl, tLinMap< CellT, CellT, CoefT > &phi)
Computes a minimal model for a given filtered finite cell complex "K".
void addIdentity(const CellArray &domain, tCombLinMap< CellT, CellT > &f)
Adds the identity map on the given domain to the map 'f'.
A template of a simple class for unrestricted cell selection in the boundary computation procedures...
Computation of the (co)homology groups of an algebraic minimal model.