The ChainCon Software (Release 0.03)
ez_aw.h
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////////////
2 ///
3 /// \file
4 ///
5 /// The Alexander-Whitney 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_AW_H_
30 #define _CHAINCON_EZ_AW_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 
40 // include relevant local header files
41 #include "chaincon/combtensor.h"
42 #include "chaincon/tensor.h"
43 
44 
45 // --------------------------------------------------
46 // ------------------ AW operator -------------------
47 // --------------------------------------------------
48 
49 /// Computes the compositions of face operators on the given simplicial cell
50 /// to get the appropriate cells for the AW operator.
51 template <class ArrayT, class SimCellT>
52 inline void AW_cells (ArrayT &sb, const SimCellT &s, bool left)
53 {
54  if (left)
55  {
56  sb [s. dim ()] = s;
57  for (int i = s. dim () - 1; i >= 0; -- i)
58  sb [i] = SimCellT (sb [i + 1], i + 1);
59  }
60  else
61  {
62  sb [0] = s;
63  for (int i = 0; i <= s. dim (); ++ i)
64  {
65  sb [i] = s;
66  for (int j = i - 1; j >= 0; -- j)
67  sb [i] = SimCellT (sb [i], j);
68  }
69  }
70  return;
71 } /* AW_cells */
72 
73 /// Computes the Alexander-Whitney operator on a product of simplicial cells.
74 /// Combinatorial version (coefficients in Z_2).
75 template <class SimCellT>
76 inline void EZ_AW (const SimCellT &s1, const SimCellT &s2,
78 {
79  int dim = s1. dim ();
80  if (dim != s2. dim ())
81  throw "Different dimensions in the AW operator.";
82 
83  std::vector<SimCellT> s1b (dim + 1);
84  AW_cells (s1b, s1, true);
85  std::vector<SimCellT> s2b (dim + 1);
86  AW_cells (s2b, s2, false);
87 
88  for (int n = 0; n <= dim; ++ n)
89  {
90  if (!s1b [n]. degenerate () && !s2b [n]. degenerate ())
91  t. add (s1b [n], s2b [n]);
92  }
93 
94  return;
95 } /* EZ_AW */
96 
97 /// Computes the Alexander-Whitney operator on a product of simplicial cells.
98 template <class SimCellT, class CoefT>
99 inline void EZ_AW (const SimCellT &s1, const SimCellT &s2,
101 {
102  int dim = s1. dim ();
103  if (dim != s2. dim ())
104  throw "Different dimensions in the AW operator.";
105 
106  std::vector<SimCellT> s1b (dim + 1);
107  AW_cells (s1b, s1, true);
108  std::vector<SimCellT> s2b (dim + 1);
109  AW_cells (s2b, s2, false);
110 
111  CoefT coef (1);
112  for (int n = 0; n <= dim; ++ n)
113  {
114  if (!s1b [n]. degenerate () && !s2b [n]. degenerate ())
115  t. add (s1b [n], s2b [n], coef);
116  }
117 
118  return;
119 } /* EZ_AW */
120 
121 // --------------------------------------------------
122 
123 /// Computes the Alexander-Whitney operator on a product of simplicial cells.
124 /// Combinatorial version (coefficients in Z_2).
125 template <class ProdCellT>
126 inline void EZ_AW (const ProdCellT &s,
128 {
129  EZ_AW (s. getLeft (), s. getRight (), t);
130 
131  return;
132 } /* EZ_AW */
133 
134 /// Computes the Alexander-Whitney operator on a product of simplicial cells.
135 template <class SimCellT, class ProdCellT, class CoefT>
136 inline void EZ_AW (const ProdCellT &s,
138 {
139  EZ_AW (s. getLeft (), s. getRight (), t);
140 
141  return;
142 } /* EZ_AW */
143 
144 // --------------------------------------------------
145 
146 /// Computes the Alexander-Whitney operator on a chain of products
147 /// of simplicial cells.
148 /// Combinatorial version (coefficients in Z_2).
149 template <class SimCellT, class ProdCellT>
150 inline void EZ_AW (const tCombChain<ProdCellT> &s,
152 {
153  for (int_t n = 0; n < s. size (); ++ n)
154  {
156  EZ_AW (s. getCell (n), result);
157  t += result;
158  }
159 
160  return;
161 } /* EZ_AW */
162 
163 /// Computes the Alexander-Whitney operator on a chain of products
164 /// of simplicial cells.
165 template <class SimCellT, class ProdCellT, class CoefT>
166 inline void EZ_AW (const tChain<ProdCellT,CoefT> &s,
168 {
169  for (int_t n = 0; n < s. size (); ++ n)
170  {
172  EZ_AW (s. getCell (n), result);
173  result *= s. getCoef (n);
174  t += result;
175  }
176 
177  return;
178 } /* EZ_AW */
179 
180 
181 #endif // _CHAINCON_EZ_AW_H_
182 
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_AW(const SimCellT &s1, const SimCellT &s2, tCombTensor< SimCellT, SimCellT > &t)
Computes the Alexander-Whitney operator on a product of simplicial cells.
Definition: ez_aw.h:76
void AW_cells(ArrayT &sb, const SimCellT &s, bool left)
Computes the compositions of face operators on the given simplicial cell to get the appropriate cells...
Definition: ez_aw.h:52