Classes | |
| class | CubicalSet |
| This class stores a full cubical set and implements some basic operations on such a set, like adding or removing cubes with given coordinates. More... | |
Namespaces | |
| namespace | chomp |
This namespace contains the entire CHomP library interface. | |
Files | |
| file | algstruct.h |
This file defines an algebraic data structure which is used to store the information about computed homology groups. | |
| file | cubfiles.h |
This file defines various types of cubical sets whose homology can be computed by homology engines. | |
| file | cubiset.h |
This file defines an very simple interface to manipulating a full cubical set represented as a bitmap for the purpose of homology computation. | |
| file | engines.h |
This file defines several engines for the homology computation of cubical sets. | |
| file | homology.h |
This file defines a top-level interface to a homology computation procedure of full cubical sets represented in terms of a bitmap. | |
Functions | |
| void | ComputeBettiNumbers (const CubicalSet &s, int *result, const char *engine=0, bool quiet=false) |
| Computes the Betti numbers of a full cubical set represented by an object of the class "CubicalSet". | |
| void | ComputeBettiNumbers (const void *buffer, int *sizes, int dim, int *result, const char *engine=0, const int *wrapping=0, bool quiet=false) |
| Computes the Betti numbers of the given set of full cubes encoded in a binary bitmap. | |
| CubicalSet::CubicalSet (const int *left_coords, const int *right_coords, int dim=EMBEDDING_DIM, const int *space_wrapping=0) | |
| The only constructor allowed: Creates an empty cubical bitmap of the given size. | |
| CubicalSet::~CubicalSet () | |
| The destructor. | |
| CubicalSet::CubicalSet (const CubicalSet &c) | |
| The copy constructor. | |
| CubicalSet & | CubicalSet::operator= (const CubicalSet &c) |
| The assignment operator. | |
| int | CubicalSet::ByteOffset (const int *coords) const |
| Computes the right word offset in the buffer. | |
| int | CubicalSet::BitMask (const int *coords) const |
| Computes the mask for the bit in the right word. | |
| bool | CubicalSet::Inside (const int *coords) |
| Verifies whether the cube is within the bounding box. | |
| int | CubicalSet::Add (const int *coords) |
| Adds a cube to the set unless the cube is outside the box. | |
| int | CubicalSet::Delete (const int *coords) |
| Deletes a cube from the set. | |
| bool | CubicalSet::Contains (const int *coords) const |
| Verifies whether the given cube is contained in the cubical set. | |
| void | CubicalSet::Clear () |
| Clears the bitmap and makes the cubical set empty. | |
| void | CubicalSet::ComputeBettiNumbers (int *result, const char *engine=0, bool quiet=false) const |
| Computes the Betti numbers of the cubical set. | |
Variables | |
| ofstreamcout | fcout |
| An output stream defined by M. Mrozek in the CAPD library. | |
| int CubicalSet::Add | ( | const int * | coords | ) | [inline, inherited] |
Adds a cube to the set unless the cube is outside the box.
Returns 0 if the cube is within the box or -1 otherwise.
Definition at line 225 of file cubiset.h.
References CubicalSet::BitMask(), CubicalSet::buffer, CubicalSet::ByteOffset(), and CubicalSet::Inside().
{
if (!Inside (coords))
return -1;
buffer [ByteOffset (coords)] |= BitMask (coords);
return 0;
} /* CubicalSet::Add */
| int CubicalSet::BitMask | ( | const int * | coords | ) | const [inline, private, inherited] |
Computes the mask for the bit in the right word.
Definition at line 208 of file cubiset.h.
References CubicalSet::minimal.
Referenced by CubicalSet::Add(), CubicalSet::Contains(), and CubicalSet::Delete().
{
return 1 << ((coords [0] - minimal [0]) & 0x07);
} /* CubicalSet::BitMask */
| int CubicalSet::ByteOffset | ( | const int * | coords | ) | const [inline, private, inherited] |
Computes the right word offset in the buffer.
Definition at line 196 of file cubiset.h.
References CubicalSet::dim, CubicalSet::minimal, and CubicalSet::sizes.
Referenced by CubicalSet::Add(), CubicalSet::Contains(), and CubicalSet::Delete().
| void CubicalSet::Clear | ( | ) | [inline, inherited] |
Clears the bitmap and makes the cubical set empty.
Definition at line 246 of file cubiset.h.
References CubicalSet::buffer, and CubicalSet::bufsize.
| void ComputeBettiNumbers | ( | const void * | buffer, | |
| int * | sizes, | |||
| int | dim, | |||
| int * | result, | |||
| const char * | engine = 0, |
|||
| const int * | wrapping = 0, |
|||
| bool | quiet = false | |||
| ) | [inline] |
Computes the Betti numbers of the given set of full cubes encoded in a binary bitmap.
| buffer | - a buffer that contains the bitmap which defines the cubes; each byte stores 8 subsequent positions, with lower bits corresponding to cubes placed to the left from the higher bits; the width of each line must be a multiple of 4 bytes (if the number of cubes is less than that, then the lines must be padded with zeros) - this is required by the MM* engines; the first line corresponds to pixels with the coordinates (0,0,0,...,0), (1,0,0,...,0), ..., (n,0,0,...,0); the next line in the bitmap corresponds to the pixels (0,1,0,...,0), ..., (n,1,0,...,0), etc. | |
| sizes | - a table of the sizes of the bitmap in each direction, | |
| dim | - the space dimension, | |
| result | - a table into which the result is written; its size must be at least (dim + 1), | |
| engine | - the name of a homology engine to choose; the engine is automatically selected if this is zero | |
| wrapping | - space wrapping in each direction (0 = no wrapping) | |
| quiet | - true = the function should display no messages to the standard output stream; false = show a lot of messages |
Definition at line 53 of file homology.h.
References fcout, chomp::homengin::engine::find(), chomp::homology::scon, and chomp::homology::sout.
{
using namespace chomp::homology;
// turn off screen output if requested to
bool soutput = sout. show;
bool coutput = scon. show;
if (quiet)
{
sout. show = false;
scon. show = false;
fcout. turnOff ();
}
else
fcout. turnOn ();
// create a corresponding set of cubes
chomp::homengin::cubitmap X (reinterpret_cast<const char *> (buffer),
sizes, dim);
// set the space wrapping
if (wrapping)
X. setwrapping (wrapping, dim);
// find the best engine to use for the homology computation
const chomp::homengin::engine *e;
if (!engine)
e = chomp::homengin::engine::find (&X);
// another possibility: find the engine with the given name
else
e = chomp::homengin::engine::find (engine);
// compute the homology of the set of cubes
chomp::homengin::algstruct<chomp::homology::integer> hom;
e -> homology (X, hom);
sout << "The computed homology is " << hom << ".\n";
// fill in the resulting table of Betti numbers
int levels = hom. countLevels ();
for (int i = 0; i <= dim; ++ i)
result [i] = (i < levels) ? hom. getBetti (i) : 0;
// restore the message settings
chomp::homology::sout. show = soutput;
chomp::homology::scon. show = coutput;
return;
} /* ComputeBettiNumbers */
| void ComputeBettiNumbers | ( | const CubicalSet & | s, | |
| int * | result, | |||
| const char * | engine = 0, |
|||
| bool | quiet = false | |||
| ) | [inline] |
Computes the Betti numbers of a full cubical set represented by an object of the class "CubicalSet".
Definition at line 262 of file cubiset.h.
References chomp::homology::ComputeBettiNumbers().
{
s. ComputeBettiNumbers (result, engine, quiet);
return;
} /* ComputeBettiNumbers */
| void CubicalSet::ComputeBettiNumbers | ( | int * | result, | |
| const char * | engine = 0, |
|||
| bool | quiet = false | |||
| ) | const [inline, inherited] |
Computes the Betti numbers of the cubical set.
Note: The size of the result table must be at least dim+1.
Definition at line 252 of file cubiset.h.
References CubicalSet::buffer, CubicalSet::dim, CubicalSet::sizes, and CubicalSet::wrapping.
{
::ComputeBettiNumbers (buffer, sizes, dim, result, engine,
wrapping, quiet);
return;
} /* CubicalSet::ComputeBettiNumbers */
| bool CubicalSet::Contains | ( | const int * | coords | ) | const [inline, inherited] |
Verifies whether the given cube is contained in the cubical set.
Returns 'true' if yes, 'false' if not.
Definition at line 241 of file cubiset.h.
References CubicalSet::BitMask(), CubicalSet::buffer, and CubicalSet::ByteOffset().
{
return buffer [ByteOffset (coords)] & BitMask (coords);
} /* CubicalSet::Contains */
| CubicalSet::CubicalSet | ( | const int * | left_coords, | |
| const int * | right_coords, | |||
| int | dim = EMBEDDING_DIM, |
|||
| const int * | space_wrapping = 0 | |||
| ) | [inline, inherited] |
The only constructor allowed: Creates an empty cubical bitmap of the given size.
Definition at line 108 of file cubiset.h.
References CubicalSet::buffer, CubicalSet::bufsize, CubicalSet::minimal, CubicalSet::sizes, and CubicalSet::wrapping.
{
if (dim <= 0)
throw "Non-positive dimension of a cubical complex.";
this -> dim = dim;
this -> sizes = new int [dim];
this -> minimal = new int [dim];
this -> wrapping = space_wrapping ? new int [dim] : 0;
this -> bufsize = 0;
for (int i = 0; i < dim; ++ i)
{
minimal [i] = left_coords [i];
sizes [i] = right_coords [i] - left_coords [i];
if (sizes [i] <= 0)
throw "Non-positive size of a cubical complex.";
if (!i)
{
sizes [0] = (sizes [0] + 63) & ~63;
bufsize = sizes [0] >> 3;
}
else
bufsize *= sizes [i];
}
if (space_wrapping)
{
for (int i = 0; i < dim; ++ i)
{
wrapping [i] = space_wrapping [i];
if (wrapping [i] < 0)
wrapping [i] = -space_wrapping [i];
}
}
if (bufsize <= 0)
throw "Wrong buffer size in a cubical complex.";
buffer = new unsigned char [bufsize];
std::memset (buffer, 0, bufsize);
return;
} /* CubicalSet::CubicalSet */
| CubicalSet::CubicalSet | ( | const CubicalSet & | c | ) | [inline, inherited] |
The copy constructor.
Definition at line 158 of file cubiset.h.
References CubicalSet::buffer, CubicalSet::bufsize, CubicalSet::dim, CubicalSet::minimal, and CubicalSet::sizes.
| int CubicalSet::Delete | ( | const int * | coords | ) | [inline, inherited] |
Deletes a cube from the set.
Returns 0 if deleted or -1 if the cube is outside the box.
Definition at line 233 of file cubiset.h.
References CubicalSet::BitMask(), CubicalSet::buffer, CubicalSet::ByteOffset(), and CubicalSet::Inside().
{
if (!Inside (coords))
return -1;
buffer [ByteOffset (coords)] &= ~(BitMask (coords));
return 0;
} /* CubicalSet::Delete */
| bool CubicalSet::Inside | ( | const int * | coords | ) | [inline, private, inherited] |
Verifies whether the cube is within the bounding box.
Definition at line 213 of file cubiset.h.
References CubicalSet::dim, CubicalSet::minimal, and CubicalSet::sizes.
Referenced by CubicalSet::Add(), and CubicalSet::Delete().
| CubicalSet & CubicalSet::operator= | ( | const CubicalSet & | c | ) | [inline, inherited] |
The assignment operator.
Definition at line 174 of file cubiset.h.
References CubicalSet::buffer, CubicalSet::bufsize, CubicalSet::dim, CubicalSet::minimal, and CubicalSet::sizes.
{
delete [] sizes;
delete [] minimal;
delete [] buffer;
dim = c. dim;
bufsize = c. bufsize;
sizes = new int [dim];
minimal = new int [dim];
for (int i = 0; i < dim; ++ i)
{
minimal [i] = c. minimal [i];
sizes [i] = c. sizes [i];
if (i > 0)
bufsize *= sizes [i];
}
buffer = new unsigned char [bufsize];
std::memcpy (buffer, c. buffer, bufsize);
return *this;
} /* CubicalSet::operator = */
| CubicalSet::~CubicalSet | ( | ) | [inline, inherited] |
The destructor.
Definition at line 148 of file cubiset.h.
References CubicalSet::buffer, CubicalSet::minimal, CubicalSet::sizes, and CubicalSet::wrapping.
| ofstreamcout fcout |
An output stream defined by M. Mrozek in the CAPD library.
Referenced by ComputeBettiNumbers().
1.7.1