28 #ifndef _CHAINCON_AWDIAGCUB_H_ 29 #define _CHAINCON_AWDIAGCUB_H_ 37 #include "chomp/system/config.h" 51 template <
class CoordT,
class WrapT,
class EmptyT>
60 if (dim > static_cast<int> (8 *
sizeof (
long) - 2))
61 throw "Dimension too high for cubical A-W diagonal.";
62 int spaceDim = c. spaceDim ();
65 CoordT *coordBuffer =
new CoordT [6 * spaceDim + 1];
66 CoordT *cLeft = coordBuffer;
67 CoordT *cRight = cLeft + spaceDim;
68 CoordT *leftLeft = cRight + spaceDim;
69 CoordT *leftRight = leftLeft + spaceDim;
70 CoordT *rightLeft = leftRight + spaceDim;
71 CoordT *rightRight = rightLeft + spaceDim;
74 int *indices =
new int [dim + 1];
76 for (
int i = 0; i < spaceDim; ++ i)
78 cLeft [i] = c. left (i);
79 cRight [i] = c. right (i);
80 if (cLeft [i] == cRight [i])
82 indices [indCur ++] = i;
85 throw "Wrong dimension of a cubical cell detected in AW.";
88 const long subsetMax = 1 << dim;
89 for (
long subset = 0; subset < subsetMax; ++ subset)
92 for (
int i = 0; i < spaceDim; ++ i)
94 leftLeft [i] = cLeft [i];
95 leftRight [i] = cRight [i];
96 rightLeft [i] = cLeft [i];
97 rightRight [i] = cRight [i];
99 for (
int i = 0; i < dim; ++ i)
101 int index = indices [i];
102 if (subset & (1 << i))
104 rightLeft [index] = rightRight [index];
108 leftRight [index] = leftLeft [index];
111 t. add (CubeType (spaceDim, leftLeft, leftRight),
112 CubeType (spaceDim, rightLeft, rightRight));
117 delete [] coordBuffer;
128 for (
int i = 0; i < dim; ++ i)
130 for (
int j = 0; j < i; ++ j)
132 if (!(subset & (1 << i)))
134 if (subset & (1 << j))
139 return (nu & 1) ? -1 : 1;
144 template <
class CoordT,
class WrapT,
class EmptyT,
class CoefT>
153 if (dim > static_cast<int> (8 *
sizeof (
long) - 2))
154 throw "Dimension too high for cubical A-W diagonal.";
155 int spaceDim = c. spaceDim ();
158 CoordT *coordBuffer =
new CoordT [6 * spaceDim + 1];
159 CoordT *cLeft = coordBuffer;
160 CoordT *cRight = cLeft + spaceDim;
161 CoordT *leftLeft = cRight + spaceDim;
162 CoordT *leftRight = leftLeft + spaceDim;
163 CoordT *rightLeft = leftRight + spaceDim;
164 CoordT *rightRight = rightLeft + spaceDim;
167 int *indices =
new int [dim + 1];
169 for (
int i = 0; i < spaceDim; ++ i)
171 cLeft [i] = c. left (i);
172 cRight [i] = c. right (i);
173 if (cLeft [i] == cRight [i])
175 indices [indCur ++] = i;
178 throw "Wrong dimension of a cubical cell detected in AW.";
181 const long subsetMax = 1 << dim;
182 for (
long subset = 0; subset < subsetMax; ++ subset)
185 for (
int i = 0; i < spaceDim; ++ i)
187 leftLeft [i] = cLeft [i];
188 leftRight [i] = cRight [i];
189 rightLeft [i] = cLeft [i];
190 rightRight [i] = cRight [i];
192 for (
int i = 0; i < dim; ++ i)
194 int index = indices [i];
195 if (subset & (1 << i))
197 rightLeft [index] = rightRight [index];
201 leftRight [index] = leftLeft [index];
205 if (
AW_rho (subset, dim) == -1)
207 t. add (CubeType (spaceDim, leftLeft, leftRight),
208 CubeType (spaceDim, rightLeft, rightRight), coef);
213 delete [] coordBuffer;
219 #endif // _CHAINCON_AWDIAGCUB_H_ A tensor of chains with coefficients in an arbitrary commutative ring.
Combinatorial tensor of cells.
A combinatorial tensor (for coefficients in Z_2).
int AW_rho(long subset, int dim)
Returns the sign rho of a term in the A-W diagonal (see the paper for details).
void AWdiagonal(const tCubCell< CoordT, WrapT, EmptyT > &c, tCombTensor< tCubCell< CoordT, WrapT, EmptyT >, tCubCell< CoordT, WrapT, EmptyT > > &t)
Computes the Alexander-Whitney diagonal of a cubical cell using the formula from Serre's paper...
An elementary cubical cell with vertex coordinates of integer type.