Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends

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>

List of all members.

Public Types

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

Public Member Functions

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

Private Member Functions

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

Private Attributes

int_t n
 The number that represents the full cube.

Friends

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

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 72 of file cubebase.h.


Member Typedef Documentation

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

The type of a cell related to this cube type.

Definition at line 79 of file cubebase.h.

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

The type of coordinates of a cube.

Definition at line 76 of file cubebase.h.

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

The point base (for wrapping and tabulating coordinates).

Definition at line 85 of file cubebase.h.


Constructor & Destructor Documentation

template<class coordtype >
chomp::homology::tCubeBase< coordtype >::tCubeBase (  )  [inline]

The default constructor.

Definition at line 158 of file cubebase.h.

: n (0)
{
        return;
} /* tCubeBase::tCubeBase */

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 165 of file cubebase.h.

References chomp::homology::tCubeBase< coordtype >::MaxDim, chomp::homology::tCubeBase< coordtype >::n, chomp::homology::tPointBase< coordtype >::number(), and chomp::homology::NumBits.

{
        if (dim <= 0)
                throw "Non-positive dimension of a cube.";
        if (dim >= MaxDim)
                throw "Too high space dimension.";
        n = PointBase::number (c, dim);
        if (n < 0)
                throw "Negative number of a cube.";
        n |= (static_cast<int_t> (dim) << NumBits);
        return;
} /* tCubeBase::tCubeBase */

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 180 of file cubebase.h.

References chomp::homology::tCubeBase< coordtype >::n, and chomp::homology::NumBits.

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

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

The copy constructor.

Definition at line 187 of file cubebase.h.

References chomp::homology::tCubeBase< coordtype >::n.

{
        n = c. n;
        return;
} /* tCubeBase::tCubeBase */


Member Function Documentation

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 219 of file cubebase.h.

References chomp::homology::tPointBase< coordtype >::coord(), chomp::homology::tCubeBase< coordtype >::dim(), and chomp::homology::tCubeBase< coordtype >::num().

{
        int d = dim ();
        const coordtype *tab = PointBase::coord (num (), d);
        for (int i = 0; i < d; ++ i)
                c [i] = tab [i];
        return c;
} /* tCubeBase::coord */

template<class coordtype >
int chomp::homology::tCubeBase< coordtype >::dim (  )  const [inline]

Returns the dimension of the cube.

Definition at line 202 of file cubebase.h.

References chomp::homology::tCubeBase< coordtype >::n, and chomp::homology::NumBits.

Referenced by chomp::homology::tCubeBase< coordtype >::coord().

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

template<class coordtype >
int_t chomp::homology::tCubeBase< coordtype >::hashkey1 (  )  const [inline]

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

Definition at line 229 of file cubebase.h.

References chomp::homology::tCubeBase< coordtype >::n.

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

template<class coordtype >
int_t chomp::homology::tCubeBase< coordtype >::hashkey2 (  )  const [inline]

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

Definition at line 237 of file cubebase.h.

References chomp::homology::tCubeBase< coordtype >::n.

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

template<class coordtype >
const char * chomp::homology::tCubeBase< coordtype >::name (  )  [inline, static]

Returns the name of the objects represented by this class.

Definition at line 245 of file cubebase.h.

{
        return "cube";
} /* tCubeBase::name */

template<class coordtype >
int_t chomp::homology::tCubeBase< coordtype >::num (  )  const [inline, private]

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

Definition at line 150 of file cubebase.h.

References chomp::homology::tCubeBase< coordtype >::n, and chomp::homology::NumMask.

Referenced by chomp::homology::tCubeBase< coordtype >::coord().

{
        return (n & NumMask);
} /* tCubeBase::num */

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

The assignment operator.

Definition at line 195 of file cubebase.h.

{
        n = c. n;
        return *this;
} /* tCubeBase::operator = */

template<class coordtype >
const char * chomp::homology::tCubeBase< coordtype >::pluralname (  )  [inline, static]

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

Definition at line 251 of file cubebase.h.

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

{
        return "cubes";
} /* tCubeBase::pluralname */


Friends And Related Function Documentation

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

The operator == for cubes.

Definition at line 127 of file cubebase.h.

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

template<class coordtype>
friend class tCellBase< coordtype > [friend]

Definition at line 134 of file cubebase.h.


Member Data Documentation

template<class coordtype>
const int chomp::homology::tCubeBase< coordtype >::MaxDim = MaxBasDim [static]
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 143 of file cubebase.h.

Referenced by chomp::homology::tCubeBase< coordtype >::dim(), chomp::homology::tCubeBase< coordtype >::hashkey1(), chomp::homology::tCubeBase< coordtype >::hashkey2(), chomp::homology::tCubeBase< coordtype >::num(), and chomp::homology::tCubeBase< coordtype >::tCubeBase().


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