The Original CHomP Software
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
chomp::homology::tCellBase< coordtype > Class Template Reference

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. More...
 
typedef tCubeBase< coordtype >::PointBase PointBase
 The point base (for wrapping and tabulating coordinates). More...
 

Public Member Functions

 tCellBase ()
 The constructor of an empty cubical cell. More...
 
 tCellBase (const coordtype *c1, const coordtype *c2, int spcdim, int celldim=-1)
 The constructor of a cell spanning from one point to another. More...
 
 tCellBase (const tCubeBase< coordtype > &q1, const tCubeBase< coordtype > &q2)
 The constructor of a cell as an intersection of two full cubes. More...
 
 tCellBase (const tCubeBase< coordtype > &q, int facedim)
 The constructor of an arbitrary k-dimensional face of a full cube. More...
 
 tCellBase (const tCubeBase< coordtype > &q)
 The constructor of a full-dimensional cubical cell. More...
 
 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. More...
 
 tCellBase (const tCellBase< coordtype > &c)
 The copy constructor. More...
 
tCellBase< coordtype > & operator= (const tCellBase< coordtype > &c)
 The assignment operator. More...
 
int dim () const
 Returns the dimension of the cubical cell. More...
 
int spacedim () const
 Returns the dimension of the embedding space. More...
 
coordtype * leftcoord (coordtype *c) const
 Fills in the given table with the left corner coordinates. More...
 
coordtype * rightcoord (coordtype *c) const
 Fills in the given table with the right corner coordinates. More...
 
int_t hashkey1 () const
 Returns hashing key no. 1 required by the hashing set template. More...
 
int_t hashkey2 () const
 Return shashing key no. 2 required by the hashing set template. More...
 

Static Public Member Functions

static const char * name ()
 Returns the name of the objects represented by this class. More...
 
static const char * pluralname ()
 Returns the plural name of the objects represented by this class. More...
 

Static Public Attributes

static const int MaxDim = tCubeBase<coordtype>::MaxDim
 The maximal dimension of a cell. More...
 
static const int MaxSpaceDim = tCubeBase<coordtype>::MaxDim
 The maximal dimension of the embedding space of a cell. More...
 
static int OutputBits = 0
 The output bits which determine how a cell is written. More...
 

Private Member Functions

int_t num1 () const
 Returns the first number of the cubical cell vertices. More...
 
int_t num2 () const
 Returns the second number of the cubical cell vertices. More...
 
void initialize (const coordtype *c1, const coordtype *c2, int spcdim, int celldim=-1)
 Initializes a new cell given its two corners. More...
 

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. More...
 
int_t n2
 The right vertex: high 6 bits = cube dim, the remaining bits form the number of the point in an appropriate pointset. More...
 

Friends

int operator== (const tCellBase< coordtype > &c1, const tCellBase< coordtype > &c2)
 Verifies if two cells are identical. More...
 

Detailed Description

template<class coordtype>
class chomp::homology::tCellBase< coordtype >

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 68 of file cellbase.h.

Member Typedef Documentation

◆ CoordType

template<class coordtype >
typedef coordtype chomp::homology::tCellBase< coordtype >::CoordType

The type of the coordinates.

Definition at line 72 of file cellbase.h.

◆ PointBase

template<class coordtype >
typedef tCubeBase<coordtype>::PointBase chomp::homology::tCellBase< coordtype >::PointBase

The point base (for wrapping and tabulating coordinates).

Definition at line 81 of file cellbase.h.

Member Enumeration Documentation

◆ OutputBitValues

template<class coordtype >
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.

Enumerator
BitProduct 
BitSpace 

Definition at line 140 of file cellbase.h.

141 {
142 BitProduct = 0x01, // unset => two vertices
143 BitSpace = 0x02
144 };

Constructor & Destructor Documentation

◆ tCellBase() [1/7]

template<class coordtype >
chomp::homology::tCellBase< coordtype >::tCellBase
inline

The constructor of an empty cubical cell.

Definition at line 240 of file cellbase.h.

241: n1 (0), n2 (0)
242{
243 return;
244} /* tCellBase::tCellBase */
int_t n2
The right vertex: high 6 bits = cube dim, the remaining bits form the number of the point in an appro...
Definition: cellbase.h:171
int_t n1
The left vertex: high 6 bits = space dim, the remaining bits form the number of the point in an appro...
Definition: cellbase.h:167

◆ tCellBase() [2/7]

template<class coordtype >
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 247 of file cellbase.h.

249{
250 initialize (c1, c2, spcdim, celldim);
251 return;
252} /* tCellBase::tCellBase */
void initialize(const coordtype *c1, const coordtype *c2, int spcdim, int celldim=-1)
Initializes a new cell given its two corners.
Definition: cellbase.h:199

◆ tCellBase() [3/7]

template<class coordtype >
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 255 of file cellbase.h.

257{
258 // get the dimension of the space and check for consistency
259 int spcdim = q1. dim ();
260 if (spcdim != q2. dim ())
261 throw "Trying to intersect cubes of different dimension.";
262
263 // get the coordinates of minimal vertices of both cubes
264 coordtype c1 [MaxDim];
265 q1. coord (c1);
266 coordtype c2 [MaxDim];
267 q2. coord (c2);
268
269 // prepare tables for the new coordinates of the cubical cell
270 coordtype left [MaxDim];
271 coordtype right [MaxDim];
272
273 // compute the new coordinates of the cubical cell
274 int celldim = CommonCell (left, right, c1, c2, spcdim,
275 PointBase::getwrapping (spcdim));
276
277 // create the cell as computed
278 initialize (left, right, spcdim, celldim);
279
280 return;
281} /* tCellBase::tCellBase */
static const int MaxDim
The maximal dimension of a cell.
Definition: cellbase.h:75
int dim() const
Returns the dimension of the cubical cell.
Definition: cellbase.h:354
static const coordtype * getwrapping(int d)
Returns the space wrapping for the given dimension.
Definition: pointbas.h:299
int CommonCell(coordtype *left, coordtype *right, const coordtype *c1, const coordtype *c2, int spcdim, const coordtype *wrap=0)
Computes the left and right corner of a cell which is the intersection of the two given cubes.
Definition: cellmain.h:328

References chomp::homology::CommonCell(), and chomp::homology::tPointBase< coordtype >::getwrapping().

◆ tCellBase() [4/7]

template<class coordtype >
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 284 of file cellbase.h.

286: n1 (q. n)
287{
288 // check the dimensions
289 int spcdim = static_cast<int> (n1 >> NumBits);
290 if (facedim < 0)
291 throw "Negative dimension of a face requested.";
292 if (facedim > spcdim)
293 throw "Too high dimension of a face requested.";
294
295 // create the opposite corner of the cell
296 const coordtype *c1 = PointBase::coord (num1 (), spcdim);
297 coordtype c2 [MaxDim];
298 for (int i = 0; i < spcdim; ++ i)
299 c2 [i] = c1 [i] + ((i < facedim) ? 1 : 0);
300
301 // determine the number of the opposite corner and add cell dimension
302 n2 = PointBase::number (c2, spcdim) |
303 (static_cast<int_t> (facedim) << NumBits);
304 return;
305} /* tCellBase::tCellBase */
int_t num1() const
Returns the first number of the cubical cell vertices.
Definition: cellbase.h:187
static const coordtype * coord(int_t number, int d)
Retrieves the coordinates of the given point.
Definition: pointbas.h:183
static int_t number(const coordtype *c, int d)
Returns the number of the point with given coordinates.
Definition: pointbas.h:211
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115
const int NumBits
The number of bits in an integer number that remain to be used for other purposes,...
Definition: pointbas.h:71

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.

◆ tCellBase() [5/7]

template<class coordtype >
chomp::homology::tCellBase< coordtype >::tCellBase ( const tCubeBase< coordtype > &  q)
inlineexplicit

The constructor of a full-dimensional cubical cell.

Definition at line 308 of file cellbase.h.

309: n1 (q. n)
310{
311 // create the opposite corner of the cell
312 int spcdim = static_cast<int> (n1 >> NumBits);
313 const coordtype *c1 = PointBase::coord (num1 (), spcdim);
314 coordtype c2 [MaxDim];
315 for (int i = 0; i < spcdim; ++ i)
316 c2 [i] = c1 [i] + 1;
317
318 // determine the number of the opposite corner and add cell dimension
319 n2 = PointBase::number (c2, spcdim) |
320 (static_cast<int_t> (spcdim) << NumBits);
321 return;
322} /* tCellBase::tCellBase */

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.

◆ tCellBase() [6/7]

template<class coordtype >
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 325 of file cellbase.h.

327{
328 int spcdim = static_cast<int> (q. n1 >> NumBits);
329 if ((offset < 0) || (ncoords <= 0) || (offset + ncoords > spcdim))
330 throw "Wrong cell projection requested.";
331 const coordtype *c1 = PointBase::coord (q. n1 & NumMask, spcdim);
332 const coordtype *c2 = PointBase::coord (q. n2 & NumMask, spcdim);
333 initialize (c1 + offset, c2 + offset, ncoords);
334 return;
335} /* tCellBase::tCellBase */
const int_t NumMask
The mask of the bits remaining after the dimension bits are excluded.
Definition: pointbas.h:77

References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::NumBits, and chomp::homology::NumMask.

◆ tCellBase() [7/7]

template<class coordtype >
chomp::homology::tCellBase< coordtype >::tCellBase ( const tCellBase< coordtype > &  c)
inline

The copy constructor.

Definition at line 338 of file cellbase.h.

339: n1 (q. n1), n2 (q. n2)
340{
341 return;
342} /* tCellBase::tCellBase */

Member Function Documentation

◆ dim()

template<class coordtype >
int chomp::homology::tCellBase< coordtype >::dim
inline

Returns the dimension of the cubical cell.

Definition at line 354 of file cellbase.h.

355{
356 return static_cast<int> (n2 >> NumBits);
357} /* tCellBase::dim */

References chomp::homology::NumBits.

◆ hashkey1()

template<class coordtype >
int_t chomp::homology::tCellBase< coordtype >::hashkey1
inline

Returns hashing key no. 1 required by the hashing set template.

Definition at line 386 of file cellbase.h.

387{
388 return ((n1 ^ 0x55555555u) << 17) ^ ((n1 ^ 0xAAAAAAAAu) << 7) ^
389 ((n2 ^ 0xAAAAAAAAu) >> 7);
390} /* tCellBase::hashkey1 */

◆ hashkey2()

template<class coordtype >
int_t chomp::homology::tCellBase< coordtype >::hashkey2
inline

Return shashing key no. 2 required by the hashing set template.

Definition at line 399 of file cellbase.h.

400{
401 return ((n2 ^ 0xAAAAAAAAu) << 21) ^ ((n2 ^ 0x55555555u) << 10) ^
402 ((n1 ^ 0x55555555u) >> 9);
403} /* tCellBase::hashkey2 */

◆ initialize()

template<class coordtype >
void chomp::homology::tCellBase< coordtype >::initialize ( const coordtype *  c1,
const coordtype *  c2,
int  spcdim,
int  celldim = -1 
)
inlineprivate

Initializes a new cell given its two corners.

Definition at line 199 of file cellbase.h.

201{
202 // test the validity of the dimension
203 if (spcdim <= 0)
204 throw "Non-positive dimension of the space.";
205 else if (spcdim >= MaxDim)
206 throw "Too high dimension of a cell.";
207
208 // get the number of the left vertex
209 n1 = PointBase::number (c1, spcdim);
210 if (n1 < 0)
211 throw "Negative number of the left vertex.";
212
213 // get the number of the right vertex
214 n2 = PointBase::number (c2, spcdim);
215 if (n2 < 0)
216 throw "Negative number of the right vertex.";
217
218 // calculate the dimension of the cubical cell if it is unknown
219 if (celldim < 0)
220 {
221 celldim = 0;
222 c1 = PointBase::coord (n1, spcdim);
223 c2 = PointBase::coord (n2, spcdim);
224 for (int i = 0; i < spcdim; ++ i)
225 {
226 if (c2 [i] != c1 [i])
227 ++ celldim;
228 }
229 }
230
231 // add the space dimension and the cell dimension to the numbers
232 n1 |= (static_cast<int_t> (spcdim) << NumBits);
233 n2 |= (static_cast<int_t> (celldim) << NumBits);
234 return;
235} /* tCellBase::initialize */

References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tPointBase< coordtype >::number(), and chomp::homology::NumBits.

◆ leftcoord()

template<class coordtype >
coordtype * chomp::homology::tCellBase< coordtype >::leftcoord ( coordtype *  c) const
inline

Fills in the given table with the left corner coordinates.

Definition at line 366 of file cellbase.h.

367{
368 const coordtype *leftc = PointBase::coord (num1 (), spacedim ());
369 if (!c)
370 throw "Null pointer to save left coordinates.";
371 copycoord (c, leftc, spacedim ());
372 return c;
373} /* tCellBase::leftcoord */
int spacedim() const
Returns the dimension of the embedding space.
Definition: cellbase.h:360
void copycoord(coordtype *destination, const coordtype *source, int dim)
Copies the coordinates of one point to another.
Definition: pointset.h:108

References chomp::homology::tPointBase< coordtype >::coord(), and chomp::homology::copycoord().

◆ name()

template<class coordtype >
const char * chomp::homology::tCellBase< coordtype >::name
static

Returns the name of the objects represented by this class.

Definition at line 412 of file cellbase.h.

413{
414 return "cubical cell";
415} /* tCellBase::name */

◆ num1()

template<class coordtype >
int_t chomp::homology::tCellBase< coordtype >::num1
inlineprivate

Returns the first number of the cubical cell vertices.

Definition at line 187 of file cellbase.h.

188{
189 return (n1 & NumMask);
190} /* tCellBase::num1 */

References chomp::homology::NumMask.

Referenced by chomp::homology::tCellBase< coordtype >::tCellBase().

◆ num2()

template<class coordtype >
int_t chomp::homology::tCellBase< coordtype >::num2
inlineprivate

Returns the second number of the cubical cell vertices.

Definition at line 193 of file cellbase.h.

194{
195 return (n2 & NumMask);
196} /* tCellBase::num2 */

References chomp::homology::NumMask.

◆ operator=()

template<class coordtype >
tCellBase< coordtype > & chomp::homology::tCellBase< coordtype >::operator= ( const tCellBase< coordtype > &  c)
inline

The assignment operator.

Definition at line 345 of file cellbase.h.

347{
348 n1 = q. n1;
349 n2 = q. n2;
350 return *this;
351} /* tCellBase::operator = */

◆ pluralname()

template<class coordtype >
const char * chomp::homology::tCellBase< coordtype >::pluralname
static

Returns the plural name of the objects represented by this class.

Definition at line 418 of file cellbase.h.

419{
420 return "cubical cells";
421} /* tCellBase::pluralname */

◆ rightcoord()

template<class coordtype >
coordtype * chomp::homology::tCellBase< coordtype >::rightcoord ( coordtype *  c) const
inline

Fills in the given table with the right corner coordinates.

Definition at line 376 of file cellbase.h.

377{
378 const coordtype *rightc = PointBase::coord (num2 (), spacedim ());
379 if (!c)
380 throw "Null pointer to save right coordinates.";
381 copycoord (c, rightc, spacedim ());
382 return c;
383} /* tCellBase::rightcoord */
int_t num2() const
Returns the second number of the cubical cell vertices.
Definition: cellbase.h:193

References chomp::homology::tPointBase< coordtype >::coord(), and chomp::homology::copycoord().

◆ spacedim()

template<class coordtype >
int chomp::homology::tCellBase< coordtype >::spacedim
inline

Returns the dimension of the embedding space.

Definition at line 360 of file cellbase.h.

361{
362 return (n1 >> NumBits);
363} /* tCellBase::spacedim */

References chomp::homology::NumBits.

Friends And Related Function Documentation

◆ operator==

template<class coordtype >
int operator== ( const tCellBase< coordtype > &  c1,
const tCellBase< coordtype > &  c2 
)
friend

Verifies if two cells are identical.

Definition at line 152 of file cellbase.h.

154 {
155 return (c1. n1 == c2. n1) && (c1. n2 == c2. n2);
156 } /* operator == */

Member Data Documentation

◆ MaxDim

template<class coordtype >
const int chomp::homology::tCellBase< coordtype >::MaxDim = tCubeBase<coordtype>::MaxDim
static

The maximal dimension of a cell.

Definition at line 75 of file cellbase.h.

Referenced by chomp::homology::tCellBase< coordtype >::tCellBase().

◆ MaxSpaceDim

template<class coordtype >
const int chomp::homology::tCellBase< coordtype >::MaxSpaceDim = tCubeBase<coordtype>::MaxDim
static

The maximal dimension of the embedding space of a cell.

Definition at line 78 of file cellbase.h.

◆ n1

template<class coordtype >
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 167 of file cellbase.h.

Referenced by chomp::homology::tCellBase< coordtype >::tCellBase().

◆ n2

template<class coordtype >
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 171 of file cellbase.h.

Referenced by chomp::homology::tCellBase< coordtype >::tCellBase().

◆ OutputBits

template<class coordtype >
int chomp::homology::tCellBase< coordtype >::OutputBits = 0
static

The output bits which determine how a cell is written.

Definition at line 147 of file cellbase.h.


The documentation for this class was generated from the following file: