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

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>

List of all members.

Public Types

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

Public Member Functions

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

Private Member Functions

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

Private Attributes

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

Friends

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

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


Member Typedef Documentation

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

The type of a cell related to this cube type.

Definition at line 79 of file cubevar.h.

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

The type of coordinates of a cube.

Definition at line 76 of file cubevar.h.

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

The point base (for wrapping and tabulating coordinates).

Definition at line 85 of file cubevar.h.


Constructor & Destructor Documentation

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

The default constructor.

Definition at line 167 of file cubevar.h.

References chomp::homology::tCubeVar< coordtype >::tab.

{
        tab = NULL;
        return;
} /* tCubeVar::tCubeVar */

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

The constructor from a table of coordinates.

Definition at line 174 of file cubevar.h.

References chomp::homology::tCubeVar< coordtype >::initialize(), chomp::homology::tCubeVar< coordtype >::tab, and chomp::homology::tPointBase< coordtype >::wrapcopy().

{
        if (d < 0)
                throw "Negative dimension of a cube.";
        if (d)
                PointBase::wrapcopy (initialize (d), c, d);
        else
                tab = NULL;
        return;
} /* tCubeVar::tCubeVar */

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 186 of file cubevar.h.

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

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

The copy constructor.

Definition at line 192 of file cubevar.h.

References chomp::homology::copycoord(), chomp::homology::tCubeVar< coordtype >::dim(), chomp::homology::tCubeVar< coordtype >::initialize(), and chomp::homology::tCubeVar< coordtype >::tab.

{
        if (!c. dim ())
                tab = NULL;
        else
        {
                initialize (c. dim ());
                copycoord (tab + 1, c. tab + 1, c. dim ());
        }
        return;
} /* tCubeVar::tCubeVar */

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

The destructor.


Member Function Documentation

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 251 of file cubevar.h.

References chomp::homology::tCubeVar< coordtype >::tab.

{
        if (!tab)
                return 0;
        for (int i = 0; i < *tab; ++ i)
                c [i] = tab [i + 1];
        return c;
} /* tCubeVar::coord */

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

Returns the dimension of the cube.

Definition at line 234 of file cubevar.h.

References chomp::homology::tCubeVar< coordtype >::tab.

Referenced by chomp::homology::tCubeVar< coordtype >::hashkey1(), chomp::homology::tCubeVar< coordtype >::hashkey2(), and chomp::homology::tCubeVar< coordtype >::tCubeVar().

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

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

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

Definition at line 261 of file cubevar.h.

References chomp::homology::tCubeVar< coordtype >::dim(), and chomp::homology::tCubeVar< coordtype >::tab.

{
        int d = dim ();
        switch (d)
        {
        case 0:
                return 0;
        case 1:
                return static_cast<int_t> (tab [0]) << 12;
        case 2:
                return ((static_cast<int_t> (tab [0])) << 18) +
                        ((static_cast<int_t> (tab [1])) << 6);
        default:
                return ((static_cast<int_t> (tab [0])) << 18) +
                        ((static_cast<int_t> (tab [1])) << 6) +
                        ((static_cast<int_t> (tab [2])) >> 6);
        }
} /* tCubeVar::hashkey1 */

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

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

Definition at line 281 of file cubevar.h.

References chomp::homology::tCubeVar< coordtype >::dim(), and chomp::homology::tCubeVar< coordtype >::tab.

{
        int d = dim ();
        switch (d)
        {
        case 0:
                return 1;
        case 1:
                return static_cast<int_t> (tab [0]) << 3;
        case 2:
                return (static_cast<int_t> (tab [0]) >> 1) +
                        (static_cast<int_t> (tab [1]) << 13);
        default:
                return ((static_cast<int_t> (tab [d - 1])) << 20) +
                        ((static_cast<int_t> (tab [d - 2])) << 9) +
                        ((static_cast<int_t> (tab [d - 3])) >> 1);
        }
} /* tCubeVar::hashkey2 */

template<class coordtype >
coordtype * chomp::homology::tCubeVar< coordtype >::initialize ( int  dim  )  [inline, private]

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 155 of file cubevar.h.

References chomp::homology::tCubeVar< coordtype >::tab.

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

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

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

Returns the name of the objects represented by this class.

Definition at line 301 of file cubevar.h.

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

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

The assignment operator.

Definition at line 206 of file cubevar.h.

References chomp::homology::copycoord().

{
        if (dim () == c. dim ())
                copycoord (tab + 1, c. tab + 1, dim ());
        else
        {
                if (tab)
                        delete [] tab;
                if (c. dim ())
                {
                        initialize (c. dim ());
                        copycoord (tab + 1, c. tab + 1, c. dim ());
                }
                else
                        tab = NULL;
        }
        return *this;
} /* tCubeVar::operator = */

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

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

Definition at line 307 of file cubevar.h.

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


Friends And Related Function Documentation

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

The operator == for cubes.

Definition at line 128 of file cubevar.h.

        {
                if (!c1. tab)
                        return c2. tab ? false : true;
                if (!c2. tab)
                        return false;
                return thesame (c1. tab, c2. tab, c1. tab [0] + 1);
        } /* operator == */

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

Definition at line 139 of file cubevar.h.


Member Data Documentation

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

The maximal dimension of a cube.

Definition at line 82 of file cubevar.h.

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

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