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

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>

List of all members.

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

Public Member Functions

 tCellFix ()
 The constructor of an empty cubical cell.
 tCellFix (const coordtype *c1, const coordtype *c2, int spcdim=0, int celldim=-1)
 The constructor of a cell spanning from one point to another.
 tCellFix (const tCubeFix< dimfix, coordtype > &q1, const tCubeFix< dimfix, coordtype > &q2)
 The constructor of a cell as an intersection of two cubes.
 tCellFix (const tCubeFix< dimfix, coordtype > &q, int facedim)
 The constructor of an arbitrary k-dimensional face of a full cube.
 tCellFix (const tCubeFix< dimfix, coordtype > &q)
 The constructor of a full-dimensional cubical cell.
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.
 tCellFix (const tCellFix< dimfix, coordtype > &c)
 The copy constructor.
tCellFix< dimfix, coordtype > & operator= (const tCellFix< dimfix, coordtype > &c)
 The assignment operator.
int dim () const
 Returns the dimension of the cubical cell.
int spacedim () const
 Returns the dimension of the embedding space.
coordtype * leftcoord (coordtype *c) const
 Fills in the given table with the left corner coordinates.
coordtype * rightcoord (coordtype *c) const
 Fills in the given table with the right corner 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
 The maximal dimension of a cell.
static const int MaxSpaceDim = dimfix
 The maximal dimension of the embedding space of a cell.
static int OutputBits = 0
 The output bits which determine how a cell is written.

Private Member Functions

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

Private Attributes

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

Friends

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

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 69 of file cellfix.h.


Member Typedef Documentation

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

The type of the coordinates.

Definition at line 73 of file cellfix.h.

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 84 of file cellfix.h.


Member Enumeration Documentation

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 145 of file cellfix.h.

        {
                BitProduct = 0x01,      // unset => two vertices
                BitSpace = 0x02
        };


Constructor & Destructor Documentation

template<int dimfix, class coordtype >
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix (  )  [inline]

The constructor of an empty cubical cell.

Definition at line 232 of file cellfix.h.

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

:n (0)
{
        if (dimfix > MaxDim)
                throw "Too high fixed-dim cell dimension.";
        return;
} /* tCellFix::tCellFix */

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 242 of file cellfix.h.

{
        // test the validity of the dimension
        if (spcdim < 0)
                throw "Negative dimension of the space.";
        else if ((spcdim > 0) && (spcdim != dimfix))
                throw "Wrong dimension of a cell.";
        if (dimfix > MaxDim)
                throw "Too high fixed-dim cell dimension.";

        // initialize the cell
        initialize (c1, c2, celldim);
        return;
} /* tCellFix::tCellFix */

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 259 of file cellfix.h.

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

{
        if (dimfix > MaxDim)
                throw "Too high fixed-dim cell dimension.";

        // get the coordinates of minimal vertices of both cubes
        coordtype c1 [dimfix];
        q1. coord (c1);
        coordtype c2 [dimfix];
        q2. coord (c2);

        // prepare tables for the new coordinates of the cubical cell
        coordinate left [dimfix];
        coordinate right [dimfix];

        // compute the new coordinates of the cubical cell
        int celldim = CommonCell (left, right, c1, c2, dimfix,
                PointBase::getwrapping (dimfix));
        
        // create the cell as computed
        initialize (left, right, celldim);

        return;
} /* tCellFix::tCellFix */

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 287 of file cellfix.h.

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

{
        if (facedim < 0)
                throw "Negative dimension of a face requested.";
        if (facedim > dimfix)
                throw "Too high dimension of a face requested.";
        if (dimfix > MaxDim)
                throw "Too high fixed-dim cell dimension.";
        copycoord (tab, q. tab, dimfix);
        n = static_cast<int_t> (facedim) << NumBits;
        for (int i = 0; i < facedim; ++ i)
                n |= static_cast<int_t> (1) << i;
        return;
} /* tCellFix::tCellFix */

template<int dimfix, class coordtype >
chomp::homology::tCellFix< dimfix, coordtype >::tCellFix ( const tCubeFix< dimfix, coordtype > &  q  )  [inline, explicit]

The constructor of a full-dimensional cubical cell.

Definition at line 304 of file cellfix.h.

References chomp::homology::copycoord().

: n ((static_cast<int_t> (dimfix) << NumBits) | NumMask)
{
        if (dimfix > MaxDim)
                throw "Too high fixed-dim cell dimension.";
        copycoord (tab, q. tab, dimfix);
        return;
} /* tCellFix::tCellFix */

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 316 of file cellfix.h.

{
        if ((offset < 0) || (ncoords <= 0) || (ncoords != dimfix) ||
                (offset + ncoords > dimhigh))
                throw "Wrong cell projection requested.";
        // note: the following can be done in a slightly more efficient way,
        // without creating the right coordinates and calling "initialize"
        coordtype right [dimhigh];
        q. rightcoord (right);
        initialize (q. tab + offset, right + offset);
        return;
} /* tCellFix::tCellFix */

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

The copy constructor.

Definition at line 331 of file cellfix.h.

References chomp::homology::copycoord().

: n (q. n)
{
        copycoord (tab, q. tab, dimfix);
        return;
} /* tCellFix::tCellFix */


Member Function Documentation

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

Returns the dimension of the cubical cell.

Definition at line 348 of file cellfix.h.

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

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

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

template<int dimfix, class coordtype >
int_t chomp::homology::tCellFix< dimfix, coordtype >::hashkey1 (  )  const [inline]

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

Definition at line 384 of file cellfix.h.

References chomp::homology::tCellFix< dimfix, coordtype >::n, and chomp::homology::tCellFix< dimfix, coordtype >::tab.

{
        switch (dimfix)
        {
        case 1:
                return (static_cast<int_t> (tab [0]) << 12) ^ n;
        case 2:
                return (((static_cast<int_t> (tab [0])) << 18) +
                        ((static_cast<int_t> (tab [1])) << 6)) ^ n;
        default:
                return (((static_cast<int_t> (tab [0])) << 18) +
                        ((static_cast<int_t> (tab [1])) << 6) +
                        ((static_cast<int_t> (tab [2])) >> 6)) ^ n;
        }
} /* tCellFix::hashkey1 */

template<int dimfix, class coordtype >
int_t chomp::homology::tCellFix< dimfix, coordtype >::hashkey2 (  )  const [inline]

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

Definition at line 401 of file cellfix.h.

References chomp::homology::tCellFix< dimfix, coordtype >::n, and chomp::homology::tCellFix< dimfix, coordtype >::tab.

{
        switch (dimfix)
        {
        case 1:
                return (static_cast<int_t> (tab [0]) << 3) ^ (n << 5);
        case 2:
                return ((static_cast<int_t> (tab [0]) >> 1) +
                        (static_cast<int_t> (tab [1]) << 13)) ^ (n << 5);
        default:
                return (((static_cast<int_t> (tab [dimfix - 1])) << 20) +
                        ((static_cast<int_t> (tab [dimfix - 2])) << 9) +
                        ((static_cast<int_t> (tab [dimfix - 3])) >> 1)) ^
                        (n << 5);
        }
} /* tCellFix::hashkey2 */

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

Initializes a new cell, given its two corners.

Definition at line 189 of file cellfix.h.

References chomp::homology::tCellFix< dimfix, coordtype >::dim(), chomp::homology::tCellFix< dimfix, coordtype >::n, chomp::homology::NumBits, chomp::homology::tCellFix< dimfix, coordtype >::tab, and chomp::homology::tPointBase< coordtype >::wrapcopy().

{
        // copy the left corner coordinates to the cell
        PointBase::wrapcopy (tab, c1, dimfix);

        // prepare wrapped right coordinates for the detection of cell bits
        coordtype r [dimfix];
        PointBase::wrapcopy (r, c2, dimfix);

        // if the dimension of the cell is known, then compute the bits only
        if (celldim >= 0)
        {
                n = static_cast<int_t> (celldim) << NumBits;
                if (!celldim)
                        return;
                for (int i = 0; i < dimfix; ++ i)
                {
                        if (tab [i] != r [i])
                                n |= (static_cast<int_t> (1) << i);
                }
                return;
        }

        // set the bits of the cell and compute its actual dimension
        n = 0;
        int dim = 0;
        for (int i = 0; i < dimfix; ++ i)
        {
                if (tab [i] != r [i])
                {
                        n |= (static_cast<int_t> (1) << i);
                        ++ dim;
                }
        }
        n |= static_cast<int_t> (dim) << NumBits;

        return;
} /* tCellFix::initialize */

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 360 of file cellfix.h.

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

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

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 419 of file cellfix.h.

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

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 340 of file cellfix.h.

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

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 425 of file cellfix.h.

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

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 370 of file cellfix.h.

References chomp::homology::tCellFix< dimfix, coordtype >::n, chomp::homology::tCellFix< dimfix, coordtype >::spacedim(), chomp::homology::tCellFix< dimfix, coordtype >::tab, and chomp::homology::tPointBase< coordtype >::wrapcoord().

{
        if (!c)
                throw "Null pointer to save right coordinates.";
        for (int i = 0; i < dimfix; ++ i)
        {
                c [i] = tab [i] +
                        ((n & (static_cast<int_t> (1) << i)) ? 1 : 0);
        }
        PointBase::wrapcoord (c, spacedim ());
        return c;
} /* tCellFix::rightcoord */

template<int dimfix, class coordtype >
int chomp::homology::tCellFix< dimfix, coordtype >::spacedim (  )  const [inline]

Returns the dimension of the embedding space.

Definition at line 354 of file cellfix.h.

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

{
        return dimfix;
} /* tCellFix::spacedim */


Friends And Related Function Documentation

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 159 of file cellfix.h.

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


Member Data Documentation

template<int dimfix, class coordtype>
const int chomp::homology::tCellFix< dimfix, coordtype >::MaxDim [static]
Initial value:
                (tCubeFix<dimfix,coordtype>::MaxDim < MaxBasDim) ?
                tCubeFix<dimfix,coordtype>::MaxDim : MaxBasDim

The maximal dimension of a cell.

Definition at line 76 of file cellfix.h.

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

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 81 of file cellfix.h.

template<int dimfix, class coordtype>
int_t chomp::homology::tCellFix< dimfix, coordtype >::n [private]
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 152 of file cellfix.h.

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

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