The ChainCon Software (Release 0.03)
cring.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file
4 ///
5 /// Computation of the cohomology ring.
6 ///
7 /////////////////////////////////////////////////////////////////////////////
8 
9 // Copyright (C) 2009-2016 by Pawel Pilarczyk.
10 //
11 // This file is part of my research software package. This is free software:
12 // you can redistribute it and/or modify it under the terms of the GNU
13 // General Public License as published by the Free Software Foundation,
14 // either version 3 of the License, or (at your option) any later version.
15 //
16 // This software is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this software; see the file "license.txt". If not,
23 // please, see <http://www.gnu.org/licenses/>.
24 
25 // Started on March 24, 2009. Last revision: September 17, 2015.
26 
27 
28 #ifndef _CHAINCON_CRING_H_
29 #define _CHAINCON_CRING_H_
30 
31 
32 // include some standard C++ header files
33 #include <istream>
34 #include <ostream>
35 #include <vector>
36 
37 // include selected header files from the CHomP library
38 #include "chomp/system/config.h"
39 #include "chomp/struct/hashsets.h"
40 #include "chomp/struct/multitab.h"
41 
42 // include relevant local header files
43 #include "chaincon/chain.h"
44 #include "chaincon/linmap.h"
45 #include "chaincon/pair.h"
46 #include "chaincon/awdiag.h"
47 
48 
49 // --------------------------------------------------
50 // ---------------- cohomology ring -----------------
51 // --------------------------------------------------
52 
53 /// Computes the cohomology ring, given a minimal model
54 /// and cohomology representants.
55 /// Please, make sure to include the appropriate header file with the
56 /// definition of the Alexander-Whitney diagonal for the cells in use
57 /// before including the header file containing this procedure.
58 template <class CellT, class CoefT>
59 inline void cring (const std::vector<std::vector<CellT> > &cohomRepresentants,
61  const tLinMap<CellT,CellT,CoefT> &incl,
62  chomp::homology::hashedset<tPair<CellT,CellT> > &cellPairs,
63  chomp::homology::multitable<tChain<CellT,CoefT> > &cupProducts)
64 {
65  typedef tPair<CellT,CellT> CellPair;
66 
67  int maxDim = cohomRepresentants. size ();
68  for (int dim = 0; dim < maxDim; ++ dim)
69  {
70  // take all the "big" cells of the given dimension
71  int size = cohomRepresentants [dim]. size ();
72  for (int i = 0; i < size; ++ i)
73  {
74  // take a cohomology representant cell
75  const CellT &cell = cohomRepresentants [dim] [i];
76  // sbug << "DEBUG: cell " << cell << ".\n";
77 
78  // compute the cycle chain that corresponds
79  // to this representant
80  tChain<CellT,CoefT> chain (incl (cell));
81 
82  // compute the A-W diagonal of this cycle
83  tTensor<CellT,CellT,CoefT> awdiagFull;
84  AWdiagonal (chain, awdiagFull);
85  // sbug << "DEBUG: awdiagFull = " << awdiagFull << ".\n";
86 
87  // project the computed tensor to the model
88  tTensor<CellT,CellT,CoefT> awdiag (pi (awdiagFull));
89  int_t awdiagSize = awdiag. size ();
90  // sbug << "DEBUG: awdiag = " << awdiag << ".\n";
91 
92 // CODE Version 1:
93  // consider all the cohomology representants
94  // that may have the big cell in their cup product
95  for (int dim1 = 0; dim1 <= dim; ++ dim1)
96  {
97  int dim2 = dim - dim1;
98  int size1 = cohomRepresentants [dim1]. size ();
99  int size2 = cohomRepresentants [dim2]. size ();
100  for (int i1 = 0; i1 < size1; ++ i1)
101  {
102  const CellT &cell1 =
103  cohomRepresentants [dim1] [i1];
104  for (int i2 = 0; i2 < size2; ++ i2)
105  {
106  const CellT &cell2 =
107  cohomRepresentants [dim2] [i2];
108  for (int_t j = 0; j < awdiagSize; ++ j)
109  {
110  if (!(awdiag. left (j) == cell1))
111  continue;
112  if (!(awdiag. right (j) == cell2))
113  continue;
114  CoefT coef (awdiag. coef (j));
115  if (coef == 0)
116  continue;
117  int_t n = cellPairs. add
118  (CellPair (cell1, cell2));
119  cupProducts [n]. add (cell, coef);
120  }
121  }
122  }
123  }
124 /*
125 // CODE Version 2:
126  // update the cup products of all the pairs
127  // of cohomology representants
128  // in which the big cell appears
129  for (int_t j = 0; j < awdiagSize; ++ j)
130  {
131  // make sure that the coefficient is nonzero
132  CoefT coef (awdiag. coef (j));
133  if (coef == 0)
134  continue;
135 
136  // make sure that both cells appear
137  // in the lists of cohomology representants
138  // (otherwise ignore this product)
139  int foundCount (0);
140  for (int c = 0; c < 2; ++ c)
141  {
142  const CellT &cell1 = c ?
143  awdiag. left (j) :
144  awdiag. right (j);
145  int dim1 = cell1. dim ();
146  int size0 (cohomRepresentants. size ());
147  if (dim1 >= size0)
148  throw "Cell1 dim out of range.";
149  int size1 = cohomRepresentants [dim1]. size ();
150  bool found (false);
151  for (int i1 = 0; i1 < size1; ++ i1)
152  {
153  if (cohomRepresentants [dim1] [i1] == cell1)
154  {
155  found = true;
156  ++ foundCount;
157  break;
158  }
159  }
160  if (found)
161  continue;
162  // throw "A wrong cohomology representant "
163  // "in cup product detected.";
164  }
165  if (foundCount < 2)
166  continue;
167 
168  int_t n = cellPairs. add
169  (CellPair (awdiag. left (j),
170  awdiag. right (j)));
171  cupProducts [n]. add (cell, coef);
172  }
173 */
174  }
175  }
176  return;
177 } /* cring */
178 
179 
180 #endif // _CHAINCON_CRING_H_
181 
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 chain with coefficients in an arbitrary ring.
Definition: chain.h:50
A linear map.
Definition: linmap.h:55
Tensor of chains.
Definition: tensor.h:52
A chain with coefficients in an arbitrary commutative ring.
void AWdiagonal(const tCombChain< CellT > &ch, tCombTensor< CellT, CellT > &t)
Computes the Alexander-Whitney diagonal of a chain, using the procedure defined for individual cells...
Definition: awdiag.h:51
A pair of elements.
Alexander-Whitney diagonal of a chain.