29 #define CUBES_NOT_SIMPLICES 30 #ifdef CUBES_NOT_SIMPLICES 31 #define SPACE_WRAPPING 43 #include "chomp/system/config.h" 44 #include "chomp/system/textfile.h" 45 #include "chomp/system/timeused.h" 46 #include "chomp/system/arg.h" 47 #include "chomp/struct/hashsets.h" 74 Experimentation with the formula for the A-W diagonal.\n\ 75 Version 0.00 (Sep 24, 2015). Copyright (C) 1997-2016 by Pawel Pilarczyk.\n\ 76 This is free software. No warranty. Consult 'license.txt' for details.";
80 This program does some computations to experiment with the A-W diagonal.\n\ 81 The ring of coefficients is Z or Z_p (the integers modulo prime number p).\n\ 83 filename - the name of a file that contains a list of cubical cells,\n\ 84 Switches and additional arguments:\n\ 85 filename2 - the name of an additional file for relative (co)homology;\n\ 86 -pN - selection of the coefficients: p=0 for Z, p=1 unsupported in this\n\ 87 \tprogram, p > 1 for Z_p (default: p=2); please, use p <= 181,\n\ 88 -r - compute reduced homology (with the empty set as a cell of dim -1),\n\ 89 -b - don't add boundary cells (use -bx and -ba for X and A selectively),\n\ 90 -w N1,..,Nk - set space wrapping, a.k.a. periodic boundary conditions;\n\ 91 \trepeat the n-tuple for each dimension n; use 0 for no wrapping,\n\ 92 -dpi, -dincl, -dphi - display the computed maps: pi, incl, phi,\n\ 93 -drepr - display homology representants (meaningful for -aN with N < 3),\n\ 94 -aN - homology algorithm: 0 = old (very slow), 1 = new without additional\n\ 95 optimization (relatively fast), 2 = new (default), 3,4 = using the SNF,\n\ 96 --verify - do additional verification of the computed maps,\n\ 97 --log filename - save the output to a file (without progress indicators),\n\ 98 --quiet - suppress data output to the screen (whcih can be still logged),\n\ 99 --help - display this brief help information only and exit.\n\ 100 For more information please consult the accompanying documentation\n\ 101 or ask the program's author at http://www.PawelPilarczyk.com/.";
109 template <
class SetT,
class CellT,
class CoefT,
class CellNames>
111 const chomp::homology::hashedset<CellT> &H,
115 CellNames &cellNames)
117 using chomp::homology::sout;
121 sout <<
"Checking the experimental formula on " <<
122 K. size () <<
" cells...\n";
125 int_t Ksize (K. size ());
126 for (int_t n = 0; n < Ksize; ++ n)
129 const CellT &c (K [n]);
132 ChainT hom_c (pi (c));
143 ChainT bd_phi_c (
boundary (phi (c), K));
144 ChainT neg_bd_phi_c (bd_phi_c);
145 neg_bd_phi_c. negate ();
148 one_etc. add (c, one);
149 one_etc += neg_bd_phi_c;
152 TensorT result1 (pi (aw1));
157 TensorT result2 (pi (aw2));
160 bool good = (result1 == result2);
161 sout <<
"Cell " << c <<
", size " << hom_c. size () <<
162 (good ?
", formula OK" :
", WRONG RESULT") <<
".\n";
166 cellNames, cellNames) <<
".\n";
168 cellNames, cellNames) <<
".\n";
181 int main (
int argc,
char *argv [])
183 #ifdef CUBES_NOT_SIMPLICES 192 using namespace chomp::homology;
195 program_time =
"Aborted after";
201 bool reduced =
false;
202 bool addBoundariesX =
true;
203 bool addBoundariesA =
true;
204 bool addNoBoundaries =
false;
205 bool displayPi =
false;
206 bool displayIncl =
false;
207 bool displayPhi =
false;
208 bool displayRepr =
false;
210 int algorithmVersion = 2;
211 #ifdef SPACE_WRAPPING 212 const int maxWrapping = 100;
213 char *wrapping [maxWrapping];
219 arg (a, NULL, Xname);
220 arg (a, NULL, Aname);
222 arg (a,
"a", algorithmVersion);
223 #ifdef SPACE_WRAPPING 224 arg (a,
"w", wrapping, nWrapping, maxWrapping);
226 argswitch (a,
"r", reduced,
true);
227 argswitch (a,
"bx", addBoundariesX,
false);
228 argswitch (a,
"ba", addBoundariesA,
false);
229 argswitch (a,
"b", addNoBoundaries,
true);
230 argswitch (a,
"dpi", displayPi,
true);
231 argswitch (a,
"dincl", displayIncl,
true);
232 argswitch (a,
"dphi", displayPhi,
true);
233 argswitch (a,
"drepr", displayRepr,
true);
234 argswitch (a,
"-verify", verify,
true);
237 argstreamprepare (a);
238 int argresult = a. analyze (argc, argv);
243 sout <<
title <<
'\n';
248 sout <<
"Call with '--help' for help.\n";
253 if ((argresult > 0) || !Xname || (p < 0))
268 CellT::EmptyType::setExistence (
true);
270 #ifdef SPACE_WRAPPING 272 for (
int i = 0; i < nWrapping; ++ i)
274 setWrapping<CellT::WrapType>
275 (std::string (wrapping [i]));
283 addBoundariesX && !addNoBoundaries,
284 addBoundariesA && !addNoBoundaries);
285 bool relativeComplex = !L. empty ();
288 chomp::homology::hashedset<CellT> H;
294 sout <<
"Carrying out computations in the ring " <<
295 CoefT::ringsymbol () <<
".\n";
297 H, pi, incl, phi, cellNames,
298 displayPi, displayIncl, displayPhi,
299 displayRepr, verify, algorithmVersion);
304 program_time =
"Total time used:";
308 catch (
const char *msg)
310 sout <<
"ERROR: " << msg <<
'\n';
313 catch (
const std::exception &e)
315 sout <<
"ERROR: " << e. what () <<
'\n';
320 sout <<
"ABORT: An unknown error occurred.\n";
Elements of the ring Z_p.
Boundary computation at the level of chains of cells.
A cubical version of the Alexander-Whitney diagonal.
A linear map for coefficients in an arbitrary commutative ring.
A simplex with vertices of arbitrary type.
const char * title
The title of the program and licensing information.
const char * helpinfo
Brief help information on the program's usage.
tCombChain< CellT > boundary(const tCombChain< CellT > &c, const CellRestrT &restr)
Returns the boundary of a given chain (takes boundary cells restricted by the given object...
A chain with coefficients in an arbitrary ring.
A class whose instances can be used to generate names of cells with subsequent numbers, in each dimension separately.
A combinatorial linear map (for coefficients in Z_2).
Tools for coordinate wrapping, a.k.a.
void readFilteredComplexes(const char *Xname, const char *Aname, tFilteredComplex< CellT > &K, tFilteredComplex< CellT > &L, bool addBoundariesX, bool addBoundariesA)
Reads a filtered cell complex or a pair of filtered cell complexes from text files.
int main(int argc, char *argv [])
The main procedure of the program.
A class for naming cells for nice text data output.
Hashing keys for std::string.
NamesT::NameType cells2names(const CellT &in, NamesT &names)
Returns the name of a cell according to the given naming object.
A chain with coefficients in an arbitrary commutative ring.
A simplex class with arbitrary vertices.
void AWdiagonal(const tCombChain< CellT > &ch, tCombTensor< CellT, CellT > &t)
Computes the Alexander-Whitney diagonal of a chain, using the procedure defined for individual cells...
The decision on whether the empty cell should be used as a valid cell of dimension -1...
Alexander-Whitney diagonal of a chain.
An empty cell existence decision class with settable global flag.
An element of the ring Z_p, where p is globally set.
void computeAlgTopModel(const tFilteredComplex< CellT > &K, bool relativeComplex, chomp::homology::hashedset< CellT > &H, LinMap &pi, LinMap &incl, LinMap &phi, CellNames &cellNames, bool displayPi, bool displayIncl, bool displayPhi, bool displayRepr, bool verify, int algorithmVersion)
Computes an AT model and the homology of a cellular complex.
A simplicial version of the Alexander-Whitney diagonal.
An elementary cubical cell with vertex coordinates of integer type.
void experiment(const SetT &K, const chomp::homology::hashedset< CellT > &H, const tLinMap< CellT, CellT, CoefT > &pi, const tLinMap< CellT, CellT, CoefT > &incl, const tLinMap< CellT, CellT, CoefT > &phi, CellNames &cellNames)
Runs the experimental calculations.
A generic procedure for the computation of chain contraction of a filtered cell complex stored in a f...