28 #ifndef _CHAINCON_SIMPLEX_H_ 29 #define _CHAINCON_SIMPLEX_H_ 39 #include "chomp/system/config.h" 58 template <
class VertexT,
class EmptyT>
72 template <
class VertexArray>
126 template <
class VertexT,
class EmptyT>
133 template <
class VertexT,
class EmptyT>
134 template <
class VertexArray>
141 if (vertices [i + 1] < vertices [i])
142 throw "Wrong order of vertices of a simplex.";
146 this -> dimension = (dimension >= 0) ? dimension : -1;
147 this -> vertices = (dimension >= 0) ?
new VertexT [dimension + 1] : 0;
151 this -> vertices [i] = vertices [i];
155 template <
class VertexT,
class EmptyT>
165 template <
class VertexT,
class EmptyT>
173 for (
int i = 0; i < n; ++ i)
182 for (
int i = 0; i < -n; ++ i)
190 template <
class VertexT,
class EmptyT>
207 template <
class VertexT,
class EmptyT>
215 template <
class VertexT,
class EmptyT>
221 template <
class VertexT,
class EmptyT>
227 template <
class VertexT,
class EmptyT>
230 if (EmptyT::exists ())
236 template <
class VertexT,
class EmptyT>
239 return (n & 1) ? -1 : 1;
242 template <
class VertexT,
class EmptyT>
253 template <
class VertexT,
class EmptyT>
254 inline bool tSimplex<VertexT,EmptyT>::operator ==
267 template <
class VertexT,
class EmptyT>
280 template <
class VertexT,
class EmptyT>
292 return ((
hashkey1 (s [0]) & 0x655555u) << 11) ^
293 ((
hashkey1 (s [1]) & 0xAA00AAu) >> 1);
297 return ((
hashkey1 (s [0]) & 0x655555u) << 15) ^
298 ((
hashkey1 (s [d >> 1]) & 0xAA00AAu) << 1) ^
299 ((
hashkey1 (s [d]) & 0xAAAAAAu) >> 7);
306 template <
class VertexT,
class EmptyT>
318 return ((
hashkey2 (s [0]) & 0xAAAAAAu) >> 2) ^
319 ((
hashkey2 (s [1]) & 0x555555u) << 8);
323 return ((
hashkey2 (s [d]) & 0x555555u) << 7) ^
324 ((
hashkey2 (s [0]) & 0xAA00AAu) << 5) ^
325 ((
hashkey2 (s [d >> 1]) & 0xAAAAu) >> 5);
334 template <
class VertexT,
class EmptyT>
335 std::ostream &operator << (std::ostream &out, const tSimplex<VertexT,EmptyT> &s)
339 for (
int i = 0; i <=
dim; ++ i)
356 template <
class VertexT,
class EmptyT>
360 chomp::homology::ignorecomments (in);
370 while ((ch != EOF) && (ch !=
')'))
374 vertices. push_back (vertex);
375 while ((in. peek () ==
' ') || (in. peek () ==
','))
377 if (in. peek () ==
')')
381 throw "Simplex reading error: ')' expected.\n";
384 for (
unsigned i = 1; i < vertices. size (); ++ i)
386 if (vertices [i - 1] >= vertices [i])
387 throw "Simplex reading error: wrong vertices.\n";
397 #endif // _CHAINCON_SIMPLEX_H_ int boundaryCoef(int n) const
Returns the n-th coefficient in the boundary of the simplex.
EmptyT EmptyType
The type of the empty cell existence decision class.
A simplex with vertices of arbitrary type.
bool operator==(const tSimplex< VertexT, EmptyT > &s) const
The equality operator.
int dim() const
Returns the dimension of the simplex.
~tSimplex()
The destructor.
VertexT * vertices
An array of vertices of the simplex.
std::istream & operator>>(std::istream &in, tSimplex< VertexT, EmptyT > &s)
Reads a simplex from the input stream in the text format.
int degenerate() const
Checks if the simplex is degenerate, that is, if it has two identical vertices one after another...
int_t hashkey2(const tSimplex< VertexT, EmptyT > &s)
Generates a hashing key no.
The decision on whether the empty cell should be used as a valid cell of dimension -1...
int boundaryLength() const
Returns the length of the boundary of the simplex.
tSimplex()
The default constructor of an empty simplex.
int dimension
The dimension of the simplex.
int_t hashkey1(const tSimplex< VertexT, EmptyT > &s)
Generates a hashing key no.
VertexT VertexType
The type of the vertex.
void swap(tSimplex< VertexT, EmptyT > &s)
Swaps the data between two simplices.
const VertexT & operator[](int n) const
Returns the n-th vertex of the simplex.