The ChainCon Software (Release 0.03)
ez_eml.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file
4 ///
5 /// The Eilenberg-Mac Lane operator as a component
6 /// of the Eilenberg-Zilber chain contraction.
7 ///
8 /////////////////////////////////////////////////////////////////////////////
9 
10 // Copyright (C) 2009-2016 by Pawel Pilarczyk.
11 //
12 // This file is part of my research software package. This is free software:
13 // you can redistribute it and/or modify it under the terms of the GNU
14 // General Public License as published by the Free Software Foundation,
15 // either version 3 of the License, or (at your option) any later version.
16 //
17 // This software is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this software; see the file "license.txt". If not,
24 // please, see <http://www.gnu.org/licenses/>.
25 
26 // Started on March 24, 2009. Last revision: December 4, 2014.
27 
28 
29 #ifndef _CHAINCON_EZ_EML_H_
30 #define _CHAINCON_EZ_EML_H_
31 
32 
33 // include some standard C++ header files
34 #include <istream>
35 #include <ostream>
36 
37 // include selected header files from the CHomP library
38 #include "chomp/system/config.h"
39 //#include "chomp/system/textfile.h"
40 
41 // include relevant local header files
42 #include "chaincon/combtensor.h"
43 #include "chaincon/tensor.h"
44 #include "chaincon/prodcell.h"
45 #include "chaincon/shuffles.h"
46 
47 
48 // --------------------------------------------------
49 // ------------------ EML operator ------------------
50 // --------------------------------------------------
51 
52 /// Computes the Eilenberg-Mac Lane operator on a tensor product
53 /// of two simplicial cells.
54 /// Combinatorial version (coefficients in Z_2).
55 template <class SimCellT, class ProdCellT>
56 inline void EZ_EML (const SimCellT &s1, const SimCellT &s2,
58 {
59  int p = s1. dim ();
60  int q = s2. dim ();
61  Shuffles s (p, q);
62  std::vector<int> alpha (p);
63  std::vector<int> beta (q);
64  int sig (0);
65  while (1)
66  {
67  // get the next shuffle
68  bool moreAvailable = s. get (alpha, beta, sig);
69 
70  // compute the degenerate cells
71  SimCellT cell1 (s1);
72  for (int i = 0; i < q; ++ i)
73  {
74  SimCellT cell1new (cell1, -1 - beta [i]);
75  cell1. swap (cell1new);
76  }
77  SimCellT cell2 (s2);
78  for (int i = 0; i < p; ++ i)
79  {
80  SimCellT cell2new (cell2, -1 - alpha [i]);
81  cell2. swap (cell2new);
82  }
83 
84  // add the product to the result
85  ProdCellT prod (cell1, cell2);
86  if (!prod. degenerate ())
87  t. add ();
88 
89  // finish the work if no more shuffles are available
90  if (!moreAvailable)
91  break;
92  }
93 
94  return;
95 } /* EZ_EML */
96 
97 /// Computes the Eilenberg-Mac Lane operator on a tensor product
98 /// of two simplicial cells.
99 template <class SimCellT, class ProdCellT, class CoefT>
100 inline void EZ_EML (const SimCellT &s1, const SimCellT &s2,
102 {
103 // using chomp::homology::sbug;
104 
105  int p = s1. dim ();
106  int q = s2. dim ();
107  Shuffles s (p, q);
108  std::vector<int> alpha (p);
109  std::vector<int> beta (q);
110  int sig (0);
111  while (1)
112  {
113  // get the next shuffle
114  bool moreAvailable = s. get (alpha, beta, sig);
115 
116  // compute the degenerate cells
117  SimCellT cell1 (s1);
118  for (int i = 0; i < q; ++ i)
119  {
120  SimCellT cell1new (cell1, -1 - beta [i]);
121  cell1. swap (cell1new);
122  }
123  SimCellT cell2 (s2);
124  for (int i = 0; i < p; ++ i)
125  {
126  SimCellT cell2new (cell2, -1 - alpha [i]);
127  cell2. swap (cell2new);
128  }
129 
130  // determine the correct coefficient
131  CoefT coef (1);
132  if (sig & 1)
133  coef. negate ();
134 
135  // add the product to the result
136  ProdCellT prod (cell1, cell2);
137  if (!prod. degenerate ())
138  t. add (prod, coef);
139  // sbug << "DEBUG EZ_EML: p = " << p <<
140  // ", q = " << q << ": " <<
141  // coef << " * " <<
142  // cell1 << " X " << cell2 << "\n";
143 
144  // finish the work if no more shuffles are available
145  if (!moreAvailable)
146  break;
147  }
148 
149  return;
150 } /* EZ_EML */
151 
152 // --------------------------------------------------
153 
154 /// Computes the Eilenberg-Mac Lane operator on a tensor product
155 /// of two simplicial cells.
156 /// Combinatorial version (coefficients in Z_2).
157 template <class SimCellT, class ProdCellT>
160 {
161  for (int_t n = 0; n < s. size (); ++ n)
162  {
163  tCombChain<ProdCellT> result;
164  EZ_EML (s. left (n), s. right (n), result);
165  t += result;
166  }
167 
168  return;
169 } /* EZ_EML */
170 
171 /// Computes the Eilenberg-Mac Lane operator on a tensor product
172 /// of two simplicial cells.
173 template <class SimCellT, class ProdCellT, class CoefT>
176 {
177  for (int_t n = 0; n < s. size (); ++ n)
178  {
180  EZ_EML (s. left (n), s. right (n), result);
181  result *= s. coef (n);
182  t += result;
183  }
184 
185  return;
186 } /* EZ_EML */
187 
188 
189 #endif // _CHAINCON_EZ_EML_H_
190 
An iterator of shuffles.
An iterator of all the (p,q)-shuffles.
Definition: shuffles.h:51
A Cartesian product of simplicial cells of arbitrary type.
A chain with coefficients in an arbitrary ring.
Definition: chain.h:50
A tensor of chains with coefficients in an arbitrary commutative ring.
Tensor of chains.
Definition: tensor.h:52
Combinatorial tensor of cells.
Definition: combtensor.h:53
A combinatorial chain.
Definition: combchain.h:49
A combinatorial tensor (for coefficients in Z_2).
void EZ_EML(const SimCellT &s1, const SimCellT &s2, tCombChain< ProdCellT > &t)
Computes the Eilenberg-Mac Lane operator on a tensor product of two simplicial cells.
Definition: ez_eml.h:56