Made storing negative simplices in StaticPersistence parameter-based, so that DynamicPersistence works again dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Thu, 03 Dec 2009 13:21:23 -0800
branchdev
changeset 178 cc0c26fba495
parent 177 b5f2e93fa75c
child 182 451748b3c888
Made storing negative simplices in StaticPersistence parameter-based, so that DynamicPersistence works again
include/topology/dynamic-persistence.hpp
include/topology/static-persistence.h
include/topology/static-persistence.hpp
--- a/include/topology/dynamic-persistence.hpp	Wed Dec 02 14:03:54 2009 -0800
+++ b/include/topology/dynamic-persistence.hpp	Thu Dec 03 13:21:23 2009 -0800
@@ -34,7 +34,7 @@
 DynamicPersistenceTrails<D,CT,Cmp,OT,CI,CC,E>::
 pair_simplices()
 { 
-    Parent::pair_simplices(begin(), end(), PairingTrailsVisitor(begin(), ccmp_, size()));
+    Parent::pair_simplices(begin(), end(), true, PairingTrailsVisitor(begin(), ccmp_, size()));
 }
 
 template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
@@ -274,6 +274,6 @@
 DynamicPersistenceChains<D,CT,Cmp,OT,CI,CC,E>::
 pair_simplices()
 { 
-    Parent::pair_simplices(begin(), end(), PairingChainsVisitor(begin(), ccmp_, size()));
+    Parent::pair_simplices(begin(), end(), true, PairingChainsVisitor(begin(), ccmp_, size()));
 }
 
--- a/include/topology/static-persistence.h	Wed Dec 02 14:03:54 2009 -0800
+++ b/include/topology/static-persistence.h	Thu Dec 03 13:21:23 2009 -0800
@@ -82,7 +82,7 @@
         
         // Function: pair_simplices()                                        
         // Compute persistence of the filtration
-        void                            pair_simplices()                                        { pair_simplices<PairVisitor>(begin(), end(), PairVisitor(size())); }
+        void                            pair_simplices()                                        { pair_simplices<PairVisitor>(begin(), end(), false, PairVisitor(size())); }
 
         // Functions: Accessors
         //   begin() -              returns OrderIndex of the first element
@@ -97,7 +97,7 @@
         // Function: pair_simplices(bg, end)
         // Compute persistence of the simplices in filtration between bg and end
         template<class Visitor>
-        void                            pair_simplices(OrderIndex bg, OrderIndex end, const Visitor& visitor = Visitor());
+        void                            pair_simplices(OrderIndex bg, OrderIndex end, bool store_negative = false, const Visitor& visitor = Visitor());
 
         // Struct: PairVisitor
         // Acts as an archetype and if necessary a base class for visitors passed to <pair_simplices(bg, end, visitor)>.
--- a/include/topology/static-persistence.hpp	Wed Dec 02 14:03:54 2009 -0800
+++ b/include/topology/static-persistence.hpp	Thu Dec 03 13:21:23 2009 -0800
@@ -40,7 +40,7 @@
 template<class Visitor>
 void 
 StaticPersistence<D, CT, Cmp, OT, E>::
-pair_simplices(OrderIndex bg, OrderIndex end, const Visitor& visitor)
+pair_simplices(OrderIndex bg, OrderIndex end, bool store_negative, const Visitor& visitor)
 {
 #if LOGGING
     typename ContainerTraits::OutputMap outmap(order_);
@@ -57,12 +57,15 @@
         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);
+        // Sparsify the cycle by removing the negative elements
+        if (!store_negative)
+        {
+            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());