summaryrefslogtreecommitdiff
path: root/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2014-12-10 14:04:18 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2014-12-10 14:04:18 +0000
commit429d4f06cede4d97144592eff91689fc1c707474 (patch)
tree10cbfc316b7445b887672b8b70a39b763d65fe9a /src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
parente8cca67a337b9d4bdbd1a8558ad99862862145f3 (diff)
Add persistent unit test - warning fix - cpplint fix
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cpplint_test@346 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9ef774de762c68a449b2a9791085f58c39a0705e
Diffstat (limited to 'src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h')
-rw-r--r--src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h249
1 files changed, 120 insertions, 129 deletions
diff --git a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
index 0702c58e..632f8e11 100644
--- a/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
+++ b/src/Persistent_cohomology/include/gudhi/Persistent_cohomology/Persistent_cohomology_column.h
@@ -1,153 +1,144 @@
- /* This file is part of the Gudhi Library. The Gudhi library
- * (Geometric Understanding in Higher Dimensions) is a generic C++
- * library for computational topology.
- *
- * Author(s): Clément Maria
- *
- * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef GUDHI_COLUMN_LIST_H
-#define GUDHI_COLUMN_LIST_H
+/* This file is part of the Gudhi Library. The Gudhi library
+ * (Geometric Understanding in Higher Dimensions) is a generic C++
+ * library for computational topology.
+ *
+ * Author(s): Clément Maria
+ *
+ * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_
+#define SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_
+
+#include <list>
#include "boost/tuple/tuple.hpp"
#include "boost/intrusive/set.hpp"
#include "boost/intrusive/list.hpp"
-namespace Gudhi{
+namespace Gudhi {
-template < typename SimplexKey
- , typename ArithmeticElement
- >
+template<typename SimplexKey, typename ArithmeticElement>
class Persistent_cohomology_column;
-struct cam_h_tag; // for horizontal traversal in the CAM
-struct cam_v_tag; // for vertical traversal in the CAM
+struct cam_h_tag;
+// for horizontal traversal in the CAM
+struct cam_v_tag;
+// for vertical traversal in the CAM
-typedef boost::intrusive::list_base_hook
- < boost::intrusive::tag < cam_h_tag >
- , boost::intrusive::link_mode < boost::intrusive::auto_unlink > //allows .unlink()
- > base_hook_cam_h;
+typedef boost::intrusive::list_base_hook<boost::intrusive::tag<cam_h_tag>,
+ boost::intrusive::link_mode<boost::intrusive::auto_unlink> // allows .unlink()
+> base_hook_cam_h;
-typedef boost::intrusive::list_base_hook
- < boost::intrusive::tag < cam_v_tag >
- , boost::intrusive::link_mode < boost::intrusive::normal_link > //faster hook, less safe
- > base_hook_cam_v;
+typedef boost::intrusive::list_base_hook<boost::intrusive::tag<cam_v_tag>,
+ boost::intrusive::link_mode<boost::intrusive::normal_link> // faster hook, less safe
+> base_hook_cam_v;
/** \internal
- * \brief
- *
- */
-template < typename SimplexKey
- , typename ArithmeticElement
- >
-class Persistent_cohomology_cell
-: public base_hook_cam_h
-, public base_hook_cam_v
-{
- public:
- template < class T1, class T2 > friend class Persistent_cohomology;
- friend class Persistent_cohomology_column < SimplexKey , ArithmeticElement >;
-
- typedef Persistent_cohomology_column< SimplexKey, ArithmeticElement > Column;
-
- Persistent_cohomology_cell( SimplexKey key
- , ArithmeticElement x
- , Column * self_col)
- : key_(key)
- , coefficient_(x)
- , self_col_(self_col) {}
-
- SimplexKey key_;
- ArithmeticElement coefficient_;
- Column * self_col_;
-};
-
-
-
+ * \brief
+ *
+ */
+template<typename SimplexKey, typename ArithmeticElement>
+class Persistent_cohomology_cell : public base_hook_cam_h,
+ public base_hook_cam_v {
+ public:
+ template<class T1, class T2> friend class Persistent_cohomology;
+ friend class Persistent_cohomology_column<SimplexKey, ArithmeticElement>;
+
+ typedef Persistent_cohomology_column<SimplexKey, ArithmeticElement> Column;
+
+ Persistent_cohomology_cell(SimplexKey key, ArithmeticElement x,
+ Column * self_col)
+ : key_(key),
+ coefficient_(x),
+ self_col_(self_col) {
+ }
+ SimplexKey key_;
+ ArithmeticElement coefficient_;
+ Column * self_col_;
+};
/*
- * \brief Sparse column for the Compressed Annotation Matrix.
- *
- * The non-zero coefficients of the column are stored in a
- * boost::intrusive::list. Contains a hook to be stored in a
- * boost::intrusive::set.
- */
-template < typename SimplexKey
- , typename ArithmeticElement >
-class Persistent_cohomology_column
-: public boost::intrusive::set_base_hook
- < boost::intrusive::link_mode< boost::intrusive::normal_link > >
-{
-private:
- template < class T1, class T2 > friend class Persistent_cohomology;
-
- typedef Persistent_cohomology_cell < SimplexKey, ArithmeticElement > Cell;
- typedef boost::intrusive::list < Cell
- , boost::intrusive::constant_time_size<false>
- , boost::intrusive::base_hook< base_hook_cam_v >
- > Col_type;
-
-/** \brief Creates an empty column.*/
- Persistent_cohomology_column (SimplexKey key)
- {
+ * \brief Sparse column for the Compressed Annotation Matrix.
+ *
+ * The non-zero coefficients of the column are stored in a
+ * boost::intrusive::list. Contains a hook to be stored in a
+ * boost::intrusive::set.
+ */
+template<typename SimplexKey, typename ArithmeticElement>
+class Persistent_cohomology_column : public boost::intrusive::set_base_hook<
+ boost::intrusive::link_mode<boost::intrusive::normal_link> > {
+ private:
+ template<class T1, class T2> friend class Persistent_cohomology;
+
+ typedef Persistent_cohomology_cell<SimplexKey, ArithmeticElement> Cell;
+ typedef boost::intrusive::list<Cell,
+ boost::intrusive::constant_time_size<false>,
+ boost::intrusive::base_hook<base_hook_cam_v> > Col_type;
+
+ /** \brief Creates an empty column.*/
+ explicit Persistent_cohomology_column(SimplexKey key) {
class_key_ = key;
col_ = Col_type();
}
-public:
- /** Copy constructor.*/
- Persistent_cohomology_column( Persistent_cohomology_column const &other )
- : col_()
- , class_key_(other.class_key_)
- { if(!other.col_.empty()) std::cerr << "Copying a non-empty column.\n"; }
-
-/** \brief Returns true iff the column is null.*/
- bool is_null() { return col_.empty(); }
-/** \brief Returns the key of the representative simplex of
- * the set of simplices having this column as annotation vector
- * in the compressed annotation matrix.*/
- SimplexKey class_key () { return class_key_; }
-
-/** \brief Lexicographic comparison of two columns.*/
-friend bool operator< ( const Persistent_cohomology_column& c1
- , const Persistent_cohomology_column& c2)
- {
- typename Col_type::const_iterator it1 = c1.col_.begin();
- typename Col_type::const_iterator it2 = c2.col_.begin();
- while(it1 != c1.col_.end() && it2 != c2.col_.end())
- {
- if(it1->key_ == it2->key_)
- { if(it1->coefficient_ == it2->coefficient_) { ++it1; ++it2; }
- else { return it1->coefficient_ < it2->coefficient_; } }
- else { return it1->key_ < it2->key_; }
- }
- return (it2 != c2.col_.end());
+ public:
+ /** Copy constructor.*/
+ Persistent_cohomology_column(Persistent_cohomology_column const &other)
+ : col_(),
+ class_key_(other.class_key_) {
+ if (!other.col_.empty())
+ std::cerr << "Copying a non-empty column.\n";
}
- // void display()
- // {
- // for(auto cell : col_)
- // { std::cout << "(" << cell.key_ <<":"<<cell.coefficient_<<") "; }
- // }
+ /** \brief Returns true iff the column is null.*/
+ bool is_null() {
+ return col_.empty();
+ }
+ /** \brief Returns the key of the representative simplex of
+ * the set of simplices having this column as annotation vector
+ * in the compressed annotation matrix.*/
+ SimplexKey class_key() {
+ return class_key_;
+ }
+
+ /** \brief Lexicographic comparison of two columns.*/
+ friend bool operator<(const Persistent_cohomology_column& c1,
+ const Persistent_cohomology_column& c2) {
+ typename Col_type::const_iterator it1 = c1.col_.begin();
+ typename Col_type::const_iterator it2 = c2.col_.begin();
+ while (it1 != c1.col_.end() && it2 != c2.col_.end()) {
+ if (it1->key_ == it2->key_) {
+ if (it1->coefficient_ == it2->coefficient_) {
+ ++it1;
+ ++it2;
+ } else {
+ return it1->coefficient_ < it2->coefficient_;
+ }
+ } else {
+ return it1->key_ < it2->key_;
+ }
+ }
+ return (it2 != c2.col_.end());
+ }
- Col_type col_;
- SimplexKey class_key_;
+ Col_type col_;
+ SimplexKey class_key_;
};
-} // namespace GUDHI
+} // namespace Gudhi
-#endif // GUDHI_COLUMN_LIST_H
+#endif // SRC_PERSISTENT_COHOMOLOGY_INCLUDE_GUDHI_PERSISTENT_COHOMOLOGY_PERSISTENT_COHOMOLOGY_COLUMN_H_