Coding style cleanup
authorStefan Huber <shuber@sthu.org>
Mon, 11 Nov 2013 12:51:37 +0000 (13:51 +0100)
committerStefan Huber <shuber@sthu.org>
Mon, 11 Nov 2013 20:13:36 +0000 (21:13 +0100)
include/libstick-0.1/booleanmatrix.h
include/libstick-0.1/matrixreduction.h
include/libstick-0.1/simplicialcomplex.h
tests/booleanmatrix.h
tests/main.cc
tests/simplicialcomplex.h

index 894892f0f3f4a0fc7e38d118a609f4a2701b8a3c..774aeb73095c6abb2738d49d9f6d8ad63f88ddbc 100644 (file)
 namespace libstick {
 
 
-/** The base class of BooleanColMatrix and BooleanColRowMatrix which implements
+/** The base class of boolean_colmatrix and boolean_colrowmatrix which implements
  * the common logic of both. */
 template<class IT, class D>
-class BooleanColMatrix_base {
+class boolean_colmatrix_base {
 
     public:
         typedef IT index_type;
@@ -26,7 +26,7 @@ class BooleanColMatrix_base {
         typedef D derived;
 
         /** Create a matrix with 'width' columns, initalized with zero entries. */
-        BooleanColMatrix_base(size_t width) :
+        boolean_colmatrix_base(size_t width) :
             cols(width) {
         }
 
@@ -38,24 +38,24 @@ class BooleanColMatrix_base {
         /** Get the matrix entry at row 'r' and column 'c'. */
         bool get(index_type r, index_type c) const {
             assert(c < width());
-            const column_type &col = getColumn(c);
+            const column_type &col = get_column(c);
             return binary_search(col.begin(), col.end(), r);
         }
 
         /** Set the matrix entry at row 'r' and column 'c'. */
         void set(index_type r, index_type c, bool value) {
-            getDerived()->_set(r, c, value);
+            get_derived()->_set(r, c, value);
         }
 
         /** Get the c-th column. */
-        const column_type& getColumn(index_type c) const {
+        const column_type& get_column(index_type c) const {
             assert(c < width());
             return cols[c];
         }
 
         /** Add the column-vector 'col' to the c-th column. Note that 'col'
          * actually contains the list of row-indices that are 1. */
-        void addColumn(index_type c, const column_type &col) {
+        void add_column(index_type c, const column_type &col) {
             assert(c < width());
 
             // Flip all entries that are set in 'col'.
@@ -64,18 +64,16 @@ class BooleanColMatrix_base {
         }
 
         /** Two matrices are equal iff they have the same entries */
-        bool operator==(const BooleanColMatrix_base<IT, D> &m) const {
+        bool operator==(const boolean_colmatrix_base<IT, D> &m) const {
             return cols == m.cols;
         }
 
         /** Two matrices are equal iff they have the same entries */
-        bool operator!=(const BooleanColMatrix_base<IT, D> &m) const {
+        bool operator!=(const boolean_colmatrix_base<IT, D> &m) const {
             return !(*this == m);
         }
 
     protected:
-
-
         /** Set the matrix entry at row 'r' and column 'c'. */
         void _set(index_type r, index_type c, bool value) {
             assert(c < width());
@@ -112,7 +110,7 @@ class BooleanColMatrix_base {
         std::vector<column_type> cols;
 
         /** A cast to the derived type */
-        derived* getDerived() {
+        derived* get_derived() {
             return static_cast<derived*>(this);
         }
 };
@@ -122,14 +120,14 @@ class BooleanColMatrix_base {
  * column-vector we save the row-indices of the 1s. It is designed to handle a
  * few 1s and column-wise operations well. */
 template<class IT=uint32_t>
-class BooleanColMatrix : public BooleanColMatrix_base<IT, BooleanColMatrix<IT> > {
+class boolean_colmatrix : public boolean_colmatrix_base<IT, boolean_colmatrix<IT> > {
 
     public:
         typedef IT index_type;
-        typedef BooleanColMatrix_base<IT, BooleanColMatrix<IT> > base;
+        typedef boolean_colmatrix_base<IT, boolean_colmatrix<IT> > base;
 
         /** Create a matrix with 'width' columns, initalized with zero entries. */
-        BooleanColMatrix(size_t columns) :
+        boolean_colmatrix(size_t columns) :
             base(columns) {
         }
 
@@ -140,10 +138,10 @@ class BooleanColMatrix : public BooleanColMatrix_base<IT, BooleanColMatrix<IT> >
 };
 
 
-/** The base class of BooleanRowMatrix and BooleanColRowMatrix which implements
+/** The base class of boolean_rowmatrix and boolean_colrowmatrix which implements
  * the common logic of both. */
 template<class IT, class D>
-class BooleanRowMatrix_base {
+class boolean_rowmatrix_base {
 
     public:
         typedef IT index_type;
@@ -152,7 +150,7 @@ class BooleanRowMatrix_base {
 
         /** Create a matrix with 'height' rows, initalized with zero entries.
          * */
-        BooleanRowMatrix_base(size_t height) :
+        boolean_rowmatrix_base(size_t height) :
             rows(height) {
         }
 
@@ -164,24 +162,24 @@ class BooleanRowMatrix_base {
         /** Get the matrix entry at row 'r' and column 'c'. */
         bool get(index_type r, index_type c) const {
             assert(r < height());
-            const row_type &row = getRow(r);
+            const row_type &row = get_row(r);
             return binary_search(row.begin(), row.end(), c);
         }
 
         /** Set the matrix entry at row 'r' and column 'c'. */
         void set(index_type r, index_type c, bool value) {
-            getDerived()->_set(r, c, value);
+            get_derived()->_set(r, c, value);
         }
 
         /** Get the r-th row. */
-        const row_type& getRow(index_type r) const {
+        const row_type& get_row(index_type r) const {
             assert(r < height());
             return rows[r];
         }
 
         /** Add the row-vector 'row' to the r-th row. Note that 'row'
          * actually contains the list of column-indices that are 1. */
-        void addRow(index_type r, const row_type &row) {
+        void add_row(index_type r, const row_type &row) {
             assert(r < height());
 
             // Flip all entries that are set in 'row'.
@@ -190,12 +188,12 @@ class BooleanRowMatrix_base {
         }
 
         /** Two matrices are equal iff they have the same entries */
-        bool operator==(const BooleanRowMatrix_base<IT, D> &m) const {
+        bool operator==(const boolean_rowmatrix_base<IT, D> &m) const {
             return rows == m.rows;
         }
 
         /** Two matrices are equal iff they have the same entries */
-        bool operator!=(const BooleanRowMatrix_base<IT, D> &m) const {
+        bool operator!=(const boolean_rowmatrix_base<IT, D> &m) const {
             return !(*this == m);
         }
 
@@ -232,7 +230,7 @@ class BooleanRowMatrix_base {
         }
 
     private:
-        derived* getDerived() {
+        derived* get_derived() {
             return static_cast<derived*>(this);
         }
 
@@ -245,14 +243,14 @@ class BooleanRowMatrix_base {
  * row-vector we save the column-indices of the 1s. It is designed to handle a
  * few 1s and row-wise operations well. */
 template<class IT=uint32_t>
-class BooleanRowMatrix : public BooleanRowMatrix_base<IT, BooleanRowMatrix<IT> > {
+class boolean_rowmatrix : public boolean_rowmatrix_base<IT, boolean_rowmatrix<IT> > {
 
     public:
         typedef IT index_type;
-        typedef BooleanRowMatrix_base<IT, BooleanRowMatrix<IT> > base;
+        typedef boolean_rowmatrix_base<IT, boolean_rowmatrix<IT> > base;
 
         /** Create a matrix with 'height' rows, initalized with zero entries. */
-        BooleanRowMatrix(size_t height) :
+        boolean_rowmatrix(size_t height) :
             base(height) {
         }
 
@@ -266,18 +264,18 @@ class BooleanRowMatrix : public BooleanRowMatrix_base<IT, BooleanRowMatrix<IT> >
 /** This is a boolean matrix that supports. It is designed to handle a
  * few 1s and row- and column-wise operations well. */
 template<class IT=uint32_t>
-class BooleanColRowMatrix : public BooleanColMatrix_base<IT, BooleanColRowMatrix<IT> >,
-                            public BooleanRowMatrix_base<IT, BooleanColRowMatrix<IT> > {
+class boolean_colrowmatrix : public boolean_colmatrix_base<IT, boolean_colrowmatrix<IT> >,
+                            public boolean_rowmatrix_base<IT, boolean_colrowmatrix<IT> > {
 
     public:
-        typedef BooleanColMatrix_base<IT, BooleanColRowMatrix<IT> > colbase;
-        typedef BooleanRowMatrix_base<IT, BooleanColRowMatrix<IT> > rowbase;
+        typedef boolean_colmatrix_base<IT, boolean_colrowmatrix<IT> > colbase;
+        typedef boolean_rowmatrix_base<IT, boolean_colrowmatrix<IT> > rowbase;
 
     public:
         typedef IT index_type;
 
         /** Create a size x size matrix, initialized with zeros. */
-        BooleanColRowMatrix(size_t size) :
+        boolean_colrowmatrix(size_t size) :
             colbase(size),
             rowbase(size) {
         }
@@ -310,20 +308,20 @@ class BooleanColRowMatrix : public BooleanColMatrix_base<IT, BooleanColRowMatrix
         }
 
         /** Two matrices are equal iff they have the same entries */
-        bool operator==(const BooleanColRowMatrix<IT> &m) const {
+        bool operator==(const boolean_colrowmatrix<IT> &m) const {
             assert(rowbase::operator==(m) == colbase::operator==(m));
             return colbase::operator==(m);
         }
 
         /** Two matrices are equal iff they have the same entries */
-        bool operator!=(const BooleanColRowMatrix<IT> &m) const {
+        bool operator!=(const boolean_colrowmatrix<IT> &m) const {
             return !(*this == m);
         }
 
         /** Multiply with matrix b from the right */
         template<class D>
-        BooleanColRowMatrix<IT> operator*(const BooleanColMatrix_base<IT, D> &b) {
-            BooleanColRowMatrix<IT> c(size());
+        boolean_colrowmatrix<IT> operator*(const boolean_colmatrix_base<IT, D> &b) {
+            boolean_colrowmatrix<IT> c(size());
             multiply_matrix(c, *this, b);
             return c;
         }
@@ -356,13 +354,13 @@ size_t count_set_intersection (InputIterator1 first1, InputIterator1 last1, Inpu
 
 /** Multiply a*b and save the product in 'result'. It is assumed that 'result' is intially empty and has appropriate size. */
 template<class IT, class D, class RT>
-void multiply_matrix(RT &result, const BooleanRowMatrix_base<IT, D> &a, const BooleanColMatrix_base<IT, D> &b) {
+void multiply_matrix(RT &result, const boolean_rowmatrix_base<IT, D> &a, const boolean_colmatrix_base<IT, D> &b) {
     assert(a.height() == b.width());
 
     for (unsigned r=0; r < a.height(); ++r) {
-        const typename BooleanRowMatrix_base<IT, D>::row_type &row = a.getRow(r);
+        const typename boolean_rowmatrix_base<IT, D>::row_type &row = a.get_row(r);
         for (unsigned c=0; c < b.width(); ++c) {
-            const typename BooleanColMatrix_base<IT, D>::column_type &col = b.getColumn(c);
+            const typename boolean_colmatrix_base<IT, D>::column_type &col = b.get_column(c);
             if (count_set_intersection(row.begin(), row.end(), col.begin(), col.end()) % 2 == 1)
                 result.set(r, c, true);
         }
@@ -370,7 +368,7 @@ void multiply_matrix(RT &result, const BooleanRowMatrix_base<IT, D> &a, const Bo
 }
 
 template<class MT>
-MT unitMatrix(size_t size) {
+MT create_unit_matrix(size_t size) {
     MT mat(size);
     for (unsigned i=0; i < size; ++i)
         mat.set(i, i, true);
@@ -378,7 +376,7 @@ MT unitMatrix(size_t size) {
 }
 
 template<class IT>
-std::ostream& operator<<(std::ostream &os, const BooleanColRowMatrix<IT> &mat) {
+std::ostream& operator<<(std::ostream &os, const boolean_colrowmatrix<IT> &mat) {
     for (unsigned r=0; r < mat.size(); ++r) {
         for (unsigned c=0; c < mat.size(); ++c)
             os << (mat.get(r,c) ? "X" : ".");
@@ -390,17 +388,17 @@ std::ostream& operator<<(std::ostream &os, const BooleanColRowMatrix<IT> &mat) {
 }
 
 template<class IT>
-std::ostream& operator<<(std::ostream &os, BooleanColRowMatrix<IT> &mat) {
-    const BooleanColRowMatrix<IT> &m = mat;
+std::ostream& operator<<(std::ostream &os, boolean_colrowmatrix<IT> &mat) {
+    const boolean_colrowmatrix<IT> &m = mat;
     return os << m;
 }
 
 template<class IT, class D>
-std::ostream& operator<<(std::ostream &os, const BooleanRowMatrix_base<IT, D> &mat) {
+std::ostream& operator<<(std::ostream &os, const boolean_rowmatrix_base<IT, D> &mat) {
     for (unsigned r=0; r < mat.height(); ++r) {
         // Get the sorted r-th row
-        std::list<IT> row(mat.getRow(r).size());
-        copy(mat.getRow(r).begin(), mat.getRow(r).end(), row.begin());
+        std::list<IT> row(mat.get_row(r).size());
+        copy(mat.get_row(r).begin(), mat.get_row(r).end(), row.begin());
 
         os << "|";
         // Print the elements, and remove them
@@ -419,13 +417,13 @@ std::ostream& operator<<(std::ostream &os, const BooleanRowMatrix_base<IT, D> &m
 }
 
 template<class IT, class D>
-std::ostream& operator<<(std::ostream &os, BooleanRowMatrix_base<IT, D> &mat) {
-    const BooleanRowMatrix_base<IT, D> &m = mat;
+std::ostream& operator<<(std::ostream &os, boolean_rowmatrix_base<IT, D> &mat) {
+    const boolean_rowmatrix_base<IT, D> &m = mat;
     return os << m;
 }
 
 template<class IT, class D>
-std::ostream& operator<<(std::ostream &os, const BooleanColMatrix_base<IT, D> &mat) {
+std::ostream& operator<<(std::ostream &os, const boolean_colmatrix_base<IT, D> &mat) {
     // The sorted columns
     std::vector<std::list<IT> > cols;
     // The max height (max. value) of all columns
@@ -433,8 +431,8 @@ std::ostream& operator<<(std::ostream &os, const BooleanColMatrix_base<IT, D> &m
 
     for (unsigned c=0; c < mat.width(); ++c) {
         // Get the sorted c-th column
-        std::list<IT> col(mat.getColumn(c).size());
-        copy(mat.getColumn(c).begin(), mat.getColumn(c).end(), col.begin());
+        std::list<IT> col(mat.get_column(c).size());
+        copy(mat.get_column(c).begin(), mat.get_column(c).end(), col.begin());
         cols.push_back(col);
 
         os << "-";
@@ -465,8 +463,8 @@ std::ostream& operator<<(std::ostream &os, const BooleanColMatrix_base<IT, D> &m
 }
 
 template<class IT, class D>
-std::ostream& operator<<(std::ostream &os, BooleanColMatrix_base<IT, D> &mat) {
-    const BooleanColMatrix_base<IT, D> &m = mat;
+std::ostream& operator<<(std::ostream &os, boolean_colmatrix_base<IT, D> &mat) {
+    const boolean_colmatrix_base<IT, D> &m = mat;
     return os << m;
 }
 
index 60d8397f895893e8eb848434635441db2a7535d3..d9624cc1200f6b1f522d0b1711adb0c69a7eb941 100644 (file)
@@ -14,12 +14,12 @@ namespace libstick {
  * invariant.  Hence, the resulting b is equal to the product of the boundary
  * matrix times v. */
 template<class IT, class D>
-void reduceBoundaryMatrix(BooleanColRowMatrix<IT> &b, BooleanColMatrix_base<IT, D> &v) {
+void reduce_boundary_matrix(boolean_colrowmatrix<IT> &b, boolean_colmatrix_base<IT, D> &v) {
     assert(b.size() == v.width());
 
     // Make every column reduced, i.e., it is a zero-column or contains only one 1.
     for (unsigned c=0; c < b.size(); ++c) {
-        const typename BooleanColRowMatrix<IT>::colbase::column_type &col = b.getColumn(c);
+        const typename boolean_colrowmatrix<IT>::colbase::column_type &col = b.get_column(c);
         if (col.size() == 0)
             continue;
 
@@ -28,19 +28,19 @@ void reduceBoundaryMatrix(BooleanColRowMatrix<IT> &b, BooleanColMatrix_base<IT,
         assert(b.get(r, c));
 
         // Get a copy of the r-th row
-        typename BooleanColRowMatrix<IT>::rowbase::row_type row(b.getRow(r).size());
-        copy(b.getRow(r).begin(), b.getRow(r).end(), row.begin());
+        typename boolean_colrowmatrix<IT>::rowbase::row_type row(b.get_row(r).size());
+        copy(b.get_row(r).begin(), b.get_row(r).end(), row.begin());
         assert(row.size() >= 1);
 
         // Get rid of 1s at that row right of column c.
-        typename BooleanColRowMatrix<IT>::row_type::const_iterator it = lower_bound(row.begin(), row.end(), c);
+        typename boolean_colrowmatrix<IT>::row_type::const_iterator it = lower_bound(row.begin(), row.end(), c);
         for(; it != row.end(); ++it) {
             if (*it <= c)
                 continue;
 
             assert(b.get(r, *it));
-            b.addColumn(*it, col);
-            v.addColumn(*it, v.getColumn(c));
+            b.add_column(*it, col);
+            v.add_column(*it, v.get_column(c));
             assert(!b.get(r, *it));
         }
     }
index 07080ed76a23617e2c87b99ca7aa3dc998640b2f..47a88c64907cb29054cb6d22d78c49df9e0bb08b 100644 (file)
@@ -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<int MAXDIM, class IT=uint32_t, class VT=double>
-class SimplicialComplex {
+class simplicial_complex {
 
     public:
         /** The type of this class. */
-        typedef SimplicialComplex<MAXDIM, IT, VT> simplcompltype;
+        typedef simplicial_complex<MAXDIM, IT, VT> 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<IT> BoundaryMatrix;
+                typedef boolean_colrowmatrix<IT> 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<Simplex>::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){
                 }
 
index 0cba01971cff197b8f4a08b92840f2cdb1b67c20..71533ffbaf392ef44841d778196e3aaea8390e95 100644 (file)
@@ -9,18 +9,18 @@
 using namespace libstick;
 
 
-class BooleanmatrixTestSuite: public Test::Suite {
+class boolean_matrix_TestSuite: public Test::Suite {
     public:
-        BooleanmatrixTestSuite() {
-            TEST_ADD(BooleanmatrixTestSuite::test_getsetsize<BooleanRowMatrix<> >);
-            TEST_ADD(BooleanmatrixTestSuite::test_getsetsize<BooleanColMatrix<> >);
-            TEST_ADD(BooleanmatrixTestSuite::test_getsetsize<BooleanColRowMatrix<> >);
+        boolean_matrix_TestSuite() {
+            TEST_ADD(boolean_matrix_TestSuite::test_getsetsize<boolean_rowmatrix<> >);
+            TEST_ADD(boolean_matrix_TestSuite::test_getsetsize<boolean_colmatrix<> >);
+            TEST_ADD(boolean_matrix_TestSuite::test_getsetsize<boolean_colrowmatrix<> >);
 
-            TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn<BooleanColMatrix<> >);
-            TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn<BooleanColRowMatrix<> >);
+            TEST_ADD(boolean_matrix_TestSuite::test_addgetcolumn<boolean_colmatrix<> >);
+            TEST_ADD(boolean_matrix_TestSuite::test_addgetcolumn<boolean_colrowmatrix<> >);
 
-            TEST_ADD(BooleanmatrixTestSuite::test_addgetrow<BooleanRowMatrix<> >);
-            TEST_ADD(BooleanmatrixTestSuite::test_addgetrow<BooleanColRowMatrix<> >);
+            TEST_ADD(boolean_matrix_TestSuite::test_addgetrow<boolean_rowmatrix<> >);
+            TEST_ADD(boolean_matrix_TestSuite::test_addgetrow<boolean_colrowmatrix<> >);
         }
 
     protected:
@@ -61,7 +61,7 @@ class BooleanmatrixTestSuite: public Test::Suite {
 
             // Check if columns are empty
             for (unsigned c=0; c < size; ++c)
-                TEST_ASSERT(mat.getColumn(c).size() == 0);
+                TEST_ASSERT(mat.get_column(c).size() == 0);
 
             col.push_back(3);
             col.push_back(14);
@@ -69,13 +69,13 @@ class BooleanmatrixTestSuite: public Test::Suite {
             col.push_back(0);
 
             // Add column and test for values
-            mat.addColumn(5, col);
+            mat.add_column(5, col);
             for (unsigned c=0; c < size; ++c) {
                 if (c==5) {
                     for (unsigned r=0; r < size; ++r )
                         TEST_ASSERT(mat.get(r,c) == (r==0 || r==3 || r==8 || r==14));
                 } else {
-                    TEST_ASSERT(mat.getColumn(c).size() == 0);
+                    TEST_ASSERT(mat.get_column(c).size() == 0);
                 }
             }
         }
@@ -88,7 +88,7 @@ class BooleanmatrixTestSuite: public Test::Suite {
 
             // Check if rows are empty
             for (unsigned r=0; r < size; ++r)
-                TEST_ASSERT(mat.getRow(r).size() == 0);
+                TEST_ASSERT(mat.get_row(r).size() == 0);
 
             row.push_back(0);
             row.push_back(8);
@@ -96,13 +96,13 @@ class BooleanmatrixTestSuite: public Test::Suite {
             row.push_back(3);
 
             // Add row and test for values
-            mat.addRow(5, row);
+            mat.add_row(5, row);
             for (unsigned r=0; r < size; ++r) {
                 if (r==5) {
                     for (unsigned c=0; c < size; ++c )
                         TEST_ASSERT(mat.get(r,c) == (c==0 || c==3 || c==8 || c==14));
                 } else {
-                    TEST_ASSERT(mat.getRow(r).size() == 0);
+                    TEST_ASSERT(mat.get_row(r).size() == 0);
                 }
             }
         }
index 6dca3334a6d895e95b439b5f6b4eff02fd449801..ef4977e8eb9110a80f69939a54516188eef54078 100644 (file)
@@ -13,8 +13,8 @@ int main(int argc, char* argv[]) {
 
     Test::Suite ts;
 
-    ts.add(auto_ptr<Test::Suite>(new BooleanmatrixTestSuite));
-    ts.add(auto_ptr<Test::Suite>(new SimplicialComplexTestSuite));
+    ts.add(auto_ptr<Test::Suite>(new boolean_matrix_TestSuite));
+    ts.add(auto_ptr<Test::Suite>(new simplicial_complex_TestSuite));
 
     Test::TextOutput output(Test::TextOutput::Verbose);
     return ts.run(output);
index afc9fab1c8f649603b4044f7c602bfd1e0b4a22b..373688351dea1f172c49a93c600d4e4388c63c28 100644 (file)
 using namespace libstick;
 
 
-class SimplicialComplexTestSuite: public Test::Suite {
+class simplicial_complex_TestSuite: public Test::Suite {
 
     private:
-        typedef SimplicialComplex<2, uint32_t, double> scomplex;
-        typedef scomplex::SimplexOrder::BoundaryMatrix bm;
+        typedef simplicial_complex<2, uint32_t, double> scomplex;
+        typedef scomplex::simplex_order::boundary_matrix bm;
 
         bool setupcalled;
         scomplex c1, c2, c3;
-        scomplex::SimplexOrder o1, o2, o3, o3b;
+        scomplex::simplex_order o1, o2, o3, o3b;
 
     public:
-        SimplicialComplexTestSuite() :
+        simplicial_complex_TestSuite() :
             setupcalled(false),
             o1(c1),
             o2(c2),
             o3(c3),
             o3b(c3)
             {
-            TEST_ADD(SimplicialComplexTestSuite::test_isComplex);
-            TEST_ADD(SimplicialComplexTestSuite::test_isMonotoneComplex);
-            TEST_ADD(SimplicialComplexTestSuite::test_isOrderFiltration);
-            TEST_ADD(SimplicialComplexTestSuite::test_isOrderMonotone);
-            TEST_ADD(SimplicialComplexTestSuite::test_boundaryMatrix);
-            TEST_ADD(SimplicialComplexTestSuite::test_matrixreduction);
+            TEST_ADD(simplicial_complex_TestSuite::test_is_complex);
+            TEST_ADD(simplicial_complex_TestSuite::test_is_monotoneComplex);
+            TEST_ADD(simplicial_complex_TestSuite::test_is_order_filtration);
+            TEST_ADD(simplicial_complex_TestSuite::test_is_order_monotone);
+            TEST_ADD(simplicial_complex_TestSuite::test_boundary_matrix);
+            TEST_ADD(simplicial_complex_TestSuite::test_matrix_reduction);
         }
 
     protected:
@@ -75,7 +75,7 @@ class SimplicialComplexTestSuite: public Test::Suite {
 
             // Build the complex
             for (unsigned i=0; i<num; ++i)
-                c1.addSimplex(ss[i]);
+                c1.add_simplex(ss[i]);
 
             c2 = c1;
             c2.simplices[6].value = 12;
@@ -87,40 +87,40 @@ class SimplicialComplexTestSuite: public Test::Suite {
             o2.reset();
             o3.reset();
             o3b.reset();
-            o3b.makeMonotoneFiltration();
+            o3b.make_monotone_filtration();
         }
 
         virtual void tear_down() {
         }
 
-        void test_isComplex() {
-            TEST_ASSERT(c1.isComplex());
-            TEST_ASSERT(c2.isComplex());
-            TEST_ASSERT(c3.isComplex());
+        void test_is_complex() {
+            TEST_ASSERT(c1.is_complex());
+            TEST_ASSERT(c2.is_complex());
+            TEST_ASSERT(c3.is_complex());
         }
 
-        void test_isMonotoneComplex() {
-            TEST_ASSERT(c1.isMonotone());
-            TEST_ASSERT(!c2.isMonotone());
-            TEST_ASSERT(c3.isMonotone());
+        void test_is_monotoneComplex() {
+            TEST_ASSERT(c1.is_monotone());
+            TEST_ASSERT(!c2.is_monotone());
+            TEST_ASSERT(c3.is_monotone());
         }
 
-        void test_isOrderFiltration() {
-            TEST_ASSERT(o1.isFiltration());
-            TEST_ASSERT(o2.isFiltration());
-            TEST_ASSERT(o3.isFiltration());
-            TEST_ASSERT(o3b.isFiltration());
+        void test_is_order_filtration() {
+            TEST_ASSERT(o1.is_filtration());
+            TEST_ASSERT(o2.is_filtration());
+            TEST_ASSERT(o3.is_filtration());
+            TEST_ASSERT(o3b.is_filtration());
         }
 
-        void test_isOrderMonotone() {
-            TEST_ASSERT(o1.isMonotone());
-            TEST_ASSERT(!o2.isMonotone());
-            TEST_ASSERT(!o3.isMonotone());
-            TEST_ASSERT(o3b.isMonotone());
+        void test_is_order_monotone() {
+            TEST_ASSERT(o1.is_monotone());
+            TEST_ASSERT(!o2.is_monotone());
+            TEST_ASSERT(!o3.is_monotone());
+            TEST_ASSERT(o3b.is_monotone());
         }
 
-        void test_boundaryMatrix() {
-            bm mat1 = o1.getBoundaryMatrix();
+        void test_boundary_matrix() {
+            bm mat1 = o1.get_boundary_matrix();
             bm mat1e(c1.size());
             mat1e.set(0, 1, true);
             mat1e.set(0, 2, true);
@@ -144,7 +144,7 @@ class SimplicialComplexTestSuite: public Test::Suite {
             mat1e.set(9, 11, true);
             TEST_ASSERT(mat1 == mat1e);
 
-            bm mat3b = o3b.getBoundaryMatrix();
+            bm mat3b = o3b.get_boundary_matrix();
             bm mat3be(c1.size());
             mat3be.set(0, 1, true);
             mat3be.set(0, 2, true);
@@ -174,12 +174,12 @@ class SimplicialComplexTestSuite: public Test::Suite {
             //std::cout << ((bm::rowbase) mat3b) << std::endl << std::endl;
         }
 
-        void test_matrixreduction() {
-            bm b = o3b.getBoundaryMatrix();
-            bm v = unitMatrix<bm>(b.size());
+        void test_matrix_reduction() {
+            bm b = o3b.get_boundary_matrix();
+            bm v = create_unit_matrix<bm>(b.size());
 
             bm b_orig = b;
-            reduceBoundaryMatrix(b, v);
+            reduce_boundary_matrix(b, v);
             TEST_ASSERT(b == b_orig*v);
 
             //std::cout << std::endl << "after reduce: " << std::endl;