X-Git-Url: https://git.sthu.org/?p=libstick.git;a=blobdiff_plain;f=include%2Flibstick-0.1%2Fsimplicialcomplex.h;h=47a88c64907cb29054cb6d22d78c49df9e0bb08b;hp=07080ed76a23617e2c87b99ca7aa3dc998640b2f;hb=88ea14f1e9079c9b8c4af7aff01a3fe960e9472b;hpb=929c696bfb48aa0f96ce2b70b1b926b5f2b2dede diff --git a/include/libstick-0.1/simplicialcomplex.h b/include/libstick-0.1/simplicialcomplex.h index 07080ed..47a88c6 100644 --- a/include/libstick-0.1/simplicialcomplex.h +++ b/include/libstick-0.1/simplicialcomplex.h @@ -18,17 +18,17 @@ namespace libstick { /** A simplicial complex is a std::vector of simplices such that each face is * also part of the complex. Every simplex has dimension at most MAXDIM. The * indices of simplices resp. their faces are of type IT. To each simplex a - * value is assigend, which is of type VT. When a SimplicialComplex is + * value is assigend, which is of type VT. When a simplicial_complex is * instantiated, a single (-1) dimensional simplex is automatically created. * Each 0-dimensional simplex automatically has this simplex as its face. - * Consequently, the innner class SimplexOrder gives the extended boundary + * Consequently, the innner class simplex_order gives the extended boundary * matrix. */ template -class SimplicialComplex { +class simplicial_complex { public: /** The type of this class. */ - typedef SimplicialComplex simplcompltype; + typedef simplicial_complex simplcompltype; /** Type of indices of simplices. */ typedef IT index_type; /** To every simplex a function value is assigned according to which a @@ -55,7 +55,7 @@ class SimplicialComplex { s.value = value; if (dim > 0) - memcpy(s.faces, faces, faceCountByDim(dim)*sizeof(index_type)); + memcpy(s.faces, faces, face_count_bydim(dim)*sizeof(index_type)); else s.faces[0] = 0; @@ -76,12 +76,12 @@ class SimplicialComplex { } /** Get number of faces. */ - size_t faceCount() const { - return faceCountByDim(dim); + size_t face_count() const { + return face_count_bydim(dim); } /** Get number of faces of a dim-dimensional simplex. */ - static size_t faceCountByDim(int dim) { + static size_t face_count_bydim(int dim) { assert(-1 <= dim && dim <= MAXDIM); return dim + 1; } @@ -89,13 +89,13 @@ class SimplicialComplex { /** An order of the simplices of complex c. An order can be interpreted * as a permuation of the complex's std::vector of simplices. */ - class SimplexOrder { + class simplex_order { public: - typedef BooleanColRowMatrix BoundaryMatrix; + typedef boolean_colrowmatrix boundary_matrix; /** Create a standard order of the complex c, i.e., the identity permutation. */ - SimplexOrder(const simplcompltype &c) : + simplex_order(const simplcompltype &c) : c(c) { reset(); @@ -116,63 +116,63 @@ class SimplicialComplex { } /** Get i-th simplex in the simplex order. */ - const Simplex& getSimplex(size_t i) const { + const Simplex& get_simplex(size_t i) const { assert(i < size()); return c.simplices[order.at(i)]; } /** Returns true iff the faces of simplex i are before i in this order. */ - bool isFiltration() const { + bool is_filtration() const { assert(size() == c.size()); for (unsigned i=0; i < size(); ++i) - for (unsigned f=0; f < getSimplex(i).faceCount(); ++f) - if (revorder[getSimplex(i).faces[f]] >= i) + for (unsigned f=0; f < get_simplex(i).face_count(); ++f) + if (revorder[get_simplex(i).faces[f]] >= i) return false; return true; } - /** Returns true iff isFiltration() gives true and values of simplices + /** Returns true iff is_filtration() gives true and values of simplices * are monotone w.r.t. this order of simplices. */ - bool isMonotone() const { + bool is_monotone() const { assert(size() == c.size()); for (unsigned i=1; i < size(); ++i) - if (getSimplex(i-1).value > getSimplex(i).value) + if (get_simplex(i-1).value > get_simplex(i).value) return false; - return isFiltration(); + return is_filtration(); } - /** Sort simplices such that isMonotone() gives true. This - * requires that the complex's isMonotone() gave true + /** Sort simplices such that is_monotone() gives true. This + * requires that the complex's is_monotone() gave true * beforehand.*/ - void makeMonotoneFiltration() { - assert(c.isMonotone()); + void make_monotone_filtration() { + assert(c.is_monotone()); - sort(order.begin(), order.end(), cmpMonotoneFiltration(c)); - restoreRevorderFromOrder(); + sort(order.begin(), order.end(), cmp_monotone_filtration(c)); + restore_revorder_from_order(); - assert(c.isMonotone()); - assert(isFiltration()); - assert(isMonotone()); + assert(c.is_monotone()); + assert(is_filtration()); + assert(is_monotone()); } /** Get the boundary matrix of the complex according to this order. */ - BoundaryMatrix getBoundaryMatrix() const { - BoundaryMatrix mat(size()); + boundary_matrix get_boundary_matrix() const { + boundary_matrix mat(size()); for (unsigned c=0; c < size(); ++c) - for(unsigned r=0; r < getSimplex(c).faceCount(); ++r) - mat.set(revorder[getSimplex(c).faces[r]], c, true); + for(unsigned r=0; r < get_simplex(c).face_count(); ++r) + mat.set(revorder[get_simplex(c).faces[r]], c, true); return mat; } private: /** Reconstruct 'revorder' by inverting the permutation given by 'order'. */ - void restoreRevorderFromOrder() { + void restore_revorder_from_order() { // Make revorder * order the identity permutation for (unsigned i=0; i < size(); ++i) revorder[order[i]] = i; @@ -193,9 +193,9 @@ class SimplicialComplex { }; public: - SimplicialComplex() { + simplicial_complex() { // Add the one minus-one dimensional simplex - addSimplex(Simplex::create_minusonedim_simplex()); + add_simplex(Simplex::create_minusonedim_simplex()); } /** Return number of simplices. */ @@ -205,15 +205,15 @@ class SimplicialComplex { /** Add a simplex to the complex. The dimension of the faces must be * dim-1, and they must already be part of the complex. */ - void addSimplex(int dim, index_type* faces, value_type value) { - addSimplex(Simplex::create(dim, faces, value)); + void add_simplex(int dim, index_type* faces, value_type value) { + add_simplex(Simplex::create(dim, faces, value)); } /** Add a simplex to the complex. The dimension of the faces must be * dim-1, and they must already be part of the complex. */ - void addSimplex(Simplex s) { + void add_simplex(Simplex s) { // Check requirements for faces - for (unsigned i=0; i < s.faceCount(); ++i) { + for (unsigned i=0; i < s.face_count(); ++i) { // Faces are already in complex. assert(s.faces[i] < size()); // Faces have dimension dim-1 @@ -225,11 +225,11 @@ class SimplicialComplex { /** Return true iff for each simplex i with dimension dim it holds that * the faces of i are contained in the complex and have dimension dim-1. */ - bool isComplex() const { + bool is_complex() const { for (unsigned i=0; i < size(); ++i) { const Simplex &s = simplices[i]; - for (unsigned f=0; f < s.faceCount(); ++f) { + for (unsigned f=0; f < s.face_count(); ++f) { if (s.faces[f] >= size()) return false; @@ -244,13 +244,13 @@ class SimplicialComplex { /** Returns true iff simplex's values are monotone w.r.t. * face-inclusion, i.e., for each simplex its value is not smaller than - * the values of its faces. Requires that isComplex() gives true. */ - bool isMonotone() const { - assert(isComplex()); + * the values of its faces. Requires that is_complex() gives true. */ + bool is_monotone() const { + assert(is_complex()); typename std::vector::const_iterator it = ++simplices.begin(); for (; it != simplices.end(); ++it) - for (unsigned f=0; f < it->faceCount(); ++f) + for (unsigned f=0; f < it->face_count(); ++f) if (simplices[it->faces[f]].value > it->value) return false; @@ -259,12 +259,12 @@ class SimplicialComplex { private: /** Compares (operator<) two simplices (i.e. indices) in a - * SimplexOrder w.r.t. lexicographical order on (value, + * simplex_order w.r.t. lexicographical order on (value, * dimension)-tuples. */ - struct cmpMonotoneFiltration { - const SimplicialComplex &c; + struct cmp_monotone_filtration { + const simplicial_complex &c; - cmpMonotoneFiltration(const SimplicialComplex &c) : + cmp_monotone_filtration(const simplicial_complex &c) : c(c){ }