This class defines a simplex as a geometric cell that can be used as a member of a geometric complex. More...
#include <simplex.h>
Public Member Functions | |
Simplex () | |
The default constructor of the empty simplex. | |
Simplex (const int *v, int dim) | |
The constructor of a simplex from an array of its vertices. | |
Simplex (const Simplex &s, int n) | |
The constructor of a boundary simplex. | |
~Simplex () | |
The destructor. | |
Simplex (const Simplex &s) | |
The copy constructor. | |
Simplex & | operator= (const Simplex &s) |
The assignment operator. | |
int | dim () const |
Returns the dimension of the simplex. | |
void | vertices (int *table) const |
Retrieves the vertices of the simplex to the given array. | |
int_t | hashkey1 () const |
The first hashing key required by the hashing set template. | |
int_t | hashkey2 () const |
The second hashing key required by the hashing set template. | |
Static Public Member Functions | |
static const char * | name () |
The singular name of the objects represented by this class. | |
static const char * | pluralname () |
The plural name of the objects represented by this class. | |
Static Public Attributes | |
static const int | MaxDim = 2048 |
The maximal dimension of a simplex. | |
Private Attributes | |
int * | tab |
The array that keeps the vertices of the simplex. | |
Friends | |
int | operator== (const Simplex &s, const Simplex &t) |
The operator == that compares whether the two simplices are the same, that is, have the same vertices in the same order. | |
std::ostream & | operator<< (std::ostream &out, const Simplex &s) |
Writes a simplex to the output stream in the text format. |
This class defines a simplex as a geometric cell that can be used as a member of a geometric complex.
Definition at line 78 of file simplex.h.
chomp::homology::Simplex::Simplex | ( | ) | [inline] |
chomp::homology::Simplex::Simplex | ( | const int * | v, | |
int | dim | |||
) | [inline] |
chomp::homology::Simplex::Simplex | ( | const Simplex & | s, | |
int | n | |||
) | [inline] |
The constructor of a boundary simplex.
Definition at line 187 of file simplex.h.
{ int d = s. dim () - 1; if (d < 0) throw "Undefined boundary simplex."; tab = new int [d + 2]; if (!tab) throw "Not enough memory for a boundary simplex."; tab [0] = d; int i; for (i = 1; i <= n; ++ i) tab [i] = s. tab [i]; for (i = n + 1; i < d + 2; ++ i) tab [i] = s. tab [i + 1]; return; } /* Simplex::Simplex */
chomp::homology::Simplex::~Simplex | ( | ) | [inline] |
chomp::homology::Simplex::Simplex | ( | const Simplex & | s | ) | [inline] |
int chomp::homology::Simplex::dim | ( | ) | const [inline] |
Returns the dimension of the simplex.
The empty simplex has the dimension of -1.
Definition at line 158 of file simplex.h.
References tab.
Referenced by hashkey1(), hashkey2(), operator=(), Simplex(), and vertices().
int_t chomp::homology::Simplex::hashkey1 | ( | ) | const [inline] |
The first hashing key required by the hashing set template.
Definition at line 247 of file simplex.h.
{ int d = dim (); if (d < 0) return 0; else if (d == 0) return static_cast<int_t> (tab [1]) << 2; else if (d == 1) { return ((static_cast<int_t> (tab [1]) ^ 0x55555555u) << 16) ^ ((static_cast<int_t> (tab [2]) ^ 0xAAAA00AAu) << 4); } else { return ((static_cast<int_t> (tab [1]) ^ 0x55555555u) << 16) ^ ((static_cast<int_t> (tab [2]) ^ 0xAA00AAAAu) << 4) ^ ((static_cast<int_t> (tab [3]) ^ 0xAA55AA55u) >> 6); } } /* Simplex::hashkey1 */
int_t chomp::homology::Simplex::hashkey2 | ( | ) | const [inline] |
The second hashing key required by the hashing set template.
Definition at line 272 of file simplex.h.
{ int d = dim (); if (d < 0) return 0; else if (d == 0) return static_cast<int_t> (tab [1]) << 2; else if (d == 1) { return ((static_cast<int_t> (tab [1]) ^ 0xAAAAAAAAu) >> 1) ^ ((static_cast<int_t> (tab [2]) ^ 0x55555555u) << 13); } else { return ((static_cast<int_t> (tab [d + 1]) ^ 0x55555555u) << 13) ^ ((static_cast<int_t> (tab [d]) ^ 0xAA00AA00u) >> 1) ^ ((static_cast<int_t> (tab [d - 1]) ^ 0xAA0055AAu) << 7); } } /* Simplex::hashkey2 */
const char * chomp::homology::simplex::name | ( | ) | [inline, static] |
The assignment operator.
Definition at line 220 of file simplex.h.
{ int d = s. dim (); if (d < 0) { if (tab) delete [] tab; tab = NULL; } else if (d == dim ()) { for (int i = 0; i < d + 2; ++ i) tab [i] = s. tab [i]; } else { if (tab) delete [] tab; tab = new int [d + 2]; if (!tab) throw "Not enough memory to assign a simplex."; for (int i = 0; i < d + 2; ++ i) tab [i] = s. tab [i]; } return *this; } /* Simplex::operator = */
const char * chomp::homology::simplex::pluralname | ( | ) | [inline, static] |
void chomp::homology::Simplex::vertices | ( | int * | table | ) | const [inline] |
std::ostream& operator<< | ( | std::ostream & | out, | |
const Simplex & | s | |||
) | [friend] |
The operator == that compares whether the two simplices are the same, that is, have the same vertices in the same order.
const int chomp::homology::Simplex::MaxDim = 2048 [static] |
The maximal dimension of a simplex.
Note that practically the maximal dimension in use should not exceed 20 or so.
Definition at line 83 of file simplex.h.
Referenced by chomp::homology::operator>>().
int* chomp::homology::Simplex::tab [private] |
The array that keeps the vertices of the simplex.
The first entry contains the dimension of the simplex.
Definition at line 129 of file simplex.h.
Referenced by dim(), hashkey1(), hashkey2(), operator=(), Simplex(), vertices(), and ~Simplex().