41#include "chomp/system/config.h" 
   42#include "chomp/system/textfile.h" 
   43#include "chomp/system/timeused.h" 
   44#include "chomp/system/arg.h" 
   62This is a program which computes a combinatorial cubical multivalued map.\n\ 
   63Ver. 0.01, March 26, 2013. Copyright (C) 2005-2012 by Pawel Pilarczyk.\n\ 
   64This is free software. No warranty. Consult 'license.txt' for details.";
 
   70This is the front-end program for the computation of a combinatorial\n\ 
   71cubical multivalued map on a cubical set at the final subdivision depth\n\ 
   72for a single parameter box. It is a supplementary program to 'cmgraphs',\n\ 
   73and may be used for the computation of the index pairs and the index map\n\ 
   74for combinatorial Morse sets saved previously.\n\ 
   75Command line arguments (the argument '-b' is mandatory):\n\ 
   76-b x1,x2,...,xN - the integer coordinates of a parameter box to use,\n\ 
   77file.cub - a file with the set of cubes on which to compute the map,\n\ 
   78file.map - a file to which the computed map will be saved,\n\ 
   79-d disjoint.cub - a set of cubes that will be removed from the images,\n\ 
   80-t filename - file name with optimization information (read only),\n\ 
   81--log filename - file name to save all the text output of the program to,\n\ 
   82--quiet - suppress any output written to the terminal,\n\ 
   83--debug - display additional information useful for debugging,\n\ 
   84--help - make the program show this brief help information and exit.\n\ 
   85For more information ask the author at http://www.pawelpilarczyk.com/.";
 
   92int runMapComp (
const char *boxCoordinates, 
const char *mapOptFileName,
 
   93        const char *cubName, 
const char *mapName, 
const char *disjointName)
 
   95        using chomp::homology::sout;
 
   96        using chomp::homology::scon;
 
   97        using chomp::homology::sbug;
 
   98        using chomp::homology::ignorecomments;
 
   99        using chomp::homology::ignoreline;
 
  100        using chomp::homology::fileerror;
 
  103        std::ostringstream info;
 
  105        sout << 
"\n" << info. str () << 
"\n";
 
  113        std::string boxCoordStr (
"(" + std::string (boxCoordinates) + 
")");
 
  114        std::istringstream boxCoordStream (boxCoordStr);
 
  115        boxCoordStream >> paramBox;
 
  127        paramBox. coord (curCoord);
 
  130        sout << 
"Parameter box: " << paramBox << 
".\n";
 
  134        sout << 
"Parameter values:";
 
  137                sout << 
" [" << leftMapParam [i] << 
"," <<
 
  138                        rightMapParam [i] << 
"]";
 
  144        theMap. setParam (leftMapParam, rightMapParam, 
paramCount);
 
  148        if (mapOptFileName && *mapOptFileName)
 
  150                std::ifstream in (mapOptFileName);
 
  153                        sout << 
"Reading map optimization data... ";
 
  154                        mapOptimization. loadData (in);
 
  157                        sout << 
"Optimizing the map... ";
 
  158                        std::vector<std::string> data;
 
  159                        mapOptimization. prepareData (data,
 
  161                        sout << data. size () << 
" hints... ";
 
  162                        for (std::vector<std::string>::const_iterator it =
 
  163                                data. begin (); it != data. end (); ++ it)
 
  165                                theMap. useOptInfo (*it);
 
  175        theCubMap. cache = 
false;
 
  176        theCubMap. cropping = 
false;
 
  180        if (disjointName && *disjointName)
 
  182                sout << 
"Reading '" << disjointName << 
"'... ";
 
  183                std::ifstream disjointFile (disjointName);
 
  185                        fileerror (disjointName, 
"open");
 
  187                sout << 
disjoint. size () << 
" cubes read.\n";
 
  189        bool usingDisjoint = !
disjoint. empty ();
 
  192        std::ifstream cubFile (cubName);
 
  194                fileerror (cubName, 
"open");
 
  197        ignorecomments (cubFile);
 
  198        if (cubFile. peek () == 
'd')
 
  200                ignoreline (cubFile);
 
  201                ignorecomments (cubFile);
 
  205        std::ofstream mapFile (mapName);
 
  207                fileerror (mapName, 
"create");
 
  210        sout << 
"Computing the map... ";
 
  212        int_t removedCubes = 0;
 
  213        int_t emptyImages = 0;
 
  218                bool cubeRead = 
false;
 
  220                if (!cubFile. eof ())
 
  223                        ignorecomments (cubFile);
 
  230                bool imgComputed = 
false;
 
  235                        theCubMap (q, &img, 0, 0, 0, 
false);
 
  243                        mapFile << q << 
" -> {";
 
  244                        int_t imgSize = img. size ();
 
  245                        allImages += imgSize;
 
  247                        for (int_t i = 0; i < imgSize; ++ i)
 
  273                        if (cur && !(cur % 1000))
 
  275                                scon << std::setw (8) << (cur / 1000) <<
 
  276                                        "k\b\b\b\b\b\b\b\b\b";
 
  287        sout << 
"Images of " << cur << 
" cubes computed.\n";
 
  288        sout << 
"There are " << allImages << 
" cubes in total " 
  289                "in all the images.\n";
 
  292                sout << removedCubes << 
" cubes were removed " 
  293                        "from the images.\n";
 
  297                sout << 
"WARNING: There are " << emptyImages <<
 
  302                sout << 
"All the images are nonempty.\n";
 
  311                sout << 
"Average image size: " << (allImages / cur) << 
".\n";
 
  318        sbug << 
"(Releasing the pointset data.)\n";
 
  319        parCube::PointBase::reset ();
 
  320        spcCube::PointBase::reset ();
 
  321        chomp::homology::Cube::PointBase::reset ();
 
  333int main (
int argc, 
char *argv [])
 
  335        using namespace chomp::homology;
 
  338        char *boxCoordinates = 0;
 
  341        char *disjointName = 0;
 
  342        char *mapOptFileName = 0;
 
  343        const int maxComments = 16;
 
  345        char *comments [maxComments];
 
  349        arg (a, NULL, cubName);
 
  350        arg (a, NULL, mapName);
 
  351        arg (a, 
"b", boxCoordinates);
 
  352        arg (a, 
"t", mapOptFileName);
 
  353        arg (a, 
"d", disjointName);
 
  354        arg (a, 
"-comment", comments, nComments, maxComments);
 
  357        argstreamprepare (a);
 
  358        int argresult = a. analyze (argc, argv);
 
  362        if (!boxCoordinates || !cubName || !mapName)
 
  367                sout << 
title << 
'\n';
 
  372                sout << 
"Call with '--help' for help.\n";
 
  387                program_time = 
"Aborted after:";
 
  392                        cubName, mapName, disjointName);
 
  395                program_time = 
"Total time used:";
 
  400        catch (
const char *msg)
 
  402                sout << 
"ERROR: " << msg << 
'\n';
 
  405        catch (
const std::exception &e)
 
  407                sout << 
"ERROR: " << e. what () << 
'\n';
 
  412                sout << 
"ABORT: An unknown error occurred.\n";
 
A generic map computation routine that computes a rigorous cubical multivalued map based on a functio...
 
static int maxImgDiam
The maximal image diameter encountered so far.
 
static int maxImgVol
The maximal image volume encountered so far.
 
This class defines a map derived from a sample difference equation.
 
A class whose objects are responsible for adjusting the integration parameters such as step size and ...
 
int main(int argc, char *argv[])
The main procedure of the program.
 
int runMapComp(const char *boxCoordinates, const char *mapOptFileName, const char *cubName, const char *mapName, const char *disjointName)
 
const char * helpinfo
The help information about the program which is displayed if the program is launched without command-...
 
const char * title
The title of the program which is displayed every time the program is launcued.
 
Choice of configuration settings.
 
Writing configuration settings to an output stream.
 
void showConfigInfo(std::ostream &f, const char *prefix, const parCoord *maxIter)
Writes the configuration information to the given output stream.
 
bool disjoint(const pointset &p, const pointset &q)
 
Map optimization data saving, retrieving, and sending.
 
const SpaceOffsetType spaceOffset
An imitation of an array which returns the offset of the rectangular area in the phase space which co...
 
const int paramDim
The dimension of the parameter space to iterate.
 
const int spaceDim
The dimension of the phase space.
 
const int paramCount
The number of all the parameters, both varying and fixed.
 
const SpaceWidthType spaceWidth
An imitation of an array which returns the width of the rectangular area in the phase space which con...
 
const int finalDepth
The final depth of subdivisions in the phase space.
 
Customizable data types for the Conley-Morse graphs computation program.
 
Data types for the dynamical systems data structures.
 
chomp::homology::tCubeFix< paramDim, parCoord > parCube
The type of a cube in the set of parameters.
 
short int parCoord
The type of coordinates of cubes in the set of parameters.
 
chomp::homology::hashedset< spcCube > spcCubes
The type of a set of cubes in the phase space.
 
chomp::homology::tCubeBase< spcCoord > spcCube
The type of a cube in the phase space.
 
Utilites and helper functions.
 
void computeParam(const intType *curCoord, double *leftMapParam, double *rightMapParam)
Computes the real coordinates of the parameter cube which corresponds to the given box.