Made storing negative simplices in StaticPersistence parameter-based, so that DynamicPersistence works again dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Thu Dec 03 13:21:23 2009 -0800 (2009-12-03)
branchdev
changeset 178cc0c26fba495
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
     1.1 --- a/include/topology/dynamic-persistence.hpp	Wed Dec 02 14:03:54 2009 -0800
     1.2 +++ b/include/topology/dynamic-persistence.hpp	Thu Dec 03 13:21:23 2009 -0800
     1.3 @@ -34,7 +34,7 @@
     1.4  DynamicPersistenceTrails<D,CT,Cmp,OT,CI,CC,E>::
     1.5  pair_simplices()
     1.6  { 
     1.7 -    Parent::pair_simplices(begin(), end(), PairingTrailsVisitor(begin(), ccmp_, size()));
     1.8 +    Parent::pair_simplices(begin(), end(), true, PairingTrailsVisitor(begin(), ccmp_, size()));
     1.9  }
    1.10  
    1.11  template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
    1.12 @@ -274,6 +274,6 @@
    1.13  DynamicPersistenceChains<D,CT,Cmp,OT,CI,CC,E>::
    1.14  pair_simplices()
    1.15  { 
    1.16 -    Parent::pair_simplices(begin(), end(), PairingChainsVisitor(begin(), ccmp_, size()));
    1.17 +    Parent::pair_simplices(begin(), end(), true, PairingChainsVisitor(begin(), ccmp_, size()));
    1.18  }
    1.19  
     2.1 --- a/include/topology/static-persistence.h	Wed Dec 02 14:03:54 2009 -0800
     2.2 +++ b/include/topology/static-persistence.h	Thu Dec 03 13:21:23 2009 -0800
     2.3 @@ -82,7 +82,7 @@
     2.4          
     2.5          // Function: pair_simplices()                                        
     2.6          // Compute persistence of the filtration
     2.7 -        void                            pair_simplices()                                        { pair_simplices<PairVisitor>(begin(), end(), PairVisitor(size())); }
     2.8 +        void                            pair_simplices()                                        { pair_simplices<PairVisitor>(begin(), end(), false, PairVisitor(size())); }
     2.9  
    2.10          // Functions: Accessors
    2.11          //   begin() -              returns OrderIndex of the first element
    2.12 @@ -97,7 +97,7 @@
    2.13          // Function: pair_simplices(bg, end)
    2.14          // Compute persistence of the simplices in filtration between bg and end
    2.15          template<class Visitor>
    2.16 -        void                            pair_simplices(OrderIndex bg, OrderIndex end, const Visitor& visitor = Visitor());
    2.17 +        void                            pair_simplices(OrderIndex bg, OrderIndex end, bool store_negative = false, const Visitor& visitor = Visitor());
    2.18  
    2.19          // Struct: PairVisitor
    2.20          // Acts as an archetype and if necessary a base class for visitors passed to <pair_simplices(bg, end, visitor)>.
     3.1 --- a/include/topology/static-persistence.hpp	Wed Dec 02 14:03:54 2009 -0800
     3.2 +++ b/include/topology/static-persistence.hpp	Thu Dec 03 13:21:23 2009 -0800
     3.3 @@ -40,7 +40,7 @@
     3.4  template<class Visitor>
     3.5  void 
     3.6  StaticPersistence<D, CT, Cmp, OT, E>::
     3.7 -pair_simplices(OrderIndex bg, OrderIndex end, const Visitor& visitor)
     3.8 +pair_simplices(OrderIndex bg, OrderIndex end, bool store_negative, const Visitor& visitor)
     3.9  {
    3.10  #if LOGGING
    3.11      typename ContainerTraits::OutputMap outmap(order_);
    3.12 @@ -57,12 +57,15 @@
    3.13          typename OrderElement::Cycle& z = oe.cycle;
    3.14          rLog(rlPersistence, "  has boundary: %s", z.tostring(outmap).c_str());
    3.15  
    3.16 -        // Sparsify the cycle by removing the negative elements (TODO: make parameter based)
    3.17 -        typename OrderElement::Cycle zz;
    3.18 -        BOOST_FOREACH(OrderIndex i, z)
    3.19 -            if (i->sign())           // positive
    3.20 -                zz.push_back(i);
    3.21 -        z.swap(zz);
    3.22 +        // Sparsify the cycle by removing the negative elements
    3.23 +        if (!store_negative)
    3.24 +        {
    3.25 +            typename OrderElement::Cycle zz;
    3.26 +            BOOST_FOREACH(OrderIndex i, z)
    3.27 +                if (i->sign())           // positive
    3.28 +                    zz.push_back(i);
    3.29 +            z.swap(zz);
    3.30 +        }
    3.31          // --------------------------
    3.32          
    3.33          CountNum(cPersistencePairBoundaries, oe.cycle.size());