The ChainCon Software (Release 0.03)
awdiag2dcomp.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file
4 ///
5 /// A generic procedure for the Alexander-Whithey diagonal computation
6 /// for 2-dimensional homology generators.
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: January 6, 2013.
29 
30 
31 #ifndef _AWDIAG2DCOMP_H_
32 #define _AWDIAG2DCOMP_H_
33 
34 
35 // include selected header files from the CHomP library
36 #include "chomp/system/config.h"
37 #include "chomp/system/textfile.h"
38 #include "chomp/system/timeused.h"
39 #include "chomp/struct/hashsets.h"
40 
41 // include relevant local header files
42 #include "chaincon/awdiag.h"
43 #include "chaincon/combchain.h"
44 #include "chaincon/combtensor.h"
45 #include "chaincon/comblinmap.h"
46 
47 
48 // --------------------------------------------------
49 // ---------------- compute homology ----------------
50 // --------------------------------------------------
51 
52 /// Computes the Alexander-Whithey diagonal for 2-dimensional
53 /// homology generators.
54 /// Uses the projection and inclusion maps computed previously
55 /// as parts of a chain contraction of a cell complex.
56 template <class CellT, class LinMap, class CellNames, class CellRestrT>
57 void computeAWdiagonal2d (const chomp::homology::hashedset<CellT> &H,
58  const LinMap &pi, const LinMap &incl, CellNames &cellNames,
59  bool displayDiag, bool verify, const CellRestrT &restr)
60 {
61  using chomp::homology::sout;
62 
63  typedef typename LinMap::ChainDomType ChainType;
64  typedef typename LinMap::TensorDomType TensorType;
65 
66  // compute the AW decomposition of each 2D homology generator
67  int_t Hsize = H. size ();
68  for (int_t i = 0; i < Hsize; ++ i)
69  {
70  if (H [i]. dim () != 2)
71  continue;
72  ChainType homGen = incl (H [i]);
73  TensorType diag;
74  AWdiagonal (homGen, diag);
75  if (displayDiag)
76  {
77  sout << "A-W diagonal of " << cellNames (H [i]) <<
78  ":\n";
79  int_t size = homGen. size ();
80  for (int_t j = 0; j < size; ++ j)
81  {
82  ChainType chain;
83  chain. add (homGen. getCell (j));
84  TensorType diagGen;
85  AWdiagonal (chain, diagGen);
86  sout << homGen. getCell (j) << " -> " <<
87  diagGen << "\n";
88  }
89  // sout << "which reduces to:\n" << diag << "\n";
90  }
91  int_t n = diag. size ();
92  TensorType diag1dim;
93  for (int_t j = 0; j < n; ++ j)
94  {
95  if (diag. left (j). dim () != 1)
96  continue;
97  if (diag. right (j). dim () != 1)
98  continue;
99  diag1dim. add (diag. left (j), diag. right (j));
100  }
101  TensorType diagBoundary;
102  if (verify)
103  computeBoundary (diag1dim, diagBoundary, restr);
104  if (displayDiag)
105  {
106  sout << "restricted to 1-dim:\n" << diag1dim << "\n";
107  if (verify)
108  {
109  sout << "its boundary: " <<
110  diagBoundary << "\n";
111  }
112  }
113  if (verify)
114  {
115  if (diagBoundary. empty ())
116  sout << "Verified: bd AW " <<
117  cellNames (H [i]) << " = 0.\n";
118  else
119  sout << "Failed to verify that bd AW " <<
120  cellNames (H [i]) << " = 0.\n";
121  }
122  TensorType diagHom (pi (diag1dim));
123  sout << "A-W decomp of " << cellNames (H [i]) << ": " <<
124  cells2names (diagHom, cellNames, cellNames) << "\n";
125  }
126 
127  return;
128 } /* computeAWdiagonal */
129 
130 
131 #endif // _AWDIAG2DCOMP_H_
132 
A combinatorial chain, that is, a chain with Z_2 coefficients.
A combinatorial linear map (for coefficients in Z_2).
void computeAWdiagonal2d(const chomp::homology::hashedset< CellT > &H, const LinMap &pi, const LinMap &incl, CellNames &cellNames, bool displayDiag, bool verify, const CellRestrT &restr)
Computes the Alexander-Whithey diagonal for 2-dimensional homology generators.
Definition: awdiag2dcomp.h:57
void computeBoundary(const CellT &c, tCombChain< CellT > &b, const CellRestrT &restr)
Adds the boundary of a given cell to the provided chain (takes boundary cells restricted by the given...
Definition: boundary.h:118
A combinatorial tensor (for coefficients in Z_2).
NamesT::NameType cells2names(const CellT &in, NamesT &names)
Returns the name of a cell according to the given naming object.
Definition: cellnames.h:343
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
Alexander-Whitney diagonal of a chain.