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::tCubeBase< coordtype > Class Template Reference

This class defines a hypercube in R^n with edges parallel to the axes and with size 1 in each direction. More...

#include <cubebase.h>

Public Types

typedef coordtype CoordType
 The type of coordinates of a cube. More...
 
typedef tCellBase< coordtype > CellType
 The type of a cell related to this cube type. More...
 
typedef tPointBase< coordtype > PointBase
 The point base (for wrapping and tabulating coordinates). More...
 

Public Member Functions

 tCubeBase ()
 The default constructor. More...
 
 tCubeBase (const coordtype *c, int dim)
 The constructor of a cube from a table of coordinates. More...
 
 tCubeBase (int_t number, int dim)
 The constructor of a cube from a number (should be used with caution). More...
 
 tCubeBase (const tCubeBase< coordtype > &c)
 The copy constructor. More...
 
tCubeBase< coordtype > & operator= (const tCubeBase< coordtype > &c)
 The assignment operator. More...
 
int dim () const
 Returns the dimension of the cube. More...
 
coordtype * coord (coordtype *c) const
 Fills out the coordinate table with the cube's 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 = MaxBasDim
 The maximal dimension of a cube. More...
 

Private Member Functions

int_t num () const
 Returns the actual number of the cube in the point base. More...
 

Private Attributes

int_t n
 The number that represents the full cube. More...
 

Friends

class tCellBase< coordtype >
 
int operator== (const tCubeBase< coordtype > &c1, const tCubeBase< coordtype > &c2)
 The operator == for cubes. More...
 

Detailed Description

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

This class defines a hypercube in R^n with edges parallel to the axes and with size 1 in each direction.

This implementation uses a cube base class for indexing all the possible coordinate combinations that appear in the program.

Definition at line 71 of file cubebase.h.

Member Typedef Documentation

◆ CellType

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

The type of a cell related to this cube type.

Definition at line 78 of file cubebase.h.

◆ CoordType

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

The type of coordinates of a cube.

Definition at line 75 of file cubebase.h.

◆ PointBase

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

The point base (for wrapping and tabulating coordinates).

Definition at line 84 of file cubebase.h.

Constructor & Destructor Documentation

◆ tCubeBase() [1/4]

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

The default constructor.

Definition at line 157 of file cubebase.h.

158: n (0)
159{
160 return;
161} /* tCubeBase::tCubeBase */
int_t n
The number that represents the full cube.
Definition: cubebase.h:142

◆ tCubeBase() [2/4]

template<class coordtype >
chomp::homology::tCubeBase< coordtype >::tCubeBase ( const coordtype *  c,
int  dim 
)
inline

The constructor of a cube from a table of coordinates.

Definition at line 164 of file cubebase.h.

166{
167 if (dim <= 0)
168 throw "Non-positive dimension of a cube.";
169 if (dim >= MaxDim)
170 throw "Too high space dimension.";
171 n = PointBase::number (c, dim);
172 if (n < 0)
173 throw "Negative number of a cube.";
174 n |= (static_cast<int_t> (dim) << NumBits);
175 return;
176} /* tCubeBase::tCubeBase */
static const int MaxDim
The maximal dimension of a cube.
Definition: cubebase.h:81
int dim() const
Returns the dimension of the cube.
Definition: cubebase.h:201
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 >::number(), and chomp::homology::NumBits.

◆ tCubeBase() [3/4]

template<class coordtype >
chomp::homology::tCubeBase< coordtype >::tCubeBase ( int_t  number,
int  dim 
)
inline

The constructor of a cube from a number (should be used with caution).

Definition at line 179 of file cubebase.h.

180{
181 n = number | (static_cast<int_t> (dim) << NumBits);
182 return;
183} /* tCubeBase::tCubeBase */

References chomp::homology::NumBits.

◆ tCubeBase() [4/4]

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

The copy constructor.

Definition at line 186 of file cubebase.h.

187{
188 n = c. n;
189 return;
190} /* tCubeBase::tCubeBase */

Member Function Documentation

◆ coord()

template<class coordtype >
coordtype * chomp::homology::tCubeBase< coordtype >::coord ( coordtype *  c) const
inline

Fills out the coordinate table with the cube's coordinates.

Definition at line 218 of file cubebase.h.

219{
220 int d = dim ();
221 const coordtype *tab = PointBase::coord (num (), d);
222 for (int i = 0; i < d; ++ i)
223 c [i] = tab [i];
224 return c;
225} /* tCubeBase::coord */
int_t num() const
Returns the actual number of the cube in the point base.
Definition: cubebase.h:149
static const coordtype * coord(int_t number, int d)
Retrieves the coordinates of the given point.
Definition: pointbas.h:183

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

◆ dim()

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

Returns the dimension of the cube.

Definition at line 201 of file cubebase.h.

202{
203 return static_cast<int> (n >> NumBits);
204} /* tCubeBase::dim */

References chomp::homology::NumBits.

◆ hashkey1()

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

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

Definition at line 228 of file cubebase.h.

229{
230 return static_cast<int_t>
231 (((n ^ 0x55555555u) << 17) ^ ((n ^ 0xAA00AA00u) << 7) ^
232 ((n ^ 0x00AA00AAu) >> 7));
233} /* tCubeBase::hashkey1 */

◆ hashkey2()

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

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

Definition at line 242 of file cubebase.h.

243{
244 return static_cast<int_t>
245 (((n ^ 0xAAAAAAAAu) << 18) ^ ((n ^ 0x55005500u) >> 8) ^
246 ((n ^ 0x00550055u) << 10));
247} /* tCubeBase::hashkey2 */

◆ name()

template<class coordtype >
const char * chomp::homology::tCubeBase< coordtype >::name
inlinestatic

Returns the name of the objects represented by this class.

Definition at line 256 of file cubebase.h.

257{
258 return "cube";
259} /* tCubeBase::name */

◆ num()

template<class coordtype >
int_t chomp::homology::tCubeBase< coordtype >::num
inlineprivate

Returns the actual number of the cube in the point base.

Definition at line 149 of file cubebase.h.

150{
151 return (n & NumMask);
152} /* tCubeBase::num */
const int_t NumMask
The mask of the bits remaining after the dimension bits are excluded.
Definition: pointbas.h:77

References chomp::homology::NumMask.

◆ operator=()

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

The assignment operator.

Definition at line 193 of file cubebase.h.

195{
196 n = c. n;
197 return *this;
198} /* tCubeBase::operator = */

◆ pluralname()

template<class coordtype >
const char * chomp::homology::tCubeBase< coordtype >::pluralname
inlinestatic

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

Definition at line 262 of file cubebase.h.

263{
264 return "cubes";
265} /* tCubeBase::pluralname */

Referenced by chomp::homology::readelements(), and chomp::homology::saveelements().

Friends And Related Function Documentation

◆ operator==

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

The operator == for cubes.

Definition at line 126 of file cubebase.h.

128 {
129 return c1. n == c2. n;
130 } /* operator == */

◆ tCellBase< coordtype >

template<class coordtype >
friend class tCellBase< coordtype >
friend

Definition at line 126 of file cubebase.h.

Member Data Documentation

◆ MaxDim

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

The maximal dimension of a cube.

Definition at line 81 of file cubebase.h.

Referenced by chomp::homology::ComputeBettiNumbers(), chomp::homengin::PPengine::dimsupported(), and chomp::homology::SetSpaceWrapping().

◆ n

template<class coordtype >
int_t chomp::homology::tCubeBase< coordtype >::n
private

The number that represents the full cube.

High bits keep the space dimension, the remaining bits form the number of the cube in an appropriate pointset.

Definition at line 142 of file cubebase.h.


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