From 88ea14f1e9079c9b8c4af7aff01a3fe960e9472b Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Mon, 11 Nov 2013 13:51:37 +0100 Subject: [PATCH] Coding style cleanup --- include/libstick-0.1/booleanmatrix.h | 106 +++++++++++------------ include/libstick-0.1/matrixreduction.h | 14 +-- include/libstick-0.1/simplicialcomplex.h | 98 ++++++++++----------- tests/booleanmatrix.h | 30 +++---- tests/main.cc | 4 +- tests/simplicialcomplex.h | 76 ++++++++-------- 6 files changed, 163 insertions(+), 165 deletions(-) diff --git a/include/libstick-0.1/booleanmatrix.h b/include/libstick-0.1/booleanmatrix.h index 894892f..774aeb7 100644 --- a/include/libstick-0.1/booleanmatrix.h +++ b/include/libstick-0.1/booleanmatrix.h @@ -15,10 +15,10 @@ 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 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 &m) const { + bool operator==(const boolean_colmatrix_base &m) const { return cols == m.cols; } /** Two matrices are equal iff they have the same entries */ - bool operator!=(const BooleanColMatrix_base &m) const { + bool operator!=(const boolean_colmatrix_base &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 cols; /** A cast to the derived type */ - derived* getDerived() { + derived* get_derived() { return static_cast(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 BooleanColMatrix : public BooleanColMatrix_base > { +class boolean_colmatrix : public boolean_colmatrix_base > { public: typedef IT index_type; - typedef BooleanColMatrix_base > base; + typedef boolean_colmatrix_base > 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 > }; -/** 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 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 &m) const { + bool operator==(const boolean_rowmatrix_base &m) const { return rows == m.rows; } /** Two matrices are equal iff they have the same entries */ - bool operator!=(const BooleanRowMatrix_base &m) const { + bool operator!=(const boolean_rowmatrix_base &m) const { return !(*this == m); } @@ -232,7 +230,7 @@ class BooleanRowMatrix_base { } private: - derived* getDerived() { + derived* get_derived() { return static_cast(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 BooleanRowMatrix : public BooleanRowMatrix_base > { +class boolean_rowmatrix : public boolean_rowmatrix_base > { public: typedef IT index_type; - typedef BooleanRowMatrix_base > base; + typedef boolean_rowmatrix_base > 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 > /** This is a boolean matrix that supports. It is designed to handle a * few 1s and row- and column-wise operations well. */ template -class BooleanColRowMatrix : public BooleanColMatrix_base >, - public BooleanRowMatrix_base > { +class boolean_colrowmatrix : public boolean_colmatrix_base >, + public boolean_rowmatrix_base > { public: - typedef BooleanColMatrix_base > colbase; - typedef BooleanRowMatrix_base > rowbase; + typedef boolean_colmatrix_base > colbase; + typedef boolean_rowmatrix_base > 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 &m) const { + bool operator==(const boolean_colrowmatrix &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 &m) const { + bool operator!=(const boolean_colrowmatrix &m) const { return !(*this == m); } /** Multiply with matrix b from the right */ template - BooleanColRowMatrix operator*(const BooleanColMatrix_base &b) { - BooleanColRowMatrix c(size()); + boolean_colrowmatrix operator*(const boolean_colmatrix_base &b) { + boolean_colrowmatrix 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 -void multiply_matrix(RT &result, const BooleanRowMatrix_base &a, const BooleanColMatrix_base &b) { +void multiply_matrix(RT &result, const boolean_rowmatrix_base &a, const boolean_colmatrix_base &b) { assert(a.height() == b.width()); for (unsigned r=0; r < a.height(); ++r) { - const typename BooleanRowMatrix_base::row_type &row = a.getRow(r); + const typename boolean_rowmatrix_base::row_type &row = a.get_row(r); for (unsigned c=0; c < b.width(); ++c) { - const typename BooleanColMatrix_base::column_type &col = b.getColumn(c); + const typename boolean_colmatrix_base::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 &a, const Bo } template -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 -std::ostream& operator<<(std::ostream &os, const BooleanColRowMatrix &mat) { +std::ostream& operator<<(std::ostream &os, const boolean_colrowmatrix &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 &mat) { } template -std::ostream& operator<<(std::ostream &os, BooleanColRowMatrix &mat) { - const BooleanColRowMatrix &m = mat; +std::ostream& operator<<(std::ostream &os, boolean_colrowmatrix &mat) { + const boolean_colrowmatrix &m = mat; return os << m; } template -std::ostream& operator<<(std::ostream &os, const BooleanRowMatrix_base &mat) { +std::ostream& operator<<(std::ostream &os, const boolean_rowmatrix_base &mat) { for (unsigned r=0; r < mat.height(); ++r) { // Get the sorted r-th row - std::list row(mat.getRow(r).size()); - copy(mat.getRow(r).begin(), mat.getRow(r).end(), row.begin()); + std::list 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 &m } template -std::ostream& operator<<(std::ostream &os, BooleanRowMatrix_base &mat) { - const BooleanRowMatrix_base &m = mat; +std::ostream& operator<<(std::ostream &os, boolean_rowmatrix_base &mat) { + const boolean_rowmatrix_base &m = mat; return os << m; } template -std::ostream& operator<<(std::ostream &os, const BooleanColMatrix_base &mat) { +std::ostream& operator<<(std::ostream &os, const boolean_colmatrix_base &mat) { // The sorted columns std::vector > cols; // The max height (max. value) of all columns @@ -433,8 +431,8 @@ std::ostream& operator<<(std::ostream &os, const BooleanColMatrix_base &m for (unsigned c=0; c < mat.width(); ++c) { // Get the sorted c-th column - std::list col(mat.getColumn(c).size()); - copy(mat.getColumn(c).begin(), mat.getColumn(c).end(), col.begin()); + std::list 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 &m } template -std::ostream& operator<<(std::ostream &os, BooleanColMatrix_base &mat) { - const BooleanColMatrix_base &m = mat; +std::ostream& operator<<(std::ostream &os, boolean_colmatrix_base &mat) { + const boolean_colmatrix_base &m = mat; return os << m; } diff --git a/include/libstick-0.1/matrixreduction.h b/include/libstick-0.1/matrixreduction.h index 60d8397..d9624cc 100644 --- a/include/libstick-0.1/matrixreduction.h +++ b/include/libstick-0.1/matrixreduction.h @@ -14,12 +14,12 @@ namespace libstick { * invariant. Hence, the resulting b is equal to the product of the boundary * matrix times v. */ template -void reduceBoundaryMatrix(BooleanColRowMatrix &b, BooleanColMatrix_base &v) { +void reduce_boundary_matrix(boolean_colrowmatrix &b, boolean_colmatrix_base &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::colbase::column_type &col = b.getColumn(c); + const typename boolean_colrowmatrix::colbase::column_type &col = b.get_column(c); if (col.size() == 0) continue; @@ -28,19 +28,19 @@ void reduceBoundaryMatrix(BooleanColRowMatrix &b, BooleanColMatrix_base::rowbase::row_type row(b.getRow(r).size()); - copy(b.getRow(r).begin(), b.getRow(r).end(), row.begin()); + typename boolean_colrowmatrix::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::row_type::const_iterator it = lower_bound(row.begin(), row.end(), c); + typename boolean_colrowmatrix::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)); } } 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){ } diff --git a/tests/booleanmatrix.h b/tests/booleanmatrix.h index 0cba019..71533ff 100644 --- a/tests/booleanmatrix.h +++ b/tests/booleanmatrix.h @@ -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 >); - TEST_ADD(BooleanmatrixTestSuite::test_getsetsize >); - TEST_ADD(BooleanmatrixTestSuite::test_getsetsize >); + boolean_matrix_TestSuite() { + TEST_ADD(boolean_matrix_TestSuite::test_getsetsize >); + TEST_ADD(boolean_matrix_TestSuite::test_getsetsize >); + TEST_ADD(boolean_matrix_TestSuite::test_getsetsize >); - TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn >); - TEST_ADD(BooleanmatrixTestSuite::test_addgetcolumn >); + TEST_ADD(boolean_matrix_TestSuite::test_addgetcolumn >); + TEST_ADD(boolean_matrix_TestSuite::test_addgetcolumn >); - TEST_ADD(BooleanmatrixTestSuite::test_addgetrow >); - TEST_ADD(BooleanmatrixTestSuite::test_addgetrow >); + TEST_ADD(boolean_matrix_TestSuite::test_addgetrow >); + TEST_ADD(boolean_matrix_TestSuite::test_addgetrow >); } 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); } } } diff --git a/tests/main.cc b/tests/main.cc index 6dca333..ef4977e 100644 --- a/tests/main.cc +++ b/tests/main.cc @@ -13,8 +13,8 @@ int main(int argc, char* argv[]) { Test::Suite ts; - ts.add(auto_ptr(new BooleanmatrixTestSuite)); - ts.add(auto_ptr(new SimplicialComplexTestSuite)); + ts.add(auto_ptr(new boolean_matrix_TestSuite)); + ts.add(auto_ptr(new simplicial_complex_TestSuite)); Test::TextOutput output(Test::TextOutput::Verbose); return ts.run(output); diff --git a/tests/simplicialcomplex.h b/tests/simplicialcomplex.h index afc9fab..3736883 100644 --- a/tests/simplicialcomplex.h +++ b/tests/simplicialcomplex.h @@ -10,30 +10,30 @@ 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(b.size()); + void test_matrix_reduction() { + bm b = o3b.get_boundary_matrix(); + bm v = create_unit_matrix(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; -- 2.30.2