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 <cellfix.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 tCubeFix< dimfix, coordtype >::PointBase | PointBase |
The point base (for wrapping and tabulating coordinates). | |
Public Member Functions | |
tCellFix () | |
The constructor of an empty cubical cell. | |
tCellFix (const coordtype *c1, const coordtype *c2, int spcdim=0, int celldim=-1) | |
The constructor of a cell spanning from one point to another. | |
tCellFix (const tCubeFix< dimfix, coordtype > &q1, const tCubeFix< dimfix, coordtype > &q2) | |
The constructor of a cell as an intersection of two cubes. | |
tCellFix (const tCubeFix< dimfix, coordtype > &q, int facedim) | |
The constructor of an arbitrary k-dimensional face of a full cube. | |
tCellFix (const tCubeFix< dimfix, coordtype > &q) | |
The constructor of a full-dimensional cubical cell. | |
template<int dimhigh> | |
tCellFix (const tCellFix< dimhigh, 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. | |
tCellFix (const tCellFix< dimfix, coordtype > &c) | |
The copy constructor. | |
tCellFix< dimfix, coordtype > & | operator= (const tCellFix< dimfix, 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 |
Returns hashing 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 |
The maximal dimension of a cell. | |
static const int | MaxSpaceDim = dimfix |
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 | |
void | initialize (const coordtype *c1, const coordtype *c2, int celldim=-1) |
Initializes a new cell, given its two corners. | |
Private Attributes | |
coordtype | tab [dimfix] |
A table with the left coordinate of the cell. | |
int_t | n |
High 6 bits = the dimension of the cell (not: space). | |
Friends | |
template<int _dimfix, class _coordtype > | |
int | operator== (const tCellFix< _dimfix, _coordtype > &c1, const tCellFix< _dimfix, _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 assumes that the embedding space dimension is known at time of compilation.
Definition at line 69 of file cellfix.h.
typedef coordtype chomp::homology::tCellFix< dimfix, coordtype >::CoordType |
typedef tCubeFix<dimfix,coordtype>::PointBase chomp::homology::tCellFix< dimfix, coordtype >::PointBase |
enum chomp::homology::tCellFix::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 145 of file cellfix.h.
{ BitProduct = 0x01, // unset => two vertices BitSpace = 0x02 };
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix | ( | ) | [inline] |
The constructor of an empty cubical cell.
Definition at line 232 of file cellfix.h.
References chomp::homology::tCellFix< dimfix, coordtype >::MaxDim.
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix | ( | const coordtype * | c1, | |
const coordtype * | c2, | |||
int | spcdim = 0 , |
|||
int | celldim = -1 | |||
) | [inline] |
The constructor of a cell spanning from one point to another.
Definition at line 242 of file cellfix.h.
{ // test the validity of the dimension if (spcdim < 0) throw "Negative dimension of the space."; else if ((spcdim > 0) && (spcdim != dimfix)) throw "Wrong dimension of a cell."; if (dimfix > MaxDim) throw "Too high fixed-dim cell dimension."; // initialize the cell initialize (c1, c2, celldim); return; } /* tCellFix::tCellFix */
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix | ( | const tCubeFix< dimfix, coordtype > & | q1, | |
const tCubeFix< dimfix, coordtype > & | q2 | |||
) | [inline] |
The constructor of a cell as an intersection of two cubes.
Definition at line 259 of file cellfix.h.
References chomp::homology::CommonCell(), and chomp::homology::tPointBase< coordtype >::getwrapping().
{ if (dimfix > MaxDim) throw "Too high fixed-dim cell dimension."; // get the coordinates of minimal vertices of both cubes coordtype c1 [dimfix]; q1. coord (c1); coordtype c2 [dimfix]; q2. coord (c2); // prepare tables for the new coordinates of the cubical cell coordinate left [dimfix]; coordinate right [dimfix]; // compute the new coordinates of the cubical cell int celldim = CommonCell (left, right, c1, c2, dimfix, PointBase::getwrapping (dimfix)); // create the cell as computed initialize (left, right, celldim); return; } /* tCellFix::tCellFix */
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix | ( | const tCubeFix< dimfix, coordtype > & | q, | |
int | facedim | |||
) | [inline] |
The constructor of an arbitrary k-dimensional face of a full cube.
Definition at line 287 of file cellfix.h.
References chomp::homology::copycoord(), and chomp::homology::NumBits.
{ if (facedim < 0) throw "Negative dimension of a face requested."; if (facedim > dimfix) throw "Too high dimension of a face requested."; if (dimfix > MaxDim) throw "Too high fixed-dim cell dimension."; copycoord (tab, q. tab, dimfix); n = static_cast<int_t> (facedim) << NumBits; for (int i = 0; i < facedim; ++ i) n |= static_cast<int_t> (1) << i; return; } /* tCellFix::tCellFix */
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix | ( | const tCubeFix< dimfix, coordtype > & | q | ) | [inline, explicit] |
The constructor of a full-dimensional cubical cell.
Definition at line 304 of file cellfix.h.
References chomp::homology::copycoord().
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix | ( | const tCellFix< dimhigh, 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 316 of file cellfix.h.
{ if ((offset < 0) || (ncoords <= 0) || (ncoords != dimfix) || (offset + ncoords > dimhigh)) throw "Wrong cell projection requested."; // note: the following can be done in a slightly more efficient way, // without creating the right coordinates and calling "initialize" coordtype right [dimhigh]; q. rightcoord (right); initialize (q. tab + offset, right + offset); return; } /* tCellFix::tCellFix */
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix | ( | const tCellFix< dimfix, coordtype > & | c | ) | [inline] |
int chomp::homology::tCellFix< dimfix, coordtype >::dim | ( | ) | const [inline] |
Returns the dimension of the cubical cell.
Definition at line 348 of file cellfix.h.
References chomp::homology::tCellFix< dimfix, coordtype >::n, and chomp::homology::NumBits.
Referenced by chomp::homology::tCellFix< dimfix, coordtype >::initialize().
int_t chomp::homology::tCellFix< dimfix, coordtype >::hashkey1 | ( | ) | const [inline] |
Returns hashing key no. 1 required by the hashing set template.
Definition at line 384 of file cellfix.h.
References chomp::homology::tCellFix< dimfix, coordtype >::n, and chomp::homology::tCellFix< dimfix, coordtype >::tab.
{ switch (dimfix) { case 1: return (static_cast<int_t> (tab [0]) << 12) ^ n; case 2: return (((static_cast<int_t> (tab [0])) << 18) + ((static_cast<int_t> (tab [1])) << 6)) ^ n; default: return (((static_cast<int_t> (tab [0])) << 18) + ((static_cast<int_t> (tab [1])) << 6) + ((static_cast<int_t> (tab [2])) >> 6)) ^ n; } } /* tCellFix::hashkey1 */
int_t chomp::homology::tCellFix< dimfix, coordtype >::hashkey2 | ( | ) | const [inline] |
Returns hashing key no. 2 required by the hashing set template.
Definition at line 401 of file cellfix.h.
References chomp::homology::tCellFix< dimfix, coordtype >::n, and chomp::homology::tCellFix< dimfix, coordtype >::tab.
{ switch (dimfix) { case 1: return (static_cast<int_t> (tab [0]) << 3) ^ (n << 5); case 2: return ((static_cast<int_t> (tab [0]) >> 1) + (static_cast<int_t> (tab [1]) << 13)) ^ (n << 5); default: return (((static_cast<int_t> (tab [dimfix - 1])) << 20) + ((static_cast<int_t> (tab [dimfix - 2])) << 9) + ((static_cast<int_t> (tab [dimfix - 3])) >> 1)) ^ (n << 5); } } /* tCellFix::hashkey2 */
void chomp::homology::tCellFix< dimfix, coordtype >::initialize | ( | const coordtype * | c1, | |
const coordtype * | c2, | |||
int | celldim = -1 | |||
) | [inline, private] |
Initializes a new cell, given its two corners.
Definition at line 189 of file cellfix.h.
References chomp::homology::tCellFix< dimfix, coordtype >::dim(), chomp::homology::tCellFix< dimfix, coordtype >::n, chomp::homology::NumBits, chomp::homology::tCellFix< dimfix, coordtype >::tab, and chomp::homology::tPointBase< coordtype >::wrapcopy().
{ // copy the left corner coordinates to the cell PointBase::wrapcopy (tab, c1, dimfix); // prepare wrapped right coordinates for the detection of cell bits coordtype r [dimfix]; PointBase::wrapcopy (r, c2, dimfix); // if the dimension of the cell is known, then compute the bits only if (celldim >= 0) { n = static_cast<int_t> (celldim) << NumBits; if (!celldim) return; for (int i = 0; i < dimfix; ++ i) { if (tab [i] != r [i]) n |= (static_cast<int_t> (1) << i); } return; } // set the bits of the cell and compute its actual dimension n = 0; int dim = 0; for (int i = 0; i < dimfix; ++ i) { if (tab [i] != r [i]) { n |= (static_cast<int_t> (1) << i); ++ dim; } } n |= static_cast<int_t> (dim) << NumBits; return; } /* tCellFix::initialize */
coordtype * chomp::homology::tCellFix< dimfix, coordtype >::leftcoord | ( | coordtype * | c | ) | const [inline] |
Fills in the given table with the left corner coordinates.
Definition at line 360 of file cellfix.h.
References chomp::homology::tCellFix< dimfix, coordtype >::tab.
{ if (!c) throw "Null pointer to save left coordinates."; for (int i = 0; i < dimfix; ++ i) c [i] = tab [i]; return c; } /* tCellFix::leftcoord */
const char * chomp::homology::tCellFix< dimfix, coordtype >::name | ( | ) | [static] |
tCellFix< dimfix, coordtype > & chomp::homology::tCellFix< dimfix, coordtype >::operator= | ( | const tCellFix< dimfix, coordtype > & | c | ) | [inline] |
const char * chomp::homology::tCellFix< dimfix, coordtype >::pluralname | ( | ) | [static] |
coordtype * chomp::homology::tCellFix< dimfix, coordtype >::rightcoord | ( | coordtype * | c | ) | const [inline] |
Fills in the given table with the right corner coordinates.
Definition at line 370 of file cellfix.h.
References chomp::homology::tCellFix< dimfix, coordtype >::n, chomp::homology::tCellFix< dimfix, coordtype >::spacedim(), chomp::homology::tCellFix< dimfix, coordtype >::tab, and chomp::homology::tPointBase< coordtype >::wrapcoord().
{ if (!c) throw "Null pointer to save right coordinates."; for (int i = 0; i < dimfix; ++ i) { c [i] = tab [i] + ((n & (static_cast<int_t> (1) << i)) ? 1 : 0); } PointBase::wrapcoord (c, spacedim ()); return c; } /* tCellFix::rightcoord */
int chomp::homology::tCellFix< dimfix, coordtype >::spacedim | ( | ) | const [inline] |
Returns the dimension of the embedding space.
Definition at line 354 of file cellfix.h.
Referenced by chomp::homology::tCellFix< dimfix, coordtype >::rightcoord().
{ return dimfix; } /* tCellFix::spacedim */
const int chomp::homology::tCellFix< dimfix, coordtype >::MaxDim [static] |
The maximal dimension of a cell.
Definition at line 76 of file cellfix.h.
Referenced by chomp::homology::tCellFix< dimfix, coordtype >::tCellFix().
const int chomp::homology::tCellFix< dimfix, coordtype >::MaxSpaceDim = dimfix [static] |
int_t chomp::homology::tCellFix< dimfix, coordtype >::n [private] |
High 6 bits = the dimension of the cell (not: space).
Remaining bits set to 1 iff the cell has width 1 in the specified direction.
Definition at line 173 of file cellfix.h.
Referenced by chomp::homology::tCellFix< dimfix, coordtype >::dim(), chomp::homology::tCellFix< dimfix, coordtype >::hashkey1(), chomp::homology::tCellFix< dimfix, coordtype >::hashkey2(), chomp::homology::tCellFix< dimfix, coordtype >::initialize(), and chomp::homology::tCellFix< dimfix, coordtype >::rightcoord().
int chomp::homology::tCellFix< dimfix, coordtype >::OutputBits = 0 [static] |
coordtype chomp::homology::tCellFix< dimfix, coordtype >::tab[dimfix] [private] |
A table with the left coordinate of the cell.
Definition at line 168 of file cellfix.h.
Referenced by chomp::homology::tCellFix< dimfix, coordtype >::hashkey1(), chomp::homology::tCellFix< dimfix, coordtype >::hashkey2(), chomp::homology::tCellFix< dimfix, coordtype >::initialize(), chomp::homology::tCellFix< dimfix, coordtype >::leftcoord(), and chomp::homology::tCellFix< dimfix, coordtype >::rightcoord().