This class defines cubical cell in R^n with edges parallel to the axes and with size 0 or 1 in each direction. More...
#include <cellbase.h>
Public Types | |
enum | OutputBitValues { BitProduct = 0x01, BitSpace = 0x02 } |
Bit masks that define how to output the cell. More... | |
typedef coordtype | CoordType |
The type of the coordinates. | |
typedef tCubeBase< coordtype > ::PointBase | PointBase |
The point base (for wrapping and tabulating coordinates). | |
Public Member Functions | |
tCellBase () | |
The constructor of an empty cubical cell. | |
tCellBase (const coordtype *c1, const coordtype *c2, int spcdim, int celldim=-1) | |
The constructor of a cell spanning from one point to another. | |
tCellBase (const tCubeBase< coordtype > &q1, const tCubeBase< coordtype > &q2) | |
The constructor of a cell as an intersection of two full cubes. | |
tCellBase (const tCubeBase< coordtype > &q, int facedim) | |
The constructor of an arbitrary k-dimensional face of a full cube. | |
tCellBase (const tCubeBase< coordtype > &q) | |
The constructor of a full-dimensional cubical cell. | |
tCellBase (const tCellBase< coordtype > &q, int offset, int ncoords) | |
The constructor of a projection of a cell to the given number of coordinates that start at the given offset. | |
tCellBase (const tCellBase< coordtype > &c) | |
The copy constructor. | |
tCellBase< coordtype > & | operator= (const tCellBase< coordtype > &c) |
The assignment operator. | |
int | dim () const |
Returns the dimension of the cubical cell. | |
int | spacedim () const |
Returns the dimension of the embedding space. | |
coordtype * | leftcoord (coordtype *c) const |
Fills in the given table with the left corner coordinates. | |
coordtype * | rightcoord (coordtype *c) const |
Fills in the given table with the right corner coordinates. | |
int_t | hashkey1 () const |
Returns hashing key no. 1 required by the hashing set template. | |
int_t | hashkey2 () const |
Return shashing key no. 2 required by the hashing set template. | |
Static Public Member Functions | |
static const char * | name () |
Returns the name of the objects represented by this class. | |
static const char * | pluralname () |
Returns the plural name of the objects represented by this class. | |
Static Public Attributes | |
static const int | MaxDim = tCubeBase<coordtype>::MaxDim |
The maximal dimension of a cell. | |
static const int | MaxSpaceDim = tCubeBase<coordtype>::MaxDim |
The maximal dimension of the embedding space of a cell. | |
static int | OutputBits = 0 |
The output bits which determine how a cell is written. | |
Private Member Functions | |
int_t | num1 () const |
Returns the first number of the cubical cell vertices. | |
int_t | num2 () const |
Returns the second number of the cubical cell vertices. | |
void | initialize (const coordtype *c1, const coordtype *c2, int spcdim, int celldim=-1) |
Initializes a new cell given its two corners. | |
Private Attributes | |
int_t | n1 |
The left vertex: high 6 bits = space dim, the remaining bits form the number of the point in an appropriate pointset. | |
int_t | n2 |
The right vertex: high 6 bits = cube dim, the remaining bits form the number of the point in an appropriate pointset. | |
Friends | |
int | operator== (const tCellBase< coordtype > &c1, const tCellBase< coordtype > &c2) |
Verifies if two cells are identical. |
This class defines cubical cell in R^n with edges parallel to the axes and with size 0 or 1 in each direction.
This implementation uses a PointBase class to index all the vertices of cells which appear in the program.
Definition at line 69 of file cellbase.h.
typedef coordtype chomp::homology::tCellBase< coordtype >::CoordType |
The type of the coordinates.
Definition at line 73 of file cellbase.h.
typedef tCubeBase<coordtype>::PointBase chomp::homology::tCellBase< coordtype >::PointBase |
The point base (for wrapping and tabulating coordinates).
Definition at line 82 of file cellbase.h.
enum chomp::homology::tCellBase::OutputBitValues |
Bit masks that define how to output the cell.
If 'BitProduct' is set, then the cell is displayed as a Cartesian product of intervals. Otherwise, it is indicated by two opposite vertices. If 'BitSpace' is set, the space is inserted in the output.
Definition at line 141 of file cellbase.h.
{ BitProduct = 0x01, // unset => two vertices BitSpace = 0x02 };
chomp::homology::tCellBase< coordtype >::tCellBase | ( | ) | [inline] |
The constructor of an empty cubical cell.
Definition at line 241 of file cellbase.h.
chomp::homology::tCellBase< coordtype >::tCellBase | ( | const coordtype * | c1, | |
const coordtype * | c2, | |||
int | spcdim, | |||
int | celldim = -1 | |||
) | [inline] |
The constructor of a cell spanning from one point to another.
Definition at line 249 of file cellbase.h.
{ initialize (c1, c2, spcdim, celldim); return; } /* tCellBase::tCellBase */
chomp::homology::tCellBase< coordtype >::tCellBase | ( | const tCubeBase< coordtype > & | q1, | |
const tCubeBase< coordtype > & | q2 | |||
) | [inline] |
The constructor of a cell as an intersection of two full cubes.
Definition at line 257 of file cellbase.h.
References chomp::homology::CommonCell(), and chomp::homology::tPointBase< coordtype >::getwrapping().
{ // get the dimension of the space and check for consistency int spcdim = q1. dim (); if (spcdim != q2. dim ()) throw "Trying to intersect cubes of different dimension."; // get the coordinates of minimal vertices of both cubes coordtype c1 [MaxDim]; q1. coord (c1); coordtype c2 [MaxDim]; q2. coord (c2); // prepare tables for the new coordinates of the cubical cell coordtype left [MaxDim]; coordtype right [MaxDim]; // compute the new coordinates of the cubical cell int celldim = CommonCell (left, right, c1, c2, spcdim, PointBase::getwrapping (spcdim)); // create the cell as computed initialize (left, right, spcdim, celldim); return; } /* tCellBase::tCellBase */
chomp::homology::tCellBase< coordtype >::tCellBase | ( | const tCubeBase< coordtype > & | q, | |
int | facedim | |||
) | [inline] |
The constructor of an arbitrary k-dimensional face of a full cube.
Definition at line 285 of file cellbase.h.
References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tCellBase< coordtype >::MaxDim, chomp::homology::tCellBase< coordtype >::n1, chomp::homology::tCellBase< coordtype >::n2, chomp::homology::tCellBase< coordtype >::num1(), chomp::homology::tPointBase< coordtype >::number(), and chomp::homology::NumBits.
: n1 (q. n) { // check the dimensions int spcdim = static_cast<int> (n1 >> NumBits); if (facedim < 0) throw "Negative dimension of a face requested."; if (facedim > spcdim) throw "Too high dimension of a face requested."; // create the opposite corner of the cell const coordtype *c1 = PointBase::coord (num1 (), spcdim); coordtype c2 [MaxDim]; for (int i = 0; i < spcdim; ++ i) c2 [i] = c1 [i] + ((i < facedim) ? 1 : 0); // determine the number of the opposite corner and add cell dimension n2 = PointBase::number (c2, spcdim) | (static_cast<int_t> (facedim) << NumBits); return; } /* tCellBase::tCellBase */
chomp::homology::tCellBase< coordtype >::tCellBase | ( | const tCubeBase< coordtype > & | q | ) | [inline, explicit] |
The constructor of a full-dimensional cubical cell.
Definition at line 309 of file cellbase.h.
References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tCellBase< coordtype >::MaxDim, chomp::homology::tCellBase< coordtype >::n1, chomp::homology::tCellBase< coordtype >::n2, chomp::homology::tCellBase< coordtype >::num1(), chomp::homology::tPointBase< coordtype >::number(), and chomp::homology::NumBits.
: n1 (q. n) { // create the opposite corner of the cell int spcdim = static_cast<int> (n1 >> NumBits); const coordtype *c1 = PointBase::coord (num1 (), spcdim); coordtype c2 [MaxDim]; for (int i = 0; i < spcdim; ++ i) c2 [i] = c1 [i] + 1; // determine the number of the opposite corner and add cell dimension n2 = PointBase::number (c2, spcdim) | (static_cast<int_t> (spcdim) << NumBits); return; } /* tCellBase::tCellBase */
chomp::homology::tCellBase< coordtype >::tCellBase | ( | const tCellBase< coordtype > & | q, | |
int | offset, | |||
int | ncoords | |||
) | [inline] |
The constructor of a projection of a cell to the given number of coordinates that start at the given offset.
Definition at line 326 of file cellbase.h.
References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tCellBase< coordtype >::initialize(), chomp::homology::tCellBase< coordtype >::n1, chomp::homology::tCellBase< coordtype >::n2, chomp::homology::NumBits, and chomp::homology::NumMask.
{ int spcdim = static_cast<int> (q. n1 >> NumBits); if ((offset < 0) || (ncoords <= 0) || (offset + ncoords > spcdim)) throw "Wrong cell projection requested."; const coordtype *c1 = PointBase::coord (q. n1 & NumMask, spcdim); const coordtype *c2 = PointBase::coord (q. n2 & NumMask, spcdim); initialize (c1 + offset, c2 + offset, ncoords); return; } /* tCellBase::tCellBase */
chomp::homology::tCellBase< coordtype >::tCellBase | ( | const tCellBase< coordtype > & | c | ) | [inline] |
int chomp::homology::tCellBase< coordtype >::dim | ( | ) | const [inline] |
Returns the dimension of the cubical cell.
Definition at line 355 of file cellbase.h.
References chomp::homology::tCellBase< coordtype >::n2, and chomp::homology::NumBits.
int_t chomp::homology::tCellBase< coordtype >::hashkey1 | ( | ) | const [inline] |
Returns hashing key no. 1 required by the hashing set template.
Definition at line 387 of file cellbase.h.
References chomp::homology::tCellBase< coordtype >::n1, and chomp::homology::tCellBase< coordtype >::n2.
int_t chomp::homology::tCellBase< coordtype >::hashkey2 | ( | ) | const [inline] |
Return shashing key no. 2 required by the hashing set template.
Definition at line 394 of file cellbase.h.
References chomp::homology::tCellBase< coordtype >::n1, and chomp::homology::tCellBase< coordtype >::n2.
void chomp::homology::tCellBase< coordtype >::initialize | ( | const coordtype * | c1, | |
const coordtype * | c2, | |||
int | spcdim, | |||
int | celldim = -1 | |||
) | [inline, private] |
Initializes a new cell given its two corners.
Definition at line 200 of file cellbase.h.
References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tCellBase< coordtype >::MaxDim, chomp::homology::tCellBase< coordtype >::n1, chomp::homology::tCellBase< coordtype >::n2, chomp::homology::tPointBase< coordtype >::number(), and chomp::homology::NumBits.
Referenced by chomp::homology::tCellBase< coordtype >::tCellBase().
{ // test the validity of the dimension if (spcdim <= 0) throw "Non-positive dimension of the space."; else if (spcdim >= MaxDim) throw "Too high dimension of a cell."; // get the number of the left vertex n1 = PointBase::number (c1, spcdim); if (n1 < 0) throw "Negative number of the left vertex."; // get the number of the right vertex n2 = PointBase::number (c2, spcdim); if (n2 < 0) throw "Negative number of the right vertex."; // calculate the dimension of the cubical cell if it is unknown if (celldim < 0) { celldim = 0; c1 = PointBase::coord (n1, spcdim); c2 = PointBase::coord (n2, spcdim); for (int i = 0; i < spcdim; ++ i) { if (c2 [i] != c1 [i]) ++ celldim; } } // add the space dimension and the cell dimension to the numbers n1 |= (static_cast<int_t> (spcdim) << NumBits); n2 |= (static_cast<int_t> (celldim) << NumBits); return; } /* tCellBase::initialize */
coordtype * chomp::homology::tCellBase< coordtype >::leftcoord | ( | coordtype * | c | ) | const [inline] |
Fills in the given table with the left corner coordinates.
Definition at line 367 of file cellbase.h.
References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::copycoord(), chomp::homology::tCellBase< coordtype >::num1(), and chomp::homology::tCellBase< coordtype >::spacedim().
{ const coordtype *leftc = PointBase::coord (num1 (), spacedim ()); if (!c) throw "Null pointer to save left coordinates."; copycoord (c, leftc, spacedim ()); return c; } /* tCellBase::leftcoord */
const char * chomp::homology::tCellBase< coordtype >::name | ( | ) | [static] |
Returns the name of the objects represented by this class.
Definition at line 401 of file cellbase.h.
{ return "cubical cell"; } /* tCellBase::name */
int_t chomp::homology::tCellBase< coordtype >::num1 | ( | ) | const [inline, private] |
Returns the first number of the cubical cell vertices.
Definition at line 188 of file cellbase.h.
References chomp::homology::tCellBase< coordtype >::n1, and chomp::homology::NumMask.
Referenced by chomp::homology::tCellBase< coordtype >::leftcoord(), and chomp::homology::tCellBase< coordtype >::tCellBase().
int_t chomp::homology::tCellBase< coordtype >::num2 | ( | ) | const [inline, private] |
Returns the second number of the cubical cell vertices.
Definition at line 194 of file cellbase.h.
References chomp::homology::tCellBase< coordtype >::n2, and chomp::homology::NumMask.
Referenced by chomp::homology::tCellBase< coordtype >::rightcoord().
tCellBase< coordtype > & chomp::homology::tCellBase< coordtype >::operator= | ( | const tCellBase< coordtype > & | c | ) | [inline] |
const char * chomp::homology::tCellBase< coordtype >::pluralname | ( | ) | [static] |
Returns the plural name of the objects represented by this class.
Definition at line 407 of file cellbase.h.
{ return "cubical cells"; } /* tCellBase::pluralname */
coordtype * chomp::homology::tCellBase< coordtype >::rightcoord | ( | coordtype * | c | ) | const [inline] |
Fills in the given table with the right corner coordinates.
Definition at line 377 of file cellbase.h.
References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::copycoord(), chomp::homology::tCellBase< coordtype >::num2(), and chomp::homology::tCellBase< coordtype >::spacedim().
{ const coordtype *rightc = PointBase::coord (num2 (), spacedim ()); if (!c) throw "Null pointer to save right coordinates."; copycoord (c, rightc, spacedim ()); return c; } /* tCellBase::rightcoord */
int chomp::homology::tCellBase< coordtype >::spacedim | ( | ) | const [inline] |
Returns the dimension of the embedding space.
Definition at line 361 of file cellbase.h.
References chomp::homology::tCellBase< coordtype >::n1, and chomp::homology::NumBits.
Referenced by chomp::homology::tCellBase< coordtype >::leftcoord(), and chomp::homology::tCellBase< coordtype >::rightcoord().
const int chomp::homology::tCellBase< coordtype >::MaxDim = tCubeBase<coordtype>::MaxDim [static] |
The maximal dimension of a cell.
Definition at line 76 of file cellbase.h.
Referenced by chomp::homology::tCellBase< coordtype >::initialize(), and chomp::homology::tCellBase< coordtype >::tCellBase().
const int chomp::homology::tCellBase< coordtype >::MaxSpaceDim = tCubeBase<coordtype>::MaxDim [static] |
The maximal dimension of the embedding space of a cell.
Definition at line 79 of file cellbase.h.
int_t chomp::homology::tCellBase< coordtype >::n1 [private] |
The left vertex: high 6 bits = space dim, the remaining bits form the number of the point in an appropriate pointset.
Definition at line 168 of file cellbase.h.
Referenced by chomp::homology::tCellBase< coordtype >::hashkey1(), chomp::homology::tCellBase< coordtype >::hashkey2(), chomp::homology::tCellBase< coordtype >::initialize(), chomp::homology::tCellBase< coordtype >::num1(), chomp::homology::tCellBase< coordtype >::spacedim(), and chomp::homology::tCellBase< coordtype >::tCellBase().
int_t chomp::homology::tCellBase< coordtype >::n2 [private] |
The right vertex: high 6 bits = cube dim, the remaining bits form the number of the point in an appropriate pointset.
Definition at line 172 of file cellbase.h.
Referenced by chomp::homology::tCellBase< coordtype >::dim(), chomp::homology::tCellBase< coordtype >::hashkey1(), chomp::homology::tCellBase< coordtype >::hashkey2(), chomp::homology::tCellBase< coordtype >::initialize(), chomp::homology::tCellBase< coordtype >::num2(), and chomp::homology::tCellBase< coordtype >::tCellBase().
int chomp::homology::tCellBase< coordtype >::OutputBits = 0 [static] |
The output bits which determine how a cell is written.
Definition at line 148 of file cellbase.h.