28 #ifndef _CHAINCON_SSQUARESCUB_H_ 29 #define _CHAINCON_SSQUARESCUB_H_ 39 #include "chomp/system/config.h" 40 #include "chomp/struct/hashsets.h" 41 #include "chomp/struct/multitab.h" 61 STuples (
int length,
int range);
66 template <
class ArrayA,
class ArrayB>
67 bool get (ArrayA &A, ArrayB &B);
108 sB (length, range - 2 * length),
curB (length),
119 template <
class ArrayA,
class ArrayB>
122 int length (A. size ());
125 for (
int i = 0; i < length; ++ i)
151 const std::vector<int> &B)
154 int length (A. size ());
156 while ((countA < length) && (A [countA] <= x))
159 while ((countB < length) && (B [countB] <= x))
163 return ((x + countA + countB) & 1);
168 template <
class CubCellT>
170 const std::vector<int> &A,
const std::vector<int> &B,
171 int range,
bool right_hand_side)
173 using chomp::homology::sbug;
175 int length (A. size ());
177 CubCellT face (xCell);
180 for (
int i = length - 1; i >= 0; -- i)
183 face = CubCellT (face, sign ? B [i] :
184 (B [i] + face. dim ()));
189 for (
int i = length - 1; i >= 0; -- i)
192 face = CubCellT (face, sign ? A [i] :
193 (A [i] + face. dim ()));
207 template <
class CubCellT,
class CoefT>
212 using chomp::homology::sbug;
216 if ((i < 0) || (j < 0) || (i > j))
224 bool moreAvailable (
true);
225 while (moreAvailable)
228 std::vector<int> A (i);
229 std::vector<int> B (i);
230 moreAvailable = sTuples.
get (A, B);
233 bool wrongTuple (
false);
236 for (
int k = 0; k < i; ++ k)
238 if ((A [k] < i + j) && (B [k] < i + j))
240 sbug <<
"WRONG TUPLE: k = " << k <<
241 " and one of these: " <<
242 A [k] <<
" or " << B [k] <<
243 " is not < " << (i + j) <<
".\n";
249 if ((
false || wrongTuple) && (sbug. show || sbug. log))
251 sbug <<
"DEBUG: A = (";
252 for (
size_t c = 0; c < A. size (); ++ c)
253 sbug << (c ?
"," :
"") << A [c];
255 for (
size_t c = 0; c < B. size (); ++ c)
256 sbug << (c ?
"," :
"") << B [c];
261 int_t size = xChain. size ();
262 for (int_t s = 0; s < size; ++ s)
265 const CubCellT &sCell (xChain. getCell (s));
266 CoefT xCoef (xChain. getCoef (s));
269 if (sCell. dim () != (i + j))
271 sbug <<
"WRONG CELL DIMENSION: s = " << s <<
272 ", sCell = " << sCell <<
".\n";
273 sbug <<
"The dimension is " << sCell. dim () <<
274 ", and should be " << i <<
".\n";
286 int_t n1 (xFace1proj. position (cCell));
292 xCoef *= xFace1proj. getCoef (n1);
299 int_t n2 (xFace2proj. position (cCell));
305 xCoef *= xFace2proj. getCoef (n2);
307 sbug <<
"DEBUG: xFace1 = " << xFace1 <<
", proj = " <<
308 xFace1proj <<
", pos = " << n1 <<
309 ((n1 >= 0) ?
"!" :
".") <<
"\n";
310 sbug <<
"DEBUG: xFace2 = " << xFace2 <<
", proj = " <<
311 xFace2proj <<
", pos = " << n2 <<
312 ((n2 >= 0) ?
"!!" :
".") <<
"\n";
326 template <
class CubCellT,
class CoefT>
328 (
const std::vector<std::vector<CubCellT> > &cohomRepresentants,
334 using chomp::homology::sbug;
340 int maxDim = cohomRepresentants. size ();
342 for (
int j = 0; j < maxDim; ++ j)
344 if (cohomRepresentants [j]. empty ())
348 for (
int i = 0; (i <= j) && (i + j < maxDim); ++ i)
350 if (cohomRepresentants [i + j]. empty ())
356 int size_c = cohomRepresentants [j]. size ();
357 for (
int n = 0; n < size_c; ++ n)
360 const CubCellT &cCell (cohomRepresentants [j] [n]);
361 sbug <<
"DEBUG: cCell " << cCell <<
".\n";
365 int size_x = cohomRepresentants [j + i]. size ();
366 for (
int m = 0; m < size_x; ++ m)
369 const CubCellT &xCell (cohomRepresentants [j + i] [m]);
370 sbug <<
"DEBUG: xCell " << xCell <<
".\n";
374 sbug <<
"DEBUG: i = " << i <<
", j = " << j <<
", j+i = " << (j + i) <<
375 ", c = " << cCell <<
", x = " << xCell <<
"...\n";
379 CoefT coef (
ssquare (i, j, cCell, xChain, pi));
382 int_t num = cellsSquares. add
383 (CellSquareT (cCell, i));
384 sbug <<
"DEBUG: Sq^" << i <<
" (" << cCell <<
385 ") += " << coef <<
" * " << xCell <<
".\n";
386 squareValues [num]. add (xCell, coef);
396 template <
class CubCellT,
class CoefT>
398 (
const std::vector<std::vector<CubCellT> > &cohomRepresentants,
404 return ssquares (cohomRepresentants, pi, incl,
405 cellsSquares, squareValues);
409 template <
class CubCellT,
class CoefT>
411 (
const std::vector<std::vector<CubCellT> > &cohomRepresentants,
417 return ssquares (cohomRepresentants, pi, incl,
418 cellsSquares, squareValues);
422 #endif // _CHAINCON_SSQUARESCUB_H_ A pair of elements of two (possibly different) types.
A linear map for coefficients in an arbitrary commutative ring.
bool get(ArrayA &A, ArrayB &B)
Gets a pair of sets A and B.
int _length
The length of each tuple: A and B.
An iterator of all the (p,q)-shuffles.
An auxiliary class for iterating all the possible disjoint subsets A and B of integers in [0...
std::vector< int > curB
The current choice of B.
bool nextA
Remembers if the next choice of A is available.
A chain with coefficients in an arbitrary ring.
Shuffles sB
The shuffle iterator that defines the current choice of B.
CubCellT ssquare_face(const CubCellT &xCell, const std::vector< int > &A, const std::vector< int > &B, int range, bool right_hand_side)
Computes a given face of a simplicial cell.
std::vector< int > curBcompl
The current choice of the complement of B.
A tensor of chains with coefficients in an arbitrary commutative ring.
void ssquares1(const std::vector< std::vector< CubCellT > > &cohomRepresentants, const tLinMap< CubCellT, CubCellT, CoefT > &pi, const tLinMap< CubCellT, CubCellT, CoefT > &incl, chomp::homology::hashedset< tPair< CubCellT, int > > &cellsSquares, chomp::homology::multitable< tChain< CubCellT, CoefT > > &squareValues)
Computes the Steenrod squares using the only procedure in this case.
void ssquares(const std::vector< std::vector< CubCellT > > &cohomRepresentants, const tLinMap< CubCellT, CubCellT, CoefT > &pi, const tLinMap< CubCellT, CubCellT, CoefT > &incl, chomp::homology::hashedset< tPair< CubCellT, int > > &cellsSquares, chomp::homology::multitable< tChain< CubCellT, CoefT > > &squareValues)
Computes the Steenrod squares, given a minimal model and cohomology representants.
A chain with coefficients in an arbitrary commutative ring.
std::vector< int > curA
The current choice of A.
std::vector< int > curAcompl
The current choice of the complement of A.
STuples(int length, int range)
The only constructor allowed.
bool nextB
Remembers if the next choice of B is available.
void ssquares2(const std::vector< std::vector< CubCellT > > &cohomRepresentants, const tLinMap< CubCellT, CubCellT, CoefT > &pi, const tLinMap< CubCellT, CubCellT, CoefT > &incl, chomp::homology::hashedset< tPair< CubCellT, int > > &cellsSquares, chomp::homology::multitable< tChain< CubCellT, CoefT > > &squareValues)
Computes the Steenrod squares using the only procedure in this case.
int _range
The range of numbers that may appear in the tuples.
CoefT ssquare(int i, int j, const CubCellT &cCell, const tChain< CubCellT, CoefT > &xChain, const tLinMap< CubCellT, CubCellT, CoefT > &pi)
Computes a single Steenrod square.
Shuffles sA
The shuffle iterator that defines the current choice of A.
bool ssquare_sign(int x, const std::vector< int > &A, const std::vector< int > &B)
Computes the sign that appears in the formula for the face.