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::tCubeVar< 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 <cubevar.h>

Public Types

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

Public Member Functions

 tCubeVar ()
 The default constructor. More...
 
 tCubeVar (const coordtype *c, int dim)
 The constructor from a table of coordinates. More...
 
 tCubeVar (int number, int dim)
 The constructor from a number (invalid in this class). More...
 
 tCubeVar (const tCubeVar< coordtype > &c)
 The copy constructor. More...
 
tCubeVar< coordtype > & operator= (const tCubeVar< coordtype > &c)
 The assignment operator. More...
 
 ~tCubeVar ()
 The destructor. 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 = 50
 The maximal dimension of a cube. More...
 

Private Member Functions

coordtype * initialize (int dim)
 Initializes the data for a cube of a given dimension > 0. More...
 

Private Attributes

coordtype * tab
 The table containing the coordinates of the cube, as well as its dimension (at tab [0]). More...
 

Friends

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

Detailed Description

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

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

In this implementation, an array is allocated for the coordinates of the minimal vertex of a cube.

Definition at line 71 of file cubevar.h.

Member Typedef Documentation

◆ CellType

template<class coordtype >
typedef tCellVar<coordtype> chomp::homology::tCubeVar< coordtype >::CellType

The type of a cell related to this cube type.

Definition at line 78 of file cubevar.h.

◆ CoordType

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

The type of coordinates of a cube.

Definition at line 75 of file cubevar.h.

◆ PointBase

template<class coordtype >
typedef tWrapBase<coordtype> chomp::homology::tCubeVar< coordtype >::PointBase

The point base (for wrapping and tabulating coordinates).

Definition at line 84 of file cubevar.h.

Constructor & Destructor Documentation

◆ tCubeVar() [1/4]

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

The default constructor.

Definition at line 166 of file cubevar.h.

167{
168 tab = NULL;
169 return;
170} /* tCubeVar::tCubeVar */
coordtype * tab
The table containing the coordinates of the cube, as well as its dimension (at tab [0]).
Definition: cubevar.h:143

◆ tCubeVar() [2/4]

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

The constructor from a table of coordinates.

Definition at line 173 of file cubevar.h.

174{
175 if (d < 0)
176 throw "Negative dimension of a cube.";
177 if (d)
179 else
180 tab = NULL;
181 return;
182} /* tCubeVar::tCubeVar */
coordtype * initialize(int dim)
Initializes the data for a cube of a given dimension > 0.
Definition: cubevar.h:154
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::tPointBase< coordtype >::wrapcopy().

◆ tCubeVar() [3/4]

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

The constructor from a number (invalid in this class).

Definition at line 185 of file cubevar.h.

186{
187 throw "Unable to construct a cube from a number.";
188} /* tCubeVar::tCubeVar */

◆ tCubeVar() [4/4]

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

The copy constructor.

Definition at line 191 of file cubevar.h.

192{
193 if (!c. dim ())
194 tab = NULL;
195 else
196 {
197 initialize (c. dim ());
198 copycoord (tab + 1, c. tab + 1, c. dim ());
199 }
200 return;
201} /* tCubeVar::tCubeVar */
int dim() const
Returns the dimension of the cube.
Definition: cubevar.h:233
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().

◆ ~tCubeVar()

template<class coordtype >
chomp::homology::tCubeVar< coordtype >::~tCubeVar< coordtype >
inline

The destructor.

Definition at line 204 of file cubevar.h.

226{
227 if (tab)
228 delete [] tab;
229 return;
230} /* tCubeVar::~tCubeVar */

Member Function Documentation

◆ coord()

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

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

Definition at line 250 of file cubevar.h.

251{
252 if (!tab)
253 return 0;
254 for (int i = 0; i < *tab; ++ i)
255 c [i] = tab [i + 1];
256 return c;
257} /* tCubeVar::coord */

◆ dim()

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

Returns the dimension of the cube.

Definition at line 233 of file cubevar.h.

234{
235 return tab ? *tab : 0;
236} /* tCubeVar::dim */

◆ hashkey1()

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

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

Definition at line 260 of file cubevar.h.

261{
262 int d = dim ();
263 switch (d)
264 {
265 case 0:
266 return 0;
267 case 1:
268 return static_cast<int_t> (tab [0]) << 12;
269 case 2:
270 return ((static_cast<int_t> (tab [0])) << 18) +
271 ((static_cast<int_t> (tab [1])) << 6);
272 default:
273 return ((static_cast<int_t> (tab [0])) << 18) +
274 ((static_cast<int_t> (tab [1])) << 6) +
275 ((static_cast<int_t> (tab [2])) >> 6);
276 }
277} /* tCubeVar::hashkey1 */
int int_t
Index type for indexing arrays, counting cubes, etc.
Definition: config.h:115

◆ hashkey2()

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

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

Definition at line 286 of file cubevar.h.

287{
288 int d = dim ();
289 switch (d)
290 {
291 case 0:
292 return 1;
293 case 1:
294 return static_cast<int_t> (tab [0]) << 3;
295 case 2:
296 return (static_cast<int_t> (tab [0]) >> 1) +
297 (static_cast<int_t> (tab [1]) << 13);
298 default:
299 return ((static_cast<int_t> (tab [d - 1])) << 20) +
300 ((static_cast<int_t> (tab [d - 2])) << 9) +
301 ((static_cast<int_t> (tab [d - 3])) >> 1);
302 }
303} /* tCubeVar::hashkey2 */

◆ initialize()

template<class coordtype >
coordtype * chomp::homology::tCubeVar< coordtype >::initialize ( int  dim)
inlineprivate

Initializes the data for a cube of a given dimension > 0.

Returns the pointer to the coordinates table (i.e. tab + 1).

Definition at line 154 of file cubevar.h.

155{
156 tab = new coordtype [d + 1];
157 if (!tab)
158 throw "Not enough memory for a cube.";
159 *tab = d;
160 return (tab + 1);
161} /* tCubeVar::initialize */

◆ name()

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

Returns the name of the objects represented by this class.

Definition at line 312 of file cubevar.h.

313{
314 return "cube";
315} /* tCubeVar::name */

◆ operator=()

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

The assignment operator.

Definition at line 204 of file cubevar.h.

206{
207 if (dim () == c. dim ())
208 copycoord (tab + 1, c. tab + 1, dim ());
209 else
210 {
211 if (tab)
212 delete [] tab;
213 if (c. dim ())
214 {
215 initialize (c. dim ());
216 copycoord (tab + 1, c. tab + 1, c. dim ());
217 }
218 else
219 tab = NULL;
220 }
221 return *this;
222} /* tCubeVar::operator = */

References chomp::homology::copycoord().

◆ pluralname()

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

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

Definition at line 318 of file cubevar.h.

319{
320 return "cubes";
321} /* tCubeVar::pluralname */

Friends And Related Function Documentation

◆ operator==

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

The operator == for cubes.

Definition at line 127 of file cubevar.h.

129 {
130 if (!c1. tab)
131 return c2. tab ? false : true;
132 if (!c2. tab)
133 return false;
134 return thesame (c1. tab, c2. tab, c1. tab [0] + 1);
135 } /* operator == */
int thesame(const coordtype *c1, const coordtype *c2, int dim)
Compare two points. Returns true iff they have the same coordinates.
Definition: pointset.h:98

◆ tCellVar< coordtype >

template<class coordtype >
friend class tCellVar< coordtype >
friend

Definition at line 127 of file cubevar.h.

Member Data Documentation

◆ MaxDim

template<class coordtype >
const int chomp::homology::tCubeVar< coordtype >::MaxDim = 50
static

The maximal dimension of a cube.

Definition at line 81 of file cubevar.h.

◆ tab

template<class coordtype >
coordtype* chomp::homology::tCubeVar< coordtype >::tab
private

The table containing the coordinates of the cube, as well as its dimension (at tab [0]).

Definition at line 143 of file cubevar.h.


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