35#ifndef _CMGRAPHS_INVPART_H_
36#define _CMGRAPHS_INVPART_H_
40#include "chomp/system/textfile.h"
41#include "chomp/cubes/cube.h"
42#include "chomp/struct/digraph.h"
43#include "chomp/struct/multitab.h"
59template <
class typeCubes>
60inline void invariantPart (typeCubes &X,
const chomp::homology::diGraph<> &g,
61 chomp::homology::diGraph<> *gInv = 0)
69 chomp::homology::multitable<int_t> compVertices (8192);
70 chomp::homology::multitable<int_t> compEnds (8192);
71 chomp::homology::diGraph<> gT;
72 int_t count = chomp::homology::SCC (g, compVertices, compEnds,
73 static_cast<chomp::homology::diGraph<> *
> (0), &gT);
76 int_t nVertices = X. size ();
77 char *forward =
new char [nVertices];
78 for (int_t i = 0; i < nVertices; ++ i)
80 for (int_t cur = 0; cur < count; ++ cur)
82 g. DFScolor (forward,
'\1',
83 compVertices [cur ? compEnds [cur - 1] :
84 static_cast<int_t
> (0)]);
88 char *backward =
new char [nVertices];
89 for (int_t i = 0; i < nVertices; ++ i)
91 for (int_t cur = 0; cur < count; ++ cur)
93 gT. DFScolor (backward,
'\1',
94 compVertices [cur ? compEnds [cur - 1] :
95 static_cast<int_t
> (0)]);
102 for (int_t i = 0; i < nVertices; ++ i)
103 if (forward [i] && backward [i])
109 for (int_t i = 0; i < nVertices; ++ i)
111 forward [i] &= backward [i];
117 g. subgraph (*gInv, forward);
132template <
class typeCubes,
class theCubMapType>
134 bool cropping =
true)
136 using chomp::homology::sbug;
140 chomp::homology::diGraph<> g;
147 int_t avgImgSize = g. countEdges () /
148 (X. size () ? X. size () :
static_cast<int_t
> (1));
149 sbug <<
"[avg " << avgImgSize <<
"] ";
152 catch (
const char *msg)
155 sbug <<
"Failed: " << msg <<
"\n";
162 sbug << X. size () <<
" left.\n";
172 const double *offset,
const double *width,
const theMapType &theMap,
175 using chomp::homology::sbug;
176 using chomp::homology::diGraph;
181 int subdivisions = 0;
186 const spcCubes &source = Z. empty () ? X : Z;
187 sbug <<
"* Subdiv " << source. size () <<
" -> ";
189 sbug << Y. size () <<
". ";
196 1 << (subdivDepth + subdivisions),
197 subdivDepth + subdivisions, theMap);
198 subdivCubMap. cache =
false;
199 if (subdivisions > 1)
201 subdivCubMap. setAllowedImgSize
205 (subdivisions > 1) ? subdivCubMap :
206 (subdivisions ? theCubMap1 : theCubMap0);
216 sbug <<
"* Empty after " << subdivisions <<
217 ((subdivisions == 1) ?
" subdivision.\n" :
229 sbug <<
"* Nonempty after " << subdivisions <<
230 ((subdivisions == 1) ?
" subdivision (" :
231 " subdivisions (") << Z. size () <<
" cubes left).\n";
240template <
class CubSetType,
class CubSetArrayType,
class CubMapType>
241inline int_t
findSCCs (
const CubSetType &X,
const CubMapType &theCubMap,
242 CubSetArrayType &components)
244 using chomp::homology::sbug;
248 chomp::homology::diGraph<> g;
255 int_t avgImgSize = g. countEdges () /
256 (X. size () ? X. size () :
static_cast<int_t
> (1));
257 sbug <<
"[avg " << avgImgSize <<
"] ";
260 catch (
const char *msg)
263 sbug <<
"Failed: " << msg <<
"\n";
269 chomp::homology::multitable<int_t> compVertices (8192);
270 chomp::homology::multitable<int_t> compEnds (8192);
271 chomp::homology::diGraph<> *sccAddr = 0;
272 chomp::homology::diGraph<> *transpAddr = 0;
273 int_t nSets = chomp::homology::SCC (g, compVertices, compEnds,
274 sccAddr, transpAddr);
275 sbug << nSets <<
".\n";
279 for (int_t n = 0; n < nSets; ++ n)
281 int_t end = compEnds [n];
284 components [n]. add (X [compVertices [cur]]);
A generic map computation routine that computes a rigorous cubical multivalued map based on a functio...
This class defines a map derived from a sample difference equation.
Choice of configuration settings.
void invariantPart(typeCubes &X, const chomp::homology::diGraph<> &g, chomp::homology::diGraph<> *gInv=0)
Computes X := Inv (X) using the algorithm by Bill Kalies and Hyunju Ban.
bool checkEmptyInv(const spcCubes &X, int subdivDepth, const double *offset, const double *width, const theMapType &theMap, const theCubMapType &theCubMap0, const theCubMapType &theCubMap1)
Verifies whether the invariant part of the given set is empty by applying a limited number of refinem...
int_t findSCCs(const CubSetType &X, const CubMapType &theCubMap, CubSetArrayType &components)
Computes the strongly connected path components of the graph representation of the multivalued map on...
Computation of the graph representation of a combinatorial map.
void computeMapGraph(const typeCubes &X, typeGraph &g, const typeCubMap &theCubMap, bool cropping=true)
Computes the cubical map on 'X' and fills out the graph 'g'.
const int refineDepth
The number of refinements that should be done if a Morse set with the trivial index is encountered or...
const int maxRefineSize0
The maximal allowed size of a set of cubes in the phase space which can be refined at the initial sub...
const int maxImageVolume
The maximal allowed volume of the cubical image of a single box.
const int maxImageDiameter
The maximal allowed diameter of the cubical image of a signle box.
const int maxRefineSize1
The maximal allowed size of a set of cubes in the phase space which can be refined at the subsequent ...
Customizable data types for the Conley-Morse graphs computation program.
Data types for the dynamical systems data structures.
chomp::homology::hashedset< spcCube > spcCubes
The type of a set of cubes in the phase space.
void subdivideCubes(const typeCubes &X, typeCubes &result)
Subdivides one set of cubes to another set of cubes with respect to twice finer grid.