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

Public Member Functions

 tCellFix ()
 The constructor of an empty cubical cell. More...
 
 tCellFix (const coordtype *c1, const coordtype *c2, int spcdim=0, int celldim=-1)
 The constructor of a cell spanning from one point to another. More...
 
 tCellFix (const tCubeFix< dimfix, coordtype > &q1, const tCubeFix< dimfix, coordtype > &q2)
 The constructor of a cell as an intersection of two cubes. More...
 
 tCellFix (const tCubeFix< dimfix, coordtype > &q, int facedim)
 The constructor of an arbitrary k-dimensional face of a full cube. More...
 
 tCellFix (const tCubeFix< dimfix, coordtype > &q)
 The constructor of a full-dimensional cubical cell. More...
 
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. More...
 
 tCellFix (const tCellFix< dimfix, coordtype > &c)
 The copy constructor. More...
 
tCellFix< dimfix, coordtype > & operator= (const tCellFix< dimfix, 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
 Returns hashing 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
 The maximal dimension of a cell. More...
 
static const int MaxSpaceDim = dimfix
 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

void initialize (const coordtype *c1, const coordtype *c2, int celldim=-1)
 Initializes a new cell, given its two corners. More...
 

Private Attributes

coordtype tab [dimfix]
 A table with the left coordinate of the cell. More...
 
int_t n
 High 6 bits = the dimension of the cell (not: space). More...
 

Friends

template<int _dimfix, class _coordtype >
int operator== (const tCellFix< _dimfix, _coordtype > &c1, const tCellFix< _dimfix, _coordtype > &c2)
 Verifies if two cells are identical. More...
 

Detailed Description

template<int dimfix, class coordtype>
class chomp::homology::tCellFix< dimfix, 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 assumes that the embedding space dimension is known at time of compilation.

Definition at line 68 of file cellfix.h.

Member Typedef Documentation

◆ CoordType

template<int dimfix, class coordtype >
typedef coordtype chomp::homology::tCellFix< dimfix, coordtype >::CoordType

The type of the coordinates.

Definition at line 72 of file cellfix.h.

◆ PointBase

template<int dimfix, class coordtype >
typedef tCubeFix<dimfix,coordtype>::PointBase chomp::homology::tCellFix< dimfix, coordtype >::PointBase

The point base (for wrapping and tabulating coordinates).

Definition at line 83 of file cellfix.h.

Member Enumeration Documentation

◆ OutputBitValues

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

Enumerator
BitProduct 
BitSpace 

Definition at line 144 of file cellfix.h.

145 {
146 BitProduct = 0x01, // unset => two vertices
147 BitSpace = 0x02
148 };

Constructor & Destructor Documentation

◆ tCellFix() [1/7]

template<int dimfix, class coordtype >
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix
inline

The constructor of an empty cubical cell.

Definition at line 231 of file cellfix.h.

232:n (0)
233{
234 if (dimfix > MaxDim)
235 throw "Too high fixed-dim cell dimension.";
236 return;
237} /* tCellFix::tCellFix */
static const int MaxDim
The maximal dimension of a cell.
Definition: cellfix.h:75
int_t n
High 6 bits = the dimension of the cell (not: space).
Definition: cellfix.h:172

References chomp::homology::tCellFix< dimfix, coordtype >::MaxDim.

◆ tCellFix() [2/7]

template<int dimfix, class coordtype >
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 240 of file cellfix.h.

242{
243 // test the validity of the dimension
244 if (spcdim < 0)
245 throw "Negative dimension of the space.";
246 else if ((spcdim > 0) && (spcdim != dimfix))
247 throw "Wrong dimension of a cell.";
248 if (dimfix > MaxDim)
249 throw "Too high fixed-dim cell dimension.";
250
251 // initialize the cell
252 initialize (c1, c2, celldim);
253 return;
254} /* tCellFix::tCellFix */
void initialize(const coordtype *c1, const coordtype *c2, int celldim=-1)
Initializes a new cell, given its two corners.
Definition: cellfix.h:188

◆ tCellFix() [3/7]

template<int dimfix, class coordtype >
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 257 of file cellfix.h.

260{
261 if (dimfix > MaxDim)
262 throw "Too high fixed-dim cell dimension.";
263
264 // get the coordinates of minimal vertices of both cubes
265 coordtype c1 [dimfix];
266 q1. coord (c1);
267 coordtype c2 [dimfix];
268 q2. coord (c2);
269
270 // prepare tables for the new coordinates of the cubical cell
271 coordinate left [dimfix];
272 coordinate right [dimfix];
273
274 // compute the new coordinates of the cubical cell
275 int celldim = CommonCell (left, right, c1, c2, dimfix,
276 PointBase::getwrapping (dimfix));
277
278 // create the cell as computed
279 initialize (left, right, celldim);
280
281 return;
282} /* tCellFix::tCellFix */
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
short int coordinate
The default type of coordinates.
Definition: pointset.h:63

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

◆ tCellFix() [4/7]

template<int dimfix, class coordtype >
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 285 of file cellfix.h.

287{
288 if (facedim < 0)
289 throw "Negative dimension of a face requested.";
290 if (facedim > dimfix)
291 throw "Too high dimension of a face requested.";
292 if (dimfix > MaxDim)
293 throw "Too high fixed-dim cell dimension.";
294 copycoord (tab, q. tab, dimfix);
295 n = static_cast<int_t> (facedim) << NumBits;
296 for (int i = 0; i < facedim; ++ i)
297 n |= static_cast<int_t> (1) << i;
298 return;
299} /* tCellFix::tCellFix */
coordtype tab[dimfix]
A table with the left coordinate of the cell.
Definition: cellfix.h:167
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
void copycoord(coordtype *destination, const coordtype *source, int dim)
Copies the coordinates of one point to another.
Definition: pointset.h:108

References chomp::homology::copycoord(), and chomp::homology::NumBits.

◆ tCellFix() [5/7]

template<int dimfix, class coordtype >
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix ( const tCubeFix< dimfix, coordtype > &  q)
inlineexplicit

The constructor of a full-dimensional cubical cell.

Definition at line 302 of file cellfix.h.

304: n ((static_cast<int_t> (dimfix) << NumBits) | NumMask)
305{
306 if (dimfix > MaxDim)
307 throw "Too high fixed-dim cell dimension.";
308 copycoord (tab, q. tab, dimfix);
309 return;
310} /* tCellFix::tCellFix */
const int_t NumMask
The mask of the bits remaining after the dimension bits are excluded.
Definition: pointbas.h:77

References chomp::homology::copycoord(), chomp::homology::tCellFix< dimfix, coordtype >::MaxDim, and chomp::homology::tCellFix< dimfix, coordtype >::tab.

◆ tCellFix() [6/7]

template<int dimfix, class coordtype >
template<int dimhigh>
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 314 of file cellfix.h.

316{
317 if ((offset < 0) || (ncoords <= 0) || (ncoords != dimfix) ||
318 (offset + ncoords > dimhigh))
319 throw "Wrong cell projection requested.";
320 // note: the following can be done in a slightly more efficient way,
321 // without creating the right coordinates and calling "initialize"
322 coordtype right [dimhigh];
323 q. rightcoord (right);
324 initialize (q. tab + offset, right + offset);
325 return;
326} /* tCellFix::tCellFix */
coordtype * rightcoord(coordtype *c) const
Fills in the given table with the right corner coordinates.
Definition: cellfix.h:369

◆ tCellFix() [7/7]

template<int dimfix, class coordtype >
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix ( const tCellFix< dimfix, coordtype > &  c)
inline

The copy constructor.

Definition at line 329 of file cellfix.h.

331: n (q. n)
332{
333 copycoord (tab, q. tab, dimfix);
334 return;
335} /* tCellFix::tCellFix */

References chomp::homology::copycoord(), and chomp::homology::tCellFix< dimfix, coordtype >::tab.

Member Function Documentation

◆ dim()

template<int dimfix, class coordtype >
int chomp::homology::tCellFix< dimfix, coordtype >::dim
inline

Returns the dimension of the cubical cell.

Definition at line 347 of file cellfix.h.

348{
349 return static_cast<int> (n >> NumBits);
350} /* tCellFix::dim */

References chomp::homology::NumBits.

◆ hashkey1()

template<int dimfix, class coordtype >
int_t chomp::homology::tCellFix< dimfix, coordtype >::hashkey1
inline

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

Definition at line 383 of file cellfix.h.

384{
385 switch (dimfix)
386 {
387 case 1:
388 return (static_cast<int_t> (tab [0]) << 12) ^ n;
389 case 2:
390 return (((static_cast<int_t> (tab [0])) << 18) +
391 ((static_cast<int_t> (tab [1])) << 6)) ^ n;
392 default:
393 return (((static_cast<int_t> (tab [0])) << 18) +
394 ((static_cast<int_t> (tab [1])) << 6) +
395 ((static_cast<int_t> (tab [2])) >> 6)) ^ n;
396 }
397} /* tCellFix::hashkey1 */

◆ hashkey2()

template<int dimfix, class coordtype >
int_t chomp::homology::tCellFix< dimfix, coordtype >::hashkey2
inline

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

Definition at line 406 of file cellfix.h.

407{
408 switch (dimfix)
409 {
410 case 1:
411 return (static_cast<int_t> (tab [0]) << 3) ^ (n << 5);
412 case 2:
413 return ((static_cast<int_t> (tab [0]) >> 1) +
414 (static_cast<int_t> (tab [1]) << 13)) ^ (n << 5);
415 default:
416 return (((static_cast<int_t> (tab [dimfix - 1])) << 20) +
417 ((static_cast<int_t> (tab [dimfix - 2])) << 9) +
418 ((static_cast<int_t> (tab [dimfix - 3])) >> 1)) ^
419 (n << 5);
420 }
421} /* tCellFix::hashkey2 */

◆ initialize()

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

Initializes a new cell, given its two corners.

Definition at line 188 of file cellfix.h.

190{
191 // copy the left corner coordinates to the cell
192 PointBase::wrapcopy (tab, c1, dimfix);
193
194 // prepare wrapped right coordinates for the detection of cell bits
195 coordtype r [dimfix];
196 PointBase::wrapcopy (r, c2, dimfix);
197
198 // if the dimension of the cell is known, then compute the bits only
199 if (celldim >= 0)
200 {
201 n = static_cast<int_t> (celldim) << NumBits;
202 if (!celldim)
203 return;
204 for (int i = 0; i < dimfix; ++ i)
205 {
206 if (tab [i] != r [i])
207 n |= (static_cast<int_t> (1) << i);
208 }
209 return;
210 }
211
212 // set the bits of the cell and compute its actual dimension
213 n = 0;
214 int dim = 0;
215 for (int i = 0; i < dimfix; ++ i)
216 {
217 if (tab [i] != r [i])
218 {
219 n |= (static_cast<int_t> (1) << i);
220 ++ dim;
221 }
222 }
223 n |= static_cast<int_t> (dim) << NumBits;
224
225 return;
226} /* tCellFix::initialize */
int dim() const
Returns the dimension of the cubical cell.
Definition: cellfix.h:347
static void wrapcopy(coordtype *dest, const coordtype *src, int dim)
Copies the coordinates and wraps them if necessary.
Definition: pointbas.h:322

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

◆ leftcoord()

template<int dimfix, class coordtype >
coordtype * chomp::homology::tCellFix< dimfix, coordtype >::leftcoord ( coordtype *  c) const
inline

Fills in the given table with the left corner coordinates.

Definition at line 359 of file cellfix.h.

360{
361 if (!c)
362 throw "Null pointer to save left coordinates.";
363 for (int i = 0; i < dimfix; ++ i)
364 c [i] = tab [i];
365 return c;
366} /* tCellFix::leftcoord */

◆ name()

template<int dimfix, class coordtype >
const char * chomp::homology::tCellFix< dimfix, coordtype >::name
static

Returns the name of the objects represented by this class.

Definition at line 430 of file cellfix.h.

431{
432 return "cubical cell";
433} /* tCellFix::name */

◆ operator=()

template<int dimfix, class coordtype >
tCellFix< dimfix, coordtype > & chomp::homology::tCellFix< dimfix, coordtype >::operator= ( const tCellFix< dimfix, coordtype > &  c)
inline

The assignment operator.

Definition at line 338 of file cellfix.h.

340{
341 memcpy (tab, q. tab, dimfix * sizeof (coordtype));
342 n = q. n;
343 return *this;
344} /* tCellFix::operator = */

◆ pluralname()

template<int dimfix, class coordtype >
const char * chomp::homology::tCellFix< dimfix, coordtype >::pluralname
static

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

Definition at line 436 of file cellfix.h.

437{
438 return "cubical cells";
439} /* tCellFix::pluralname */

◆ rightcoord()

template<int dimfix, class coordtype >
coordtype * chomp::homology::tCellFix< dimfix, coordtype >::rightcoord ( coordtype *  c) const
inline

Fills in the given table with the right corner coordinates.

Definition at line 369 of file cellfix.h.

370{
371 if (!c)
372 throw "Null pointer to save right coordinates.";
373 for (int i = 0; i < dimfix; ++ i)
374 {
375 c [i] = tab [i] +
376 ((n & (static_cast<int_t> (1) << i)) ? 1 : 0);
377 }
379 return c;
380} /* tCellFix::rightcoord */
int spacedim() const
Returns the dimension of the embedding space.
Definition: cellfix.h:353
static void wrapcoord(coordtype *c, int dim)
Wraps the given coordinates if necessary.
Definition: pointbas.h:311

References chomp::homology::tPointBase< coordtype >::wrapcoord().

◆ spacedim()

template<int dimfix, class coordtype >
int chomp::homology::tCellFix< dimfix, coordtype >::spacedim
inline

Returns the dimension of the embedding space.

Definition at line 353 of file cellfix.h.

354{
355 return dimfix;
356} /* tCellFix::spacedim */

Friends And Related Function Documentation

◆ operator==

template<int dimfix, class coordtype >
template<int _dimfix, class _coordtype >
int operator== ( const tCellFix< _dimfix, _coordtype > &  c1,
const tCellFix< _dimfix, _coordtype > &  c2 
)
friend

Verifies if two cells are identical.

Definition at line 157 of file cellfix.h.

160 {
161 return ((c1. n == c2. n) && (!memcmp (c1. tab, c2. tab,
162 dimfix * sizeof (coordtype))));
163 } /* operator == */

Member Data Documentation

◆ MaxDim

template<int dimfix, class coordtype >
const int chomp::homology::tCellFix< dimfix, coordtype >::MaxDim
static
Initial value:
=
static const int MaxDim
The maximal dimension of a cube (unused).
Definition: cubefix.h:81
const int MaxBasDim
The maximal dimension that can be used if the high bits of an integer store the value of the dimensio...
Definition: pointbas.h:89

The maximal dimension of a cell.

Definition at line 75 of file cellfix.h.

Referenced by chomp::homology::tCellFix< dimfix, coordtype >::tCellFix().

◆ MaxSpaceDim

template<int dimfix, class coordtype >
const int chomp::homology::tCellFix< dimfix, coordtype >::MaxSpaceDim = dimfix
static

The maximal dimension of the embedding space of a cell.

Definition at line 80 of file cellfix.h.

◆ n

template<int dimfix, class coordtype >
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 172 of file cellfix.h.

◆ OutputBits

template<int dimfix, class coordtype >
int chomp::homology::tCellFix< dimfix, coordtype >::OutputBits = 0
static

The output bits which determine how a cell is written.

Definition at line 151 of file cellfix.h.

◆ tab

template<int dimfix, class coordtype >
coordtype chomp::homology::tCellFix< dimfix, coordtype >::tab[dimfix]
private

A table with the left coordinate of the cell.

Definition at line 167 of file cellfix.h.

Referenced by chomp::homology::tCellFix< dimfix, coordtype >::tCellFix().


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