35#ifndef _CHOMP_CUBES_CUBMAPS_H_
36#define _CHOMP_CUBES_CUBMAPS_H_
63template <
class eucl
idom,
class tCell>
66 const int *level,
int xdim,
int format = 0)
68 typedef typename tCell::CoordType coordType;
69 bool firstlist =
true;
70 for (
int d = 0; d <= c. dim (); ++ d)
72 if ((level && !level [d]) || hom [d]. empty ())
80 if (hom [d]. size () == 1)
82 out <<
"The generator of H_" << d <<
87 out <<
"The " << hom [d]. size () <<
88 " generators of H_" << d <<
93 for (
int_t i = 0; i < hom [d]. size (); ++ i)
97 if (hom [d]. size () > 1)
98 out <<
"generator " <<
102 c. gethomgen (d, hom [d]. num (i));
103 for (
int_t j = 0; j < lst. size (); ++ j)
105 coordType left [tCell::MaxDim];
106 cset [lst. num (j)]. leftcoord (left);
107 coordType right [tCell::MaxDim];
108 cset [lst. num (j)]. rightcoord (right);
110 for (
int k = 0; k < xdim; ++ k)
112 if (left [k] != right [k])
119 out << lst. coef (j) <<
" * " <<
120 tCell (left, right, xdim) <<
125 for (
int k = 0; k < xdim; ++ k)
126 out << left [k] <<
" ";
127 for (
int k = 0; k < xdim; ++ k)
128 out << right [k] <<
" ";
129 out << lst. coef (j) <<
" " <<
130 (i + 1) <<
" " << d <<
'\n';
146template <
class eucl
idom,
class tCell,
class tCube>
151 typedef typename tCell::CoordType coordType;
152 int_t countimages = 0;
153 coordType leftbound [tCell::MaxDim];
154 coordType rightbound [tCell::MaxDim];
155 coordType left [tCell::MaxDim];
156 coordType right [tCell::MaxDim];
157 for (
int d = 0; d <= m. dim (); ++ d)
162 const int spacedim = cset [0]. spacedim ();
163 for (
int_t i = 0; i < cset. size (); ++ i)
165 cset [i]. leftcoord (left);
166 cset [i]. rightcoord (right);
167 for (
int_t j = 0; j < spacedim; ++ j)
170 if (right [j] < left [j])
171 right [j] = left [j] + 1;
173 leftbound [j] =
static_cast<coordType
>
174 (left [j] - (left [j] == right [j]));
175 rightbound [j] =
static_cast<coordType
>
177 (left [j] == right [j]));
182 while ((c = r. get ()) != NULL)
184 if (!tCube::PointBase::check (c, spacedim))
186 tCube q (c, spacedim);
188 m. add (d, i, f1 (q));
190 m. add (d, i, f2 (q));
192 countimages += m (cset [i]). size ();
199template <
class eucl
idom,
class tCell,
class tCube>
210template <
class eucl
idom,
class tCell,
class tCube>
220template <
class eucl
idom,
class tCell,
class tCube>
236template <
class eucl
idom,
class tCell>
240 int offset,
int outdim,
int discarddim,
int *level = NULL)
242 typedef typename tCell::CoordType coordType;
244 for (
int d = 0; d <= Ycompl. dim (); ++ d)
246 if ((!level || level [d]) && (Fcompl. dim () >= d))
257 for (
int_t i = 0; i < Fset. size (); ++ i)
260 const tCell &Fcell = Fset [i];
261 coordType left [tCell::MaxDim];
262 Fcell. leftcoord (left);
263 coordType right [tCell::MaxDim];
264 Fcell. rightcoord (right);
269 for (j = 0; j < offset; ++ j)
270 if (left [j] != right [j])
277 for (j = 0; j < discarddim; ++ j)
278 if (left [offset + outdim + j] !=
279 right [offset + outdim + j])
288 if (!(tCell::PointBase::check
289 (left + offset, outdim)))
291 if (!(tCell::PointBase::check
292 (right + offset, outdim)))
296 tCell projected (Fcell, offset, outdim);
299 int_t nr = Yset. getnumber (projected);
308 cmap. add (d, nr, i, e);
319template <
class eucl
idom,
class tCell>
323 int offset,
int outdim,
int discarddim,
const int *level,
326 typedef typename tCell::CoordType coordType;
329 for (
int d = 0; d <= c. dim (); ++ d)
331 if ((!level || level [d]) && (c. dim () >= d))
339 for (
int_t i = 0; i < cset. size (); ++ i)
342 const tCell &thecell = cset [i];
343 coordType left [tCell::MaxDim];
344 thecell. leftcoord (left);
345 coordType right [tCell::MaxDim];
346 thecell. rightcoord (right);
351 for (j = 0; j < offset; ++ j)
352 if (left [j] != right [j])
359 for (j = 0; j < discarddim; ++ j)
360 if (left [offset + outdim + j] !=
361 right [offset + outdim + j])
370 if (!(tCell::PointBase::check
371 (left + offset, outdim))
372 || !(tCell::PointBase::check
373 (right + offset, outdim)))
376 throw "Inclusion undefined!";
380 tCell projected (left + offset,
381 right + offset, outdim);
382 if ((only. dim () >= 0) &&
383 !only. check (projected))
386 throw "Inclusion undefined.";
390 img. add (projected);
405template <
class tCube>
409 if ((in. peek () !=
'S') && (in. peek () !=
's'))
415 while (in. peek () != EOF)
417 if (in. peek () ==
'[')
423 throw "Can't read the file.";
436template <
class tCube>
440 if ((in. peek () !=
'S') && (in. peek () !=
's'))
446 typename tCube::CoordType left [tCube::MaxDim];
447 typename tCube::CoordType right [tCube::MaxDim];
448 while (in. peek () != EOF)
450 if (in. peek () ==
'[')
463 throw "Can't read the file.";
467 int dim = q1. dim ();
472 const typename tCube::CoordType *c;
473 while ((c = r. get ()) != NULL)
474 img. add (tCube (c, dim));
487template <
class tCube>
493 if ((in. peek () !=
'S') && (in. peek () !=
's'))
495 while (in. peek () != EOF)
498 !std::isdigit (in. peek ()))
506 bool ignore = !dom. check (q);
508 while (in. peek () ==
'-')
512 int opening = in. get ();
515 throw "An opening brace '{' expected.";
516 while ((in. peek () != EOF) &&
517 (in. peek () != closing))
521 if (in. get () == opening)
523 while ((in. peek () != EOF) &&
524 (in. peek () != closing))
536 if (in. peek () ==
',')
549 typename tCube::CoordType left [tCube::MaxDim];
550 typename tCube::CoordType right [tCube::MaxDim];
551 while (in. peek () != EOF)
553 if (in. peek () ==
'[')
556 tCube domcube1, domcube2;
558 if (!dom. check (domcube1))
572 throw "Can't read the file.";
576 if (dom. check (domcube1))
578 int dim = q1. dim ();
583 const typename tCube::CoordType *c;
584 while ((c = r. get ()) != NULL)
585 img. add (tCube (c, dim));
597template <
class tCube>
601 if (dom1. empty () && dom2. empty ())
603 sout <<
"Warning: The domain of the map is empty.\n";
608 if ((in. peek () !=
'S') && (in. peek () !=
's'))
611 typename tCube::CoordType left [tCube::MaxDim];
612 typename tCube::CoordType right [tCube::MaxDim];
613 while (in. peek () != EOF)
615 if (in. peek () ==
'[')
620 int dim = domcube. dim ();
621 if (dom1. check (domcube) || dom2. check (domcube))
631 throw "Can't read the file.";
637 const typename tCube::CoordType *c;
638 while ((c = r. get ()) != NULL)
639 img. add (tCube (c, dim));
652template <
class tCube>
This file includes header files with various definitions of cubical cells and defines the standard ty...
This class defines objects which represent chains as finite sequences of elements identified by integ...
This is an implementation of a chain complex over an arbitrary ring.
This class defines a chain map between two chain complexes.
The class that defines a geometric complex - a set of cells (cubes, simplices, etc).
This class represents a multivalued map whose domain is a geometric complex.
This class can be used for iterating a rectangular set of points, given its left and right bound.
This file contains some precompiler definitions which indicate the operating system and/or compiler u...
This file includes header files with various definitions of full cubes and defines the standard types...
This file contains a definition of a general geometric complex which represents a polyhedron.
int int_t
Index type for indexing arrays, counting cubes, etc.
This file contains the definition of the container "hashedset" which can be used to represent a set o...
This file defines a class "integer" which represents the ring of integers or the field of integers mo...
std::ostream & writegenerators(std::ostream &out, const chain< euclidom > *hom, const chaincomplex< euclidom > &c, const gcomplex< tCell, euclidom > &g, const int *level, int xdim, int format=0)
Writes projected homology generators of a cubical complex to a file.
void ignoreline(std::istream &in)
Ignores the input characters until the end of a line, including this end of the line.
outputstream sout
A replacement for standard output stream, with optional logging and other features provided by the cl...
int closingparenthesis(int ch)
Returns the matching closing parenthesis for the given opening one or EOF if none.
void project(const gcomplex< tCell, euclidom > &c, gcomplex< tCell, euclidom > &img, const gcomplex< tCell, euclidom > &only, int offset, int outdim, int discarddim, const int *level, bool watchforimages)
Creates the image of the projection from the set of cubical cells in the given geometric complex to t...
void createprojection(const gcomplex< tCell, euclidom > &Fcompl, const gcomplex< tCell, euclidom > &Ycompl, chainmap< euclidom > &cmap, int offset, int outdim, int discarddim, int *level=NULL)
Creates the chain map of the projection from a cell complex of the graph of a map to a cell complex o...
std::istream & readimage(std::istream &in, hashedset< tCube > &img)
Reads the image of a multivalued cubical map.
int_t createimages(mvcellmap< tCell, euclidom, tCube > &m, const mvmap< tCube, tCube > &f1, const mvmap< tCube, tCube > &f2, const hashedset< tCube > &dom1, const hashedset< tCube > &dom2)
Creates images of cells in 'm' as unions of cubes determined by f1 and f2.
std::istream & readselective(std::istream &in, const hashedset< tCube > &dom1, const hashedset< tCube > &dom2, mvmap< tCube, tCube > &m)
Reads the restriction of a multivalued map to the given pair of sets.
void ignorecomments(std::istream &in)
Ignores white characters (spaces, tabulators, CRs and LFs), as well as comments from the input text f...
std::istream & readdomain(std::istream &in, hashedset< tCube > &dom)
Reads the domain of a multivalued cubical map.
This namespace contains the entire CHomP library interface.
This file contains the definition of a point base class which is used for indexing all the points (n-...
This file contains the definition of a set of n-dimensional points with integer coordinates and sever...
This file contains some useful functions related to the text input/output procedures.