The ChainCon Software (Release 0.03)
cringcomp.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file
4 ///
5 /// A generic procedure for the computation of the cohomology ring structure
6 /// for an algebraic minimal model.
7 /// This is a complete procedure good for simplicial, cubical,
8 /// or other complexes.
9 ///
10 /////////////////////////////////////////////////////////////////////////////
11 
12 // Copyright (C) 2009-2016 by Pawel Pilarczyk.
13 //
14 // This file is part of my research software package. This is free software:
15 // you can redistribute it and/or modify it under the terms of the GNU
16 // General Public License as published by the Free Software Foundation,
17 // either version 3 of the License, or (at your option) any later version.
18 //
19 // This software is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this software; see the file "license.txt". If not,
26 // please, see <http://www.gnu.org/licenses/>.
27 
28 // Started on March 24, 2009. Last revision: September 17, 2015.
29 
30 
31 #ifndef _CRINGCOMP_H_
32 #define _CRINGCOMP_H_
33 
34 
35 // include some standard C++ header files
36 #include <istream>
37 #include <ostream>
38 #include <vector>
39 #include <utility>
40 
41 // include selected header files from the CHomP library
42 #include "chomp/system/config.h"
43 #include "chomp/system/textfile.h"
44 #include "chomp/system/timeused.h"
45 #include "chomp/struct/hashsets.h"
46 #include "chomp/struct/multitab.h"
47 
48 // include relevant local header files
49 #include "chaincon/cellnames.h"
50 #include "chaincon/linmap.h"
51 #include "chaincon/pair.h"
52 #include "chaincon/cring.h"
53 
54 
55 // --------------------------------------------------
56 // ------------ compute cohomology ring -------------
57 // --------------------------------------------------
58 
59 /// Computes the cohomology ring, given a minimal model of a cell complex,
60 /// and shows the result.
61 template <class CellT, class CoefT, class CellArray1, class CellArray2,
62  class CellArray3, class CoefArray, class CellNames>
63 inline void computeCohomRing (const CellArray1 &H, const CellArray2 &A,
64  const CellArray3 &B, const CoefArray &Q,
66  const tLinMap<CellT,CellT,CoefT> &incl,
67  CellNames &cellNames, bool verify)
68 {
69  using chomp::homology::sout;
70  using chomp::homology::sbug;
71  using chomp::homology::timeused;
72  using chomp::homology::hashedset;
73  using chomp::homology::multitable;
74 
75 // typedef typename LinMap::CellDomType CellT;
76 // typedef tLinMap<CellT,CellT,CoefT> LinMap;
77 
78  // prepare
79  timeused compTime;
80  compTime = 0;
81 
82  // determine cohomology generators
83 // sout << "Determining cohomology generators "
84 // "from the algebraic minimal model...\n";
85  std::vector<std::vector<CellT> > cohomRepresentants;
86  std::vector<int> cohomBettiNumbers;
87  std::vector<std::vector<CoefT> > cohomTorsion;
88  getHomCohom (H, A, B, Q, &cohomRepresentants, &cohomBettiNumbers,
89  &cohomTorsion, true);
90 
91  // prepare correct cell names (in case it was not done before)
92 // sout << "Setting up names of the representants...\n";
93  int cohomReprSize = cohomRepresentants. size ();
94  for (int dim = 0; dim < cohomReprSize; ++ dim)
95  {
96  int size = cohomRepresentants [dim]. size ();
97  for (int i = 0; i < size; ++ i)
98  cellNames (cohomRepresentants [dim] [i]);
99  }
100 
101  // prepare a data structure for the cup products
102  typedef tPair<CellT,CellT> CellPair;
103  hashedset<CellPair> cellPairs;
104  multitable<tChain<CellT,CoefT> > cupProducts;
105 
106  // compute all the cup products
107  cring (cohomRepresentants, pi, incl, cellPairs, cupProducts);
108 
109  // show the computed nonzero cup products
110  // in the ascending order by the dimension of the "big" cells
111  bool nonzeroFound = false;
112  int_t size = cellPairs. size ();
113  for (int_t n = 0; n < size; ++ n)
114  {
115  if (cupProducts [n]. empty ())
116  continue;
117  if (!nonzeroFound)
118  {
119  sout << "The computed nonzero cup products are:\n";
120  nonzeroFound = true;
121  }
122  sout << cellNames (cellPairs [n]. left) << " u " <<
123  cellNames (cellPairs [n]. right) << " = " <<
124  cells2names (cupProducts [n], cellNames) << ".\n";
125  }
126  if (!nonzeroFound)
127  sout << "All the computed cup products are trivial.\n";
128 
129  // show information on the total computation time
130  sout << "The ring structure was computed in " << compTime << ".\n";
131 
132  return;
133 } /* computeCohomRing */
134 
135 
136 #endif // _CRINGCOMP_H_
137 
void computeCohomRing(const CellArray1 &H, const CellArray2 &A, const CellArray3 &B, const CoefArray &Q, const tLinMap< CellT, CellT, CoefT > &pi, const tLinMap< CellT, CellT, CoefT > &incl, CellNames &cellNames, bool verify)
Computes the cohomology ring, given a minimal model of a cell complex, and shows the result...
Definition: cringcomp.h:63
A pair of elements of two (possibly different) types.
Definition: pair.h:48
void cring(const std::vector< std::vector< CellT > > &cohomRepresentants, const tLinMap< CellT, CellT, CoefT > &pi, const tLinMap< CellT, CellT, CoefT > &incl, chomp::homology::hashedset< tPair< CellT, CellT > > &cellPairs, chomp::homology::multitable< tChain< CellT, CoefT > > &cupProducts)
Computes the cohomology ring, given a minimal model and cohomology representants. ...
Definition: cring.h:59
A linear map for coefficients in an arbitrary commutative ring.
A linear map.
Definition: linmap.h:55
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...
Definition: homcohom.h:57
Computation of the cohomology ring.
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.
Definition: cellnames.h:343
A pair of elements.