28 #ifndef _CHAINCON_SSQUARESSIM_H_ 29 #define _CHAINCON_SSQUARESSIM_H_ 39 #include "chomp/system/config.h" 40 #include "chomp/struct/hashsets.h" 41 #include "chomp/struct/multitab.h" 61 template <
class ProdCellT,
class CoefT>
65 int_t length (input. size ());
66 for (int_t i = 0; i < length; ++ i)
68 result. add (ProdCellT (input. getCell (i). getRight (),
69 input. getCell (i). getLeft ()),
77 template <
class CellT,
class ProdCellT,
class CoefT>
81 int_t xSize = x. size ();
82 for (int_t i = 0; i < xSize; ++ i)
84 const CellT &xCell (x. getCell (i));
85 const CoefT &xCoef (x. getCoef (i));
86 result. add (ProdCellT (xCell, xCell), xCoef);
93 template <
class CellT,
class ProdCellT,
class CoefT>
97 int_t size (chain. size ());
98 for (int_t i = 0; i < size; ++ i)
100 result. add (chain. getCell (i). getCell (),
108 template <
class Cell1T,
class Cell2T,
class ProdCell1T,
class ProdCell2T,
114 int_t size (tensor. size ());
115 for (int_t i = 0; i < size; ++ i)
117 result. add (tensor. left (i). getCell (),
118 tensor. right (i). getCell (),
137 template <
class SimCellT,
class CoefT>
139 (
const std::vector<std::vector<SimCellT> > &cohomRepresentants,
145 using chomp::homology::sbug;
151 int maxDim = cohomRepresentants. size ();
152 for (
int dim = 0; dim < maxDim; ++ dim)
158 int size = cohomRepresentants [dim]. size ();
159 for (
int n = 0; n < size; ++ n)
162 const SimCellT &xCell (cohomRepresentants [dim] [n]);
178 for (
int k = 0; k <= dim; ++ k)
200 int squareOrder = (dim - k) / 2;
201 int dim1 = (dim + k) / 2;
211 EZ_AW (xx, awdiagProd);
218 int_t awdiagSize = awdiag. size ();
223 int size1 = cohomRepresentants [dim1]. size ();
224 for (
int i1 = 0; i1 < size1; ++ i1)
226 const SimCellT &cell1 =
227 cohomRepresentants [dim1] [i1];
228 for (int_t j = 0; j < awdiagSize; ++ j)
230 if (!(awdiag. left (j) == cell1))
232 if (!(awdiag. right (j) == cell1))
234 CoefT coef (awdiag. coef (j));
237 int_t n = cellsSquares. add
238 (CellSquareT (cell1, squareOrder));
246 squareValues [n]. add (xCell, coef);
258 inline int ssquare_S (
int k,
const std::vector<int> &ii,
int n,
int m)
260 using chomp::homology::sbug;
264 for (
int a = k + 1; a <= n; ++ a)
278 throw "A negative value of S detected.";
284 template <
class SimCellT>
286 const std::vector<int> &ii,
int n,
int m,
bool right_hand_side)
288 using chomp::homology::sbug;
290 SimCellT face (xCell);
296 if (!right_hand_side)
298 for (
int a = n; a >= 0; a -= 2)
300 for (
int b = ((a == n) ? m : (ii [a + 1] - 1));
301 b >= (ii [a] + 1); -- b)
303 face = SimCellT (face, b);
310 for (
int a = n; a >= 0; a -= 2)
312 for (
int b = ii [a] - 1; b >=
313 ((a == 0) ? 0 : (ii [a - 1] + 1));
316 face = SimCellT (face, b);
325 if (!right_hand_side)
327 for (
int a = n; a >= 1; a -= 2)
329 for (
int b = (ii [a] - 1);
330 b >= (ii [a - 1] + 1); -- b)
332 face = SimCellT (face, b);
339 for (
int a = n; a >= -1; a -= 2)
341 for (
int b = ((a == n) ? m : (ii [a + 1] - 1));
342 b >= ((a == -1) ? 0 : (ii [a] + 1));
345 face = SimCellT (face, b);
356 template <
class SimCellT,
class CoefT>
361 using chomp::homology::sbug;
365 if ((i < 0) || (j < 0) || (i > j))
375 std::vector<int> ii (n + 1);
376 for (
int k = n; k >= 0; -- k)
391 int_t size = xChain. size ();
392 for (int_t s = 0; s < size; ++ s)
395 const SimCellT &sCell (xChain. getCell (s));
396 CoefT xCoef (xChain. getCoef (s));
408 int_t n1 (xFace1proj. position (cCell));
413 xCoef *= xFace1proj. getCoef (n1);
421 int_t n2 (xFace2proj. position (cCell));
426 xCoef *= xFace2proj. getCoef (n2);
434 for (
int k = n; k >= 1; -- k)
437 if (ii [k] <= ((k == n) ? m : (ii [k + 1] - 1)))
460 template <
class SimCellT,
class CoefT>
462 (
const std::vector<std::vector<SimCellT> > &cohomRepresentants,
468 using chomp::homology::sbug;
474 int maxDim = cohomRepresentants. size ();
476 for (
int j = 0; j < maxDim; ++ j)
478 if (cohomRepresentants [j]. empty ())
482 for (
int i = 0; (i <= j) && (i + j < maxDim); ++ i)
484 if (cohomRepresentants [i + j]. empty ())
490 int size_c = cohomRepresentants [j]. size ();
491 for (
int n = 0; n < size_c; ++ n)
494 const SimCellT &cCell (cohomRepresentants [j] [n]);
499 int size_x = cohomRepresentants [j + i]. size ();
500 for (
int m = 0; m < size_x; ++ m)
503 const SimCellT &xCell (cohomRepresentants [j + i] [m]);
513 CoefT coef (
ssquare (i, j, cCell, xChain, pi));
516 int_t num = cellsSquares. add
517 (CellSquareT (cCell, i));
520 squareValues [num]. add (xCell, coef);
535 template <
class SimCellT,
class CoefT>
537 (
const std::vector<std::vector<SimCellT> > &cohomRepresentants,
543 return ssquares2 (cohomRepresentants, pi, incl,
544 cellsSquares, squareValues);
548 #endif // _CHAINCON_SSQUARESSIM_H_ void computeDiagonal(const tChain< CellT, CoefT > &x, tChain< ProdCellT, CoefT > &result)
Computes the diagonal of a chain.
void ssquares1(const std::vector< std::vector< SimCellT > > &cohomRepresentants, const tLinMap< SimCellT, SimCellT, CoefT > &pi, const tLinMap< SimCellT, SimCellT, CoefT > &incl, chomp::homology::hashedset< tPair< SimCellT, int > > &cellsSquares, chomp::homology::multitable< tChain< SimCellT, CoefT > > &squareValues)
Computes the Steenrod squares, given a minimal model and cohomology representants.
A pair of elements of two (possibly different) types.
void ssquares(const std::vector< std::vector< SimCellT > > &cohomRepresentants, const tLinMap< SimCellT, SimCellT, CoefT > &pi, const tLinMap< SimCellT, SimCellT, CoefT > &incl, chomp::homology::hashedset< tPair< SimCellT, int > > &cellsSquares, chomp::homology::multitable< tChain< SimCellT, CoefT > > &squareValues)
Computes the Steenrod squares, given a minimal model and cohomology representants.
void flattenProduct(const tChain< ProdCellT, CoefT > &chain, tChain< CellT, CoefT > &result)
Converts a chain of cells encoded as trivial product cells to the chain of the actual cells...
A linear map for coefficients in an arbitrary commutative ring.
void ssquares2(const std::vector< std::vector< SimCellT > > &cohomRepresentants, const tLinMap< SimCellT, SimCellT, CoefT > &pi, const tLinMap< SimCellT, SimCellT, CoefT > &incl, chomp::homology::hashedset< tPair< SimCellT, int > > &cellsSquares, chomp::homology::multitable< tChain< SimCellT, CoefT > > &squareValues)
Computes the Steenrod squares, given a minimal model and cohomology representants.
void swapProduct(const tChain< ProdCellT, CoefT > &input, tChain< ProdCellT, CoefT > &result)
Swaps the components of all of the product cells in the chain.
The Shih operator as a component of the Eilenberg-Zilber chain contraction.
A Cartesian product of simplicial cells of arbitrary type.
A chain with coefficients in an arbitrary ring.
A tensor of chains with coefficients in an arbitrary commutative ring.
void EZ_SHI(const SimCellT &s1, const SimCellT &s2, tCombChain< ProdCellT > &t)
Computes the Shih operator on a product of two simplicial cells.
CoefT ssquare(int i, int j, const SimCellT &cCell, const tChain< SimCellT, CoefT > &xChain, const tLinMap< SimCellT, SimCellT, CoefT > &pi)
Computes a single Steenrod square.
void EZ_AW(const SimCellT &s1, const SimCellT &s2, tCombTensor< SimCellT, SimCellT > &t)
Computes the Alexander-Whitney operator on a product of simplicial cells.
A chain with coefficients in an arbitrary commutative ring.
The Alexander-Whitney operator as a component of the Eilenberg-Zilber chain contraction.
A Cartesian product of simplicial cells as a simplicial cell.
int ssquare_S(int k, const std::vector< int > &ii, int n, int m)
Computes the k-th value of the index S in the sum ranges defined in Corollary 3.2 in [CombSteenSq]...
SimCellT ssquare_face(const SimCellT &xCell, const std::vector< int > &ii, int n, int m, bool right_hand_side)
Computes the faces of a simplicial cell.