34#ifndef _CMGRAPHS_MORSEDEC_H_ 
   35#define _CMGRAPHS_MORSEDEC_H_ 
   45#include "chomp/system/textfile.h" 
   46#include "chomp/homology/homology.h" 
   47#include "chomp/struct/digraph.h" 
   62template <
class mapcomp, 
class cubetype,
 
   63        class cubsettype = chomp::homology::hashedset<cubetype> >
 
   67        typedef chomp::homology::mvmap<cubetype,cubetype> 
cubmaptype;
 
  114        int add (
int n, 
const cubetype &q);
 
  141        int addconn (
int n, 
int m, 
const cubetype &q);
 
  149        const cubsettype &
connection (
int n, 
int m) 
const;
 
  155        int distance (
int n, 
int m, 
int k) 
const;
 
  169        int makegraph (chomp::homology::diGraph<> &g) 
const;
 
  213        int join (
int n, 
int m);
 
  225        int passthru (chomp::homology::hashedset<int> &setsToRemove);
 
  231        int jointrivial (int_t maxsetsize, int_t maxconnsize,
 
  249        chomp::homology::multitable<cubsettype *> 
sets;
 
  252        chomp::homology::multitable<IndexType *> 
indices;
 
  260        chomp::homology::multitable<chomp::homology::multitable<cubsettype *> >
 
  267        mutable chomp::homology::multitable<chomp::homology::multitable<int> >
 
  274        mutable chomp::homology::multitable<chomp::homology::multitable<int> >
 
  287        void deleteall (
int firstnumber, 
int lastnumber);
 
  297        bool adjacent (
int n, 
int m, 
int margin = 0) 
const;
 
  306        static int cubsetdistance (
const cubsettype &X, 
const cubsettype &Y,
 
  313template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  315        (
const mapcomp &_M): M (_M), nsets (0),
 
  316        sets (256), indices (256), nontrivial (256),
 
  317        connDefined (false), distDefined (false), distconnDefined (false)
 
  322template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  331        for (
int i = 0; i < nsets; ++ i)
 
  333                for (
int j = 0; j < nsets; ++ j)
 
  346template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  348        (
int firstnumber, 
int lastnumber)
 
  350        int difference = lastnumber - firstnumber;
 
  354        for (
int i = firstnumber; i < lastnumber; ++ i)
 
  371        for (
int i = lastnumber; i < nsets; ++ i)
 
  374                sets [i - difference] = sets [i];
 
  378                indices [i - difference] = indices [i];
 
  382                nontrivial [i - difference] = nontrivial [i];
 
  388                for (
int i = 0; i < nsets; ++ i)
 
  391                        for (
int j = firstnumber; j < lastnumber; ++ j)
 
  401                        for (
int j = lastnumber; j < nsets; ++ j)
 
  403                                conn [i] [j - difference] = conn [i] [j];
 
  412                for (
int i = 0; i < nsets; ++ i)
 
  414                        for (
int j = lastnumber; j < nsets; ++ j)
 
  415                                dist [i] [j - difference] = dist [i] [j];
 
  420                for (
int i = 0; i < nsets; ++ i)
 
  422                        for (
int j = lastnumber; j < nsets; ++ j)
 
  424                                distconn [i] [j - difference] =
 
  432                for (
int j = 0; j < nsets - difference; ++ j)
 
  435                        for (
int i = firstnumber; i < lastnumber; ++ i)
 
  445                        for (
int i = lastnumber; i < nsets; ++ i)
 
  447                                conn [i - difference] [j] = conn [i] [j];
 
  456                for (
int j = 0; j < nsets - difference; ++ j)
 
  458                        for (
int i = lastnumber; i < nsets; ++ i)
 
  459                                dist [i - difference] [j] = dist [i] [j];
 
  464                for (
int j = 0; j < nsets - difference; ++ j)
 
  466                        for (
int i = lastnumber; i < nsets; ++ i)
 
  468                                distconn [i - difference] [j] =
 
  479template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  483        deleteall (0, nsets);
 
  487template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  494        for (
int i = 0; i < nsets; ++ i)
 
  498                        sets [i] = 
new cubsettype (*(m. sets [i]));
 
  504                        indices [i] = 
new IndexType (*(m. indices [i]));
 
  507                nontrivial [i] = m. nontrivial [i];
 
  511        connDefined = m. connDefined;
 
  514                for (
int i = 0; i < nsets; ++ i)
 
  516                        for (
int j = 0; j < nsets; ++ j)
 
  520                                        conn [i] [j] = 
new cubsettype
 
  521                                                (*(m. conn [i] [j]));
 
  528        distDefined = m. distDefined;
 
  531                for (
int i = 0; i < nsets; ++ i)
 
  533                        for (
int j = 0; j < nsets; ++ j)
 
  535                                dist [i] [j] = m. dist [i] [j];
 
  539        distconnDefined = m. distconnDefined;
 
  540        if (m. distconnDefined)
 
  542                for (
int i = 0; i < nsets; ++ i)
 
  544                        for (
int j = 0; j < nsets; ++ j)
 
  546                                distconn [i] [j] = m. distconn [i] [j];
 
  553template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  561template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  571        deleteall (0, nsets);
 
  579template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  583        std::swap (
this -> nsets, m. nsets);
 
  584        this -> sets. swap (m. sets);
 
  585        this -> indices. swap (m. indices);
 
  586        this -> nontrivial. swap (m. nontrivial);
 
  587        this -> conn. swap (m. conn);
 
  588        std::swap (
this -> connDefined, m. connDefined);
 
  589        this -> dist. swap (m. dist);
 
  590        std::swap (
this -> distDefined, m. distDefined);
 
  591        this -> distconn. swap (m. distconn);
 
  592        std::swap (
this -> distconnDefined, m. distconnDefined);
 
  596template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  600        sets [nsets] = 
new cubsettype;
 
  604        nontrivial [nsets] = -1;
 
  609                for (
int i = 0; i < nsets; ++ i)
 
  611                        conn [nsets] [i] = 0;
 
  612                        conn [i] [nsets] = 0;
 
  614                conn [nsets] [nsets] = 0;
 
  620                for (
int i = 0; i < nsets; ++ i)
 
  622                        dist [nsets] [i] = -1;
 
  623                        dist [i] [nsets] = -1;
 
  625                dist [nsets] [nsets] = 0;
 
  629                for (
int i = 0; i < nsets; ++ i)
 
  631                        distconn [nsets] [i] = -1;
 
  632                        distconn [i] [nsets] = -1;
 
  634                distconn [nsets] [nsets] = 0;
 
  642template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  644        (
int n, 
int m, 
int margin)
 const 
  647        typedef chomp::homology::tNeighbors<typename cubetype::CoordType>
 
  651        if ((n < 0) || (n >= nsets) || (m < 0) || (m >= nsets))
 
  659        bool n_m = (sets [n] -> size () < sets [m] -> size ());
 
  660        const cubsettype &smaller = n_m ? *(sets [n]) : *(sets [m]);
 
  661        const cubsettype &larger = n_m ? *(sets [m]) : *(sets [n]);
 
  664        if (larger. empty ())
 
  668        int dim = larger [0]. dim ();
 
  669        typename cubetype::CoordType *c =
 
  670                new typename cubetype::CoordType [dim];
 
  677        for (
int i = 0; i < margin; ++ i)
 
  679                int stop = enhanced. size ();
 
  680                for (
int n = start; n < stop; ++ n)
 
  682                        enhanced [n]. coord (c);
 
  683                        neighborstype nb (c, dim);
 
  684                        const typename cubetype::CoordType *nc;
 
  685                        while ((nc = nb. get ()) != 0)
 
  686                                enhanced. add (cubetype (nc, dim));
 
  693        const cubsettype &smallcheck = margin ? enhanced : smaller;
 
  697        for (int_t i = 0; i < smallcheck. size (); ++ i)
 
  699                smallcheck [i]. coord (c);
 
  700                neighborstype n (c, dim);
 
  701                const typename cubetype::CoordType *nc;
 
  702                while ((nc = n. get ()) != 0)
 
  704                        if (larger. check (cubetype (nc, dim)))
 
  715template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  717        (
const cubsettype &X, 
const cubsettype &Y, 
bool minimum)
 
  720        if (X. empty () || Y. empty ())
 
  724        int dim = X [0]. dim ();
 
  725        typedef typename cubetype::CoordType coords;
 
  726        coords *c = 
new coords [dim + dim];
 
  732        for (int_t i = 0; i < X. size (); ++ i)
 
  736                for (int_t j = 0; j < Y. size (); ++ j)
 
  740                        for (
int k = 0; k < dim; ++ k)
 
  741                                dist0 += (c [k] - d [k]) * (c [k] - d [k]);
 
  742                        dist0 = 
static_cast<int> 
  743                                (std::sqrt (
static_cast<double> (dist0)));
 
  744                        if ((local_dist < 0) || (local_dist > dist0))
 
  750                        if ((best_dist < 0) || (best_dist > local_dist))
 
  751                                best_dist = local_dist;
 
  755                        if ((best_dist < 0) || (best_dist < local_dist))
 
  756                                best_dist = local_dist;
 
  766template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  775                deleteall (n, nsets);
 
  779template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  781        (
int n, 
const cubetype &q)
 
  793template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  797        if ((n < 0) || (m < 0))
 
  800        while ((n > nsets) || (m > nsets))
 
  803                conn [n] [m] = 
new cubsettype;
 
  807template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  809        (
int n, 
int m, 
const cubetype &q)
 
  811        if ((n < 0) || (m < 0))
 
  814        while ((n > nsets) || (m > nsets))
 
  817                conn [n] [m] = 
new cubsettype;
 
  818        conn [n] [m] -> add (q);
 
  822template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  828template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  832        if ((n < 0) || (n >= nsets) || !sets [n])
 
  833                throw "Trying to access an undefined Morse set.";
 
  837template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  841        if ((n < 0) || (n >= nsets) || !sets [n])
 
  842                throw "Trying to access an undefined Morse set.";
 
  846template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  871        if ((n < 0) && !distDefined)
 
  883                for (
int i = 0; i < nsets; ++ i)
 
  885                        for (
int j = 0; j < nsets; ++ j)
 
  897                for (
int i = 0; i < nsets; ++ i)
 
  906        if (dist [n] [m] >= 0)
 
  910        int d = cubsetdistance (*(sets [n]), *(sets [m]), 
true);
 
  920template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  924        return ((n >= 0) && (n < nsets) && (m >= 0) && (m < nsets) &&
 
  925                connDefined && conn [n] [m]);
 
  928template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  932        if ((n < 0) || (n >= nsets) || (m < 0) || (m >= nsets) ||
 
  933                !connDefined || !conn [n] [m])
 
  934                throw "Trying to access an undefined Morse set connection.";
 
  935        return *(conn [n] [m]);
 
  938template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  940        (
int n, 
int m, 
int k)
 const 
  942        if ((n < 0) || (n >= nsets) || (m < 0) || (m >= nsets) ||
 
  943                (k < 0) || (k >= nsets))
 
  945        if ((n == m) || !connDefined || (!conn [n] [m] && !conn [m] [n]))
 
  947        return cubsetdistance (conn [n] [m] ? *(conn [n] [m]) :
 
  948                *(conn [m] [n]), *(sets [k]), 
false);
 
  951template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
  956        if ((n >= nsets) || (m >= nsets))
 
  960        if ((n < 0) && (m < 0))
 
  962                distconnDefined = 
false;
 
  968        if (((n < 0) || (m < 0)) && !distconnDefined)
 
  974        if (!distconnDefined)
 
  976                for (
int i = 0; i < nsets; ++ i)
 
  978                        for (
int j = 0; j < nsets; ++ j)
 
  980                                distconn [i] [j] = -1;
 
  983                distconnDefined = 
true;
 
  987        if ((n < 0) || (m < 0))
 
  989                int num = (n >= 0) ? n : m;
 
  990                for (
int i = 0; i < nsets; ++ i)
 
  992                        distconn [i] [num] = -1;
 
  993                        distconn [num] [i] = -1;
 
  999        if (distconn [n] [m] >= 0)
 
 1000                return distconn [n] [m];
 
 1003        int d = distance (n, m, n);
 
 1004        distconn [n] [m] = d;
 
 1010template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1012        (chomp::homology::diGraph<> &g)
 const 
 1014        for (
int i = 0; i < nsets; ++ i)
 
 1017                for (
int j = 0; j < nsets; ++ j)
 
 1019                        if (connDefined && conn [i] [j])
 
 1028template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1033        if ((n < 0) || (n >= nsets) || !sets [n])
 
 1034                throw "Trying to compute the Conley index of an undefined " 
 1039        const cubsettype &cset = *(sets [n]);
 
 1040        int_t csetsize = cset. size ();
 
 1041        for (int_t i = 0; i < csetsize; ++ i)
 
 1049        indices [n] -> setIndexPair (&P);
 
 1051        indices [n] -> compute ();
 
 1052        indices [n] -> setIndexPair (0);
 
 1055        if (indices [n] -> trivial ())
 
 1060        return *(indices [n]);
 
 1063template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1066        for (
int i = 0; i < nsets; ++ i)
 
 1071template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1075        return ((n >= 0) && (n < nsets) && indices [n]);
 
 1078template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1083        if ((n < 0) || (n >= nsets) || !indices [n])
 
 1084                throw "Trying to get an undefined Conley index.";
 
 1085        return *(indices [n]);
 
 1088template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1091        (
int n, 
const typename 
 1094        if ((n < 0) || (n >= nsets))
 
 1095                throw "Trying to set a Conley index out of range.";
 
 1099        if (indices [n] -> trivial ())
 
 1103        return *(indices [n]);
 
 1106template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1110        return ((n >= 0) && (n < nsets) && (nontrivial [n] == 0));
 
 1115template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1120        for (
int i = 0; i < m. nsets; ++ i)
 
 1122                for (
int j = 0; j < n. nsets; ++ j)
 
 1125                        X. intersection (*(m. sets [i]), *(n. sets [j]));
 
 1129                        sets [nsets - 1] -> swap (X);
 
 1137template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1141        if ((n < 0) || (n >= nsets) || (m < 0) || (m >= nsets) || (n == m))
 
 1142                throw "Incorrect numbers of Morse sets to join.";
 
 1145        chomp::homology::sbug << 
"* Joining Morse sets: " <<
 
 1146                n << 
" and " << m << 
"(" << sets [n] -> size () <<
 
 1147                " - " << ((conn [n] [m] ? conn [n] [m] -> size () :
 
 1148                static_cast<int_t
> (0)) +
 
 1149                (conn [m] [n] ? conn [m] [n] -> size () :
 
 1150                static_cast<int_t
> (0))) << 
" - " <<
 
 1151                sets [m] -> size () << 
").\n";
 
 1156                for (
int i = 0; i < nsets; ++ i)
 
 1162        if (distconnDefined)
 
 1164                for (
int i = 0; i < nsets; ++ i)
 
 1166                        distconn [i] [n] = -1;
 
 1167                        distconn [n] [i] = -1;
 
 1172        sets [n] -> add (*(sets [m]));
 
 1173        if (connDefined && conn [n] [m])
 
 1174                sets [n] -> add (*(conn [n] [m]));
 
 1175        if (connDefined && conn [m] [n])
 
 1176                sets [n] -> add (*(conn [m] [n]));
 
 1181                for (
int k = 0; k < nsets; ++ k)
 
 1183                        if ((k == n) || (k == m))
 
 1192                                                add (*(conn [m] [k]));
 
 1194                                conn [n] [k] -> remove (*(sets [n]));
 
 1196                        else if (conn [m] [k])
 
 1198                                conn [n] [k] = conn [m] [k];
 
 1200                                conn [n] [k] -> remove (*(sets [n]));
 
 1209                                                add (*(conn [k] [m]));
 
 1211                                conn [k] [n] -> remove (*(sets [n]));
 
 1213                        else if (conn [k] [m])
 
 1215                                conn [k] [n] = conn [k] [m];
 
 1217                                conn [k] [n] -> remove (*(sets [n]));
 
 1223        if (indices [n] && nontrivial [m])
 
 1227                nontrivial [n] = -1;
 
 1231        deleteall (m, m + 1);
 
 1235template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1238        using chomp::homology::sbug;
 
 1240        if ((n < 0) || (n >= nsets))
 
 1241                throw "Incorrect numbers of Morse set to pass through.";
 
 1248        for (
int i = 0; i < nsets; ++ i)
 
 1252                for (
int j = 0; j < nsets; ++ j)
 
 1270                        if (connDefined && conn [i] [n] && conn [n] [j])
 
 1280                                        conn [i] [j] = 
new cubsettype;
 
 1281                                conn [i] [j] -> add (*(conn [i] [n]));
 
 1282                                conn [i] [j] -> add (*(conn [n] [j]));
 
 1283                                conn [i] [j] -> add (*(sets [n]));
 
 1286                                if (distconnDefined)
 
 1288                                        distconn [i] [j] = -1;
 
 1289                                        distconn [j] [i] = -1;
 
 1296        deleteall (n, n + 1);
 
 1300template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1302        (chomp::homology::hashedset<int> &setsToRemove)
 
 1304        using chomp::homology::sbug;
 
 1306        int nSetsToRemove = setsToRemove. size ();
 
 1309                for (
int index = nSetsToRemove - 1; index >= 0; -- index)
 
 1311                        this -> passthru (setsToRemove [index]);
 
 1320template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1322        (int_t maxsetsize, int_t maxconnsize, 
int maxdistance)
 
 1324        using chomp::homology::sbug;
 
 1325        sbug << 
"- Join trivial: maxsetsize = " << maxsetsize <<
 
 1326                ", maxconnsize = " << maxconnsize <<
 
 1327                ", maxdistance = " << maxdistance << 
".\n";
 
 1330        for (
int n = 0; n < nsets; ++ n)
 
 1332                if (nontrivial [n] < 0)
 
 1337        bool allow_trivial = 
false;
 
 1344                        sbug << 
"Morse decomposition connection set sizes:\n";
 
 1346                        for (
int i = 0; i < nsets; ++ i)
 
 1347                                sbug << setw (7) << i;
 
 1349                        for (
int i = 0; i < nsets; ++ i)
 
 1351                                sbug << setw (3) << i << 
" (" <<
 
 1352                                        setw (7) << sets [i] -> size ();
 
 1353                                switch (nontrivial [i])
 
 1355                                case -1: sbug << 
")- "; 
break;
 
 1356                                case 1: sbug << 
")+ "; 
break;
 
 1357                                case 0: sbug << 
"): "; 
break;
 
 1358                                default: sbug << 
")[" << nontrivial [i] <<
 
 1361                                for (
int j = 0; j < nsets; ++ j)
 
 1363                                        if (connDefined && conn [i] [j])
 
 1377                int best_n = -1, best_m = -1;
 
 1385                int best_conndist = 0;
 
 1388                for (
int n = 0; n < nsets; ++ n)
 
 1390                        for (
int m = 0; m < nsets; ++ m)
 
 1400                                int_t nsize = sets [n] -> size ();
 
 1401                                int_t msize = sets [m] -> size ();
 
 1405                                if (!nontrivial [m] && (nontrivial [n] ||
 
 1406                                        (nsize > maxsetsize) ||
 
 1413                                        (connDefined && conn [n] [m]) ?
 
 1414                                        conn [n] [m] -> size () :
 
 1415                                        static_cast<int_t
> (0);
 
 1417                                        (connDefined && conn [m] [n]) ?
 
 1418                                        conn [m] [n] -> size () :
 
 1419                                        static_cast<int_t
> (0);
 
 1423                                if ((msize < maxsetsize) &&
 
 1424                                        (conn_nm < maxconnsize) &&
 
 1425                                        (conn_mn < maxconnsize));
 
 1430                                bool looping = 
false;
 
 1433                                        for (
int k = 0; k < nsets; ++ k)
 
 1435                                                if ((conn [n] [k] &&
 
 1449                                int dist0 = distance (n, m);
 
 1452                                if (dist0 <= maxdistance);
 
 1458                                int conndist0 = conndistance (n, m);
 
 1461                                if (conndist0 <= maxdistance);
 
 1469                                if ((best_n < 0) || (dist0 + conndist0 <=
 
 1470                                        best_dist + best_conndist));
 
 1491                if ((best_n < 0) || (best_m < 0))
 
 1498                        allow_trivial = 
true;
 
 1503                join (best_n, best_m);
 
 1507        for (
int n = 0; n < nsets; ++ n)
 
 1509                if (nontrivial [n] < 0)
 
 1516template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1518        (
const char *prefix)
 
 1520        for (
int n = 0; n < nsets; ++ n)
 
 1523                std::ostringstream ofname;
 
 1527                std::string fname = ofname. str ();
 
 1529                std::ofstream out (ofname. str (). c_str ());
 
 1532                out << 
"; This is the Morse set no. " << n << 
".\n";
 
 1533                out << 
"; Its Conley index ";
 
 1534                switch (nontrivial [n])
 
 1536                case 0: out << 
"is trivial.\n"; 
break;
 
 1537                case 1: out << 
"is nontrivial.\n"; 
break;
 
 1538                default: out << 
"has not been computed.\n"; 
break;
 
 1544                        out << 
"; The Conley index: " <<
 
 1545                                *(indices [n]) << 
"\n";
 
 1553                for (
int m = 0; m < nsets; ++ m)
 
 1556                        if (!connDefined || !conn [n] [m])
 
 1560                        std::ostringstream connname;
 
 1561                        connname << fname << 
'-' << m << 
".cub";
 
 1564                        std::ofstream outc (connname. str (). c_str ());
 
 1565                        outc << 
"; This is a covering of all the computed " 
 1566                                "connecting orbits\n" 
 1567                                "; that run from the Morse set no. " << n <<
 
 1568                                " to " << m << 
".\n";
 
 1569                        if (conn [n] [m] -> empty ())
 
 1571                                outc << 
"\n; Note: This set is empty " 
 1572                                        "which means that the orbit\n" 
 1573                                        "; was most likely not computed.\n";
 
 1577                                outc << *(conn [n] [m]);
 
 1584template <
class mapcomp, 
class cubetype, 
class cubsettype>
 
 1586        (
const char *prefix)
 
 1588        for (
int n = 0; ; ++ n)
 
 1591                std::ostringstream fname;
 
 1597                std::ifstream in (fname. str (). c_str ());
 
 1604                int nontrivialindex = -1;
 
 1606                while (in. peek () == 
';')
 
 1613                        if (line. find (
"Conley index is nontrivial") !=
 
 1616                                nontrivialindex = 1;
 
 1621                        if (line. find (
"Conley index is trivial") !=
 
 1624                                nontrivialindex = 0;
 
 1629                        std::string indHeader (
"Conley index: ");
 
 1630                        std::string::size_type pos = line. find (indHeader);
 
 1631                        if (pos != std::string::npos)
 
 1633                                std::istringstream str (line);
 
 1634                                std::string::size_type len = pos +
 
 1636                                for (
unsigned int i = 0; i < len; ++ i)
 
 1648                indices [n] = theIndex;
 
 1649                nontrivial [n] = nontrivialindex;
 
 1653        for (
int n = 0; n < nsets; ++ n)
 
 1655                for (
int m = 0; m < nsets; ++ m)
 
 1658                        std::ostringstream fname;
 
 1661                        fname << n << 
'-' << m;
 
 1664                        std::ifstream in (fname. str (). c_str ());
 
 1670                        in >> *(conn [n] [m]);
 
The class that computes and returns properties of the Conley index.
 
A generic class that computes an index pair given the isolating neighborhood and a means to compute t...
 
The Morse decoposition class.
 
void copyall(const MorseDecomposition &m)
Copy all the data (used in the copy constructor and operator =).
 
int passthru(int n)
Make connecting orbits pass through the given Morse set, because its invariant part is in fact empty.
 
bool distconnDefined
Were any values of conn distance defined?
 
bool trivial(int n) const
Returns true if the Conley index of the given Morse set is trivial, and false if either nontrivial or...
 
static int cubsetdistance(const cubsettype &X, const cubsettype &Y, bool minimum)
Returns the approximate distance between the two cubical sets.
 
const cubsettype & operator[](int n) const
Returns the n-th Morse set.
 
int jointrivial(int_t maxsetsize, int_t maxconnsize, int maxdistance)
Joins small Morse sets with trivial indices with Morse sets whose indices are nontrivial.
 
IndexPair< mapcomp, cubetype, cubsettype > PairType
The type of the index pair.
 
void addone()
Add one Morse set and initialize its data.
 
bool connected(int n, int m) const
Checks whether there exists a connection between given sets.
 
int conndistance(int n, int m) const
Returns the appropriate maximal distance between cubes that are contained in the Morse set n and the ...
 
chomp::homology::multitable< chomp::homology::multitable< int > > dist
Tabulated distances between the Morse sets.
 
int compute()
Computes the Conley indices of all the Morse sets.
 
const IndexType & setindex(int n, const typename MorseDecomposition< mapcomp, cubetype, cubsettype >::IndexType &ind)
Sets the index of the given Morse set to the apriori known one.
 
void setConnDefined(void)
Initializes the connection array so that connections are defined from this point on.
 
const IndexType & index(int n) const
Retrieves the previously computed Conley index of the given Morse set.
 
void intersection(const MorseDecomposition< mapcomp, cubetype, cubsettype > &m, const MorseDecomposition< mapcomp, cubetype, cubsettype > &n)
Computes the set-wise intersection of two Morse decompositions.
 
int addconn(int n, int m)
Adds a connection between the given Morse sets without adding any cubes to this connection (like in a...
 
cubetype CubeType
The type of a single cube.
 
int nsets
The number of Morse sets.
 
int makegraph(chomp::homology::diGraph<> &g) const
Creates a graph representation of the Morse decomposition.
 
const mapcomp & M
The map computation class.
 
~MorseDecomposition()
The destructor.
 
chomp::homology::multitable< int > nontrivial
The table that stores the information on whether the indices are trivial or not: -1 = unknown,...
 
MorseDecomposition(const mapcomp &_M=mapcomp())
The default constructor.
 
bool adjacent(int n, int m, int margin=0) const
Verifies if two Morse sets are adjacent to each other.
 
bool distDefined
Were any distances computed?
 
chomp::homology::multitable< chomp::homology::multitable< int > > distconn
Tabulated values of the function "conndistance".
 
int count() const
Returns the number of Morse sets.
 
mapcomp MapCompType
The type of the map computation class.
 
const cubsettype & connection(int n, int m) const
Returns the connection between the given sets.
 
int add(int n, const cubetype &q)
Adds a cube to the given Morse set and increases the number of Morse sets if necessary.
 
int join(int n, int m)
Joins the two given Morse sets.
 
chomp::homology::multitable< chomp::homology::multitable< cubsettype * > > conn
Connecting orbits from one set to another.
 
chomp::homology::multitable< IndexType * > indices
The Conley indices of the Morse sets.
 
int setnumber(int n)
Changes (increases or decreases) the number of Morse sets.
 
bool connDefined
Were any connections defined?
 
int distance(int n, int m) const
Returns the approximate distance between the two Morse sets.
 
chomp::homology::multitable< cubsettype * > sets
The Morse sets.
 
bool computed(int n) const
Verifies if the Conley index for the given Morse set has been already computed.
 
void swap(MorseDecomposition &m)
Swaps the internal data with another object (note: both must be initialized with the same map computa...
 
void deleteall(int firstnumber, int lastnumber)
Release the memory (used in the destructor and copy constructor).
 
cubsettype CubSetType
The type of a set of cubes used to store each Morse set.
 
chomp::homology::mvmap< cubetype, cubetype > cubmaptype
The type of a combinatorial cubical multivalued map.
 
int savetofiles(const char *prefix=0)
Save the Morse sets and connecting orbits to files.
 
ConleyIndex< PairType > IndexType
The type of the Conley index.
 
int loadfromfiles(const char *prefix=0)
Load the Morse sets and connecting orbits from files.
 
Conley index computation routines.