This class defines a simplex as a geometric cell that can be used as a member of a geometric complex.
More...
#include <simplex.h>
|
static const char * | name () |
| The singular name of the objects represented by this class. More...
|
|
static const char * | pluralname () |
| The plural name of the objects represented by this class. More...
|
|
|
static const int | MaxDim = 2048 |
| The maximal dimension of a simplex. More...
|
|
|
int * | tab |
| The array that keeps the vertices of the simplex. More...
|
|
|
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. More...
|
|
std::ostream & | operator<< (std::ostream &out, const Simplex &s) |
| Writes a simplex to the output stream in the text format. More...
|
|
This class defines a simplex as a geometric cell that can be used as a member of a geometric complex.
Definition at line 77 of file simplex.h.
◆ Simplex() [1/4]
chomp::homology::Simplex::Simplex |
( |
| ) |
|
|
inline |
The default constructor of the empty simplex.
Definition at line 134 of file simplex.h.
135{
137 return;
138}
int * tab
The array that keeps the vertices of the simplex.
References tab.
◆ Simplex() [2/4]
chomp::homology::Simplex::Simplex |
( |
const int * |
v, |
|
|
int |
dim |
|
) |
| |
|
inline |
The constructor of a simplex from an array of its vertices.
Definition at line 173 of file simplex.h.
174{
175 if (d < 0)
176 throw "Negative dimension of a simplex.";
177 tab =
new int [d + 2];
179 throw "Not enough memory for a simplex.";
181 for (int i = 0; i <= d; ++ i)
183 return;
184}
References tab.
◆ Simplex() [3/4]
chomp::homology::Simplex::Simplex |
( |
const Simplex & |
s, |
|
|
int |
n |
|
) |
| |
|
inline |
The constructor of a boundary simplex.
Definition at line 186 of file simplex.h.
187{
188 int d = s.
dim () - 1;
189 if (d < 0)
190 throw "Undefined boundary simplex.";
191 tab =
new int [d + 2];
193 throw "Not enough memory for a boundary simplex.";
195 int i;
196 for (i = 1; i <= n; ++ i)
198 for (i = n + 1; i < d + 2; ++ i)
200 return;
201}
int dim() const
Returns the dimension of the simplex.
References dim(), and tab.
◆ ~Simplex()
chomp::homology::Simplex::~Simplex |
( |
| ) |
|
|
inline |
◆ Simplex() [4/4]
chomp::homology::Simplex::Simplex |
( |
const Simplex & |
s | ) |
|
|
inline |
The copy constructor.
Definition at line 203 of file simplex.h.
204{
206 if (d < 0)
208 else
209 {
210 tab =
new int [d + 2];
212 throw "Not enough memory to copy a simplex.";
213 for (int i = 0; i < d + 2; ++ i)
215 }
216 return;
217}
References dim(), and tab.
◆ dim()
int chomp::homology::Simplex::dim |
( |
| ) |
const |
|
inline |
◆ hashkey1()
int_t chomp::homology::Simplex::hashkey1 |
( |
| ) |
const |
|
inline |
The first hashing key required by the hashing set template.
Definition at line 246 of file simplex.h.
247{
249 if (d < 0)
250 return 0;
251 else if (d == 0)
252 return static_cast<int_t> (
tab [1]) << 2;
253 else if (d == 1)
254 {
255 return ((
static_cast<int_t> (
tab [1])
256 ^ 0x55555555u) << 16) ^
258 ^ 0xAAAA00AAu) << 4);
259 }
260 else
261 {
262 return ((
static_cast<int_t> (
tab [1]) ^
263 0x55555555u) << 16) ^
265 0xAA00AAAAu) << 4) ^
267 0xAA55AA55u) >> 6);
268 }
269}
int int_t
Index type for indexing arrays, counting cubes, etc.
References dim(), and tab.
◆ hashkey2()
int_t chomp::homology::Simplex::hashkey2 |
( |
| ) |
const |
|
inline |
The second hashing key required by the hashing set template.
Definition at line 276 of file simplex.h.
277{
279 if (d < 0)
280 return 0;
281 else if (d == 0)
282 return static_cast<int_t> (
tab [1]) << 2;
283 else if (d == 1)
284 {
285 return ((
static_cast<int_t> (
tab [1]) ^
286 0xAAAAAAAAu) >> 1) ^
288 0x55555555u) << 13);
289 }
290 else
291 {
292 return ((
static_cast<int_t> (
tab [d + 1]) ^
293 0x55555555u) << 13) ^
295 0xAA00AA00u) >> 1) ^
296 ((
static_cast<int_t> (
tab [d - 1]) ^
297 0xAA0055AAu) << 7);
298 }
299}
References dim(), and tab.
◆ name()
const char * chomp::homology::simplex::name |
( |
| ) |
|
|
inlinestatic |
The singular name of the objects represented by this class.
Definition at line 147 of file simplex.h.
148{
149 return "simplex";
150}
◆ operator=()
The assignment operator.
Definition at line 219 of file simplex.h.
220{
222 if (d < 0)
223 {
227 }
228 else if (d ==
dim ())
229 {
230 for (int i = 0; i < d + 2; ++ i)
232 }
233 else
234 {
237 tab =
new int [d + 2];
239 throw "Not enough memory to assign a simplex.";
240 for (int i = 0; i < d + 2; ++ i)
242 }
243 return *this;
244}
References dim(), and tab.
◆ pluralname()
const char * chomp::homology::simplex::pluralname |
( |
| ) |
|
|
inlinestatic |
The plural name of the objects represented by this class.
Definition at line 152 of file simplex.h.
153{
154 return "simplices";
155}
◆ vertices()
void chomp::homology::Simplex::vertices |
( |
int * |
table | ) |
const |
|
inline |
Retrieves the vertices of the simplex to the given array.
Definition at line 165 of file simplex.h.
166{
168 for (int i = 0; i <= d; ++ i)
169 table [i] =
tab [i + 1];
170 return;
171}
References dim(), and tab.
◆ operator<<
std::ostream & operator<< |
( |
std::ostream & |
out, |
|
|
const Simplex & |
s |
|
) |
| |
|
friend |
Writes a simplex to the output stream in the text format.
Definition at line 361 of file simplex.h.
362{
363 out << '(';
365 {
368 for (int i = 2; i < d + 2; ++ i)
369 out <<
',' << s.
tab [i];
370 }
371 out << ')';
372 return out;
373}
◆ operator==
The operator == that compares whether the two simplices are the same, that is, have the same vertices in the same order.
Definition at line 310 of file simplex.h.
311{
314 if (sd != td)
315 return 0;
316 for (int i = 1; i < sd + 2; ++ i)
317 if (s.
tab [i] != t.
tab [i])
318 return 0;
319 return 1;
320}
◆ MaxDim
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 82 of file simplex.h.
Referenced by chomp::homology::operator>>().
◆ tab
int* chomp::homology::Simplex::tab |
|
private |
The documentation for this class was generated from the following file: