Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <istream>
00031 #include <ostream>
00032
00033
00034 #include "chomp/system/config.h"
00035 #include "chomp/system/textfile.h"
00036 #include "chomp/system/timeused.h"
00037 #include "chomp/system/arg.h"
00038 #include "chomp/struct/hashsets.h"
00039
00040
00041 #include "chaincon/simplex.h"
00042 #include "chaincon/awdiagsim.h"
00043 #include "comphom.h"
00044 #include "awdiag2d.h"
00045
00046
00047
00048
00049
00050
00051
00052 const char *title = "\
00053 Alexander-Whitney diagonal for simplicial complexes.\n\
00054 Version 0.01 (Apr 4, 2011). Copyright (C) 1997-2011 by Pawel Pilarczyk.\n\
00055 This is free software. No warranty. Consult 'license.txt' for details.";
00056
00057
00058 const char *helpinfo = "\
00059 This program computes the Alexander-Whitney diagonal for 2-dimensional\n\
00060 homology generators, and represents the result in terms of 1-dimensional\n\
00061 homology genrators. In other words, this program decomposes cavities\n\
00062 into products of cycles.\n\
00063 The ring of coefficients is set to Z_2, the integers modulo 2.\n\
00064 Call with:\n\
00065 filename - the name of a file that contains a list of simplices,\n\
00066 Switches and additional arguments:\n\
00067 -ddiag - display the A-W diagonal of each 2D homology generator,\n\
00068 -aN - homology algorithm: 0 = old (very slow), 1 = new without additional\n\
00069 optimization (relatively fast), 2 = new (default), 3 = using the SNF.\n\
00070 --verify - do additional verification of the computed A-W diagonal,\n\
00071 --log filename - save the output to a file (without progress indicators),\n\
00072 --quiet - suppress data output to the screen (whcih can be still logged),\n\
00073 --help - display this brief help information only and exit.\n\
00074 For more information please consult the accompanying documentation\n\
00075 or ask the program's author at http://www.PawelPilarczyk.com/.";
00076
00077
00078
00079
00080
00081
00082
00083
00084 int main (int argc, char *argv [])
00085 {
00086 using namespace chomp::homology;
00087
00088
00089 program_time = "Aborted after";
00090
00091
00092 char *filename = 0;
00093 bool displayDiag = false;
00094 bool verify = false;
00095 int algorithmVersion = 2;
00096
00097
00098 arguments a;
00099 arg (a, NULL, filename);
00100 arg (a, "a", algorithmVersion);
00101 argswitch (a, "ddiag", displayDiag, true);
00102 argswitch (a, "-verify", verify, true);
00103 arghelp (a);
00104
00105 argstreamprepare (a);
00106 int argresult = a. analyze (argc, argv);
00107 argstreamset ();
00108
00109
00110 if (argresult >= 0)
00111 sout << title << '\n';
00112
00113
00114 if (argresult < 0)
00115 {
00116 sout << "Call with '--help' for help.\n";
00117 return 2;
00118 }
00119
00120
00121 if ((argresult > 0) || !filename)
00122 {
00123 sout << helpinfo << '\n';
00124 return 1;
00125 }
00126
00127
00128 try
00129 {
00130
00131 typedef tSimplex<int_t> CellT;
00132 chomp::homology::hashedset<CellT> H;
00133 tCombLinMap<CellT, CellT> pi, incl, phi;
00134
00135
00136 bool displayPi = false;
00137 bool displayIncl = false;
00138 bool displayPhi = false;
00139 computeHomology<CellT> (filename, H, pi, incl, phi,
00140 displayPi, displayIncl, displayPhi,
00141 verify, algorithmVersion);
00142
00143
00144 computeAWdiagonal<CellT> (H, pi, incl, displayDiag, verify);
00145
00146 program_time = "Total time used:";
00147 program_time = 1;
00148 return 0;
00149 }
00150 catch (const char *msg)
00151 {
00152 sout << "ERROR: " << msg << '\n';
00153 return -1;
00154 }
00155 catch (const std::exception &e)
00156 {
00157 sout << "ERROR: " << e. what () << '\n';
00158 return -1;
00159 }
00160 catch (...)
00161 {
00162 sout << "ABORT: An unknown error occurred.\n";
00163 return -1;
00164 }
00165 }
00166