StaticPersistence operates on chains consisting of only positive simplices dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Wed, 02 Dec 2009 14:03:54 -0800
branchdev
changeset 177 b5f2e93fa75c
parent 176 64177e8ef379
child 178 cc0c26fba495
StaticPersistence operates on chains consisting of only positive simplices
include/topology/static-persistence.hpp
--- a/include/topology/static-persistence.hpp	Tue Dec 01 20:34:31 2009 -0800
+++ b/include/topology/static-persistence.hpp	Wed Dec 02 14:03:54 2009 -0800
@@ -4,6 +4,8 @@
 #include <boost/utility.hpp>
 #include <utilities/property-maps.h>
 
+#include <boost/foreach.hpp>
+
 #ifdef LOGGING
 static rlog::RLogChannel* rlPersistence =                   DEF_CHANNEL("topology/persistence", rlog::Log_Debug);
 #endif // LOGGING
@@ -54,6 +56,14 @@
         OrderElement& oe = *j;
         typename OrderElement::Cycle& z = oe.cycle;
         rLog(rlPersistence, "  has boundary: %s", z.tostring(outmap).c_str());
+
+        // Sparsify the cycle by removing the negative elements (TODO: make parameter based)
+        typename OrderElement::Cycle zz;
+        BOOST_FOREACH(OrderIndex i, z)
+            if (i->sign())           // positive
+                zz.push_back(i);
+        z.swap(zz);
+        // --------------------------
         
         CountNum(cPersistencePairBoundaries, oe.cycle.size());
         Count(cPersistencePair);