34#ifndef _CMGRAPHS_INDCACHE_H_
35#define _CMGRAPHS_INDCACHE_H_
44#include "chomp/system/textfile.h"
45#include "chomp/cubes/pointset.h"
75 int read (
const std::string &fileName,
82 int write (
const std::string &fileName,
109 attractor (nSets, false), wrongIndex (nSets, false),
110 skipped (nSets, false)
123 using chomp::homology::ignoreline;
124 using chomp::homology::ignorecomments;
125 using chomp::homology::sbug;
128 std::ifstream inFile (fileName. c_str ());
133 if (inFile. peek () ==
'B')
142 std::getline (inFile, str,
'\0');
147 std::istringstream in (str);
154 if (nSets != morseDec. count ())
156 sbug <<
"Wrong number of Morse sets: " << nSets <<
157 " instead of " << morseDec. count () <<
".\n";
174 std::vector<bool> matched (nSets,
false);
182 int character = in. get ();
184 if (countSets && (character ==
'M'))
195 sbug <<
"Only " << countItems <<
" elements "
196 "read, at least 7 expected.\n";
203 for (
int setNum = 0; setNum < nSets; ++ setNum)
205 if (matched [setNum])
207 if (morseDec [setNum]. size () != nCubes)
209 if (!morseDec [setNum]. check (reprCube))
211 matched [setNum] =
true;
215 skipped [setNum] = (skip == 1);
216 morseDec. setindex (setNum, ind);
224 sbug <<
"Morse set no. " << number <<
225 " could not be matched with any "
226 "Morse set in the Morse dec.\n";
231 if (character == EOF)
233 if (countSets == nSets)
235 sbug <<
"Cached information for " <<
236 countSets <<
" Morse sets found, " <<
237 nSets <<
" expected.\n";
255 if (number != countSets)
257 sbug <<
"Wrong Morse set number: " <<
258 number <<
" (" << countSets <<
270 if ((empty != 0) && (empty != 1))
272 sbug <<
"The number 0 or 1 expected "
273 "for 'emptyInv', " << empty <<
284 if ((attr != 0) && (attr != 1))
286 sbug <<
"The number 0 or 1 expected "
287 "for 'attractor', " << attr <<
298 if ((wrong != 0) && (wrong != 1))
300 sbug <<
"The number 0 or 1 expected "
301 "for 'wrong index', " << wrong <<
312 if ((skip != 0) && (skip != 1))
314 sbug <<
"The number 0 or 1 expected "
315 "for 'skipped index', " << skip <<
328 sbug <<
"Negative number of cubes found.\n";
337 if (in. peek () !=
'(')
339 sbug <<
"An opening parenthesis of a cube "
371 std::ostringstream out;
373 out <<
"; Cached information with Conley indices "
374 "for a Morse decomposition.\n";
377 int nSets = morseDec. count ();
378 out <<
"; The number of Morse sets:\n";
379 out << nSets <<
"\n";
383 out <<
"; M - the consecutive number of a Morse set\n";
384 out <<
"; E - 1 if the invariant set is empty, 0 if unknown\n";
385 out <<
"; A - 1 if this is an attractor, 0 if not or unknown\n";
386 out <<
"; W - 1 if the index is wrong (no isolation), 0 if good\n";
387 out <<
"; S - 1 if the index computation was skipped, 0 otherwise\n";
388 out <<
"; N - the number of cubes in the Morse set\n";
389 out <<
"; Q - a representative cube\n";
390 out <<
"; I - the Conley index encoded in numbers\n";
393 for (
int n = 0; n < nSets; ++ n)
396 out <<
"M " << n <<
"\n";
397 out <<
"E " << (
emptyInv [n] ? 1 : 0) <<
"\n";
398 out <<
"A " << (
attractor [n] ? 1 : 0) <<
"\n";
399 out <<
"W " << (
wrongIndex [n] ? 1 : 0) <<
"\n";
400 out <<
"S " << (
skipped [n] ? 1 : 0) <<
"\n";
401 out <<
"N " << morseDec [n]. size () <<
"\n";
402 out <<
"Q " << morseDec [n] [0] <<
"\n";
403 out <<
"I " << morseDec. index (n) <<
"\n";
407 std::ofstream outFile (fileName. c_str ());
410#ifdef CONFIG_NOINDEXCACHECOMPRESSION
411 outFile << out. str ();
414 outCompr << out. str ();
Writing and reading binary data (int, double) with bzip2 compression.
Utility procedures for writing and reading entire data structures with bzip2 compression,...
A simple wrapper for the bzip2 data compression to an output stream.
A simple wrapper for the bzip2 data decompression from an input stream.
The class that computes and returns properties of the Conley index.
Cached information on the Conley-Morse decompositions which contains information on computed Conley i...
std::vector< bool > emptyInv
The information on whether the invariant part of the given set has been proven to be empty.
std::vector< bool > skipped
The information on whether the computation of the given index was skipped due to the limit on the siz...
int write(const std::string &fileName, const theMorseDecompositionType &morseDec) const
Writes the cached information for the given Morse decomposition to a file.
~IndexCache()
The destructor of a cached information structure.
std::vector< bool > attractor
The information on whether the given Morse set is an attractor in the sense that its image is contain...
IndexCache(int nSets)
The constructor of an empty cached information structure for the given number of Morse sets.
int read(const std::string &fileName, theMorseDecompositionType &morseDec)
Reads the cached information from a file, matches it with the given Morse decomposition and sets the ...
std::vector< bool > wrongIndex
The information on whether the given index could not be computed because of a problem with isolation.
The Morse decoposition class.
Choice of configuration settings.
Conley index computation routines.
Customizable data types for the Conley-Morse graphs computation program.
Data types for the dynamical systems data structures.
chomp::homology::tCubeBase< spcCoord > spcCube
The type of a cube in the phase space.