Cleaned up traits (chain and container) for static- and dynamic-persistence dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Fri, 01 May 2009 15:09:38 -0700
branchdev
changeset 125 0a2c2283e4a8
parent 124 af54138b98fd
child 126 3c3e77ac43d2
Cleaned up traits (chain and container) for static- and dynamic-persistence
examples/rips/rips-pairwise.cpp
examples/rips/rips.cpp
include/topology/cycles.h
include/topology/dynamic-persistence.h
include/topology/dynamic-persistence.hpp
include/topology/order.h
include/topology/static-persistence.h
include/topology/static-persistence.hpp
include/utilities/types.h
--- a/examples/rips/rips-pairwise.cpp	Fri May 01 15:36:25 2009 -0700
+++ b/examples/rips/rips-pairwise.cpp	Fri May 01 15:09:38 2009 -0700
@@ -60,7 +60,7 @@
     // Output cycles
     for (Persistence::OrderIndex cur = p.begin(); cur != p.end(); ++cur)
     {
-        Persistence::OrderDescriptor::Cycle& cycle = cur->cycle;
+        Persistence::Cycle& cycle = cur->cycle;
 
         if (!cur->sign())        // only negative simplices have non-empty cycles
         {
@@ -81,7 +81,7 @@
         }
 
         // Iterate over the cycle
-        for (Persistence::OrderDescriptor::Cycle::const_iterator si =  cycle.begin();
+        for (Persistence::Cycle::const_iterator si =  cycle.begin();
                                                                  si != cycle.end();     ++si)
         {
             const Smplx& s = f.simplex(f.begin() + (*si - p.begin()));
--- a/examples/rips/rips.cpp	Fri May 01 15:36:25 2009 -0700
+++ b/examples/rips/rips.cpp	Fri May 01 15:09:38 2009 -0700
@@ -79,7 +79,7 @@
     // Output cycles
     for (Persistence::OrderIndex cur = p.begin(); cur != p.end(); ++cur)
     {
-        Persistence::OrderDescriptor::Cycle& cycle = cur->cycle;
+        Persistence::Cycle& cycle = cur->cycle;
 
         if (!cur->sign())        // only negative simplices have non-empty cycles
         {
@@ -100,7 +100,7 @@
         }
 
         // Iterate over the cycle
-        for (Persistence::OrderDescriptor::Cycle::const_iterator si =  cycle.begin();
+        for (Persistence::Cycle::const_iterator si =  cycle.begin();
                                                                  si != cycle.end();     ++si)
         {
             const Smplx& s = f.simplex(f.begin() + (*si - p.begin()));
--- a/include/topology/cycles.h	Fri May 01 15:36:25 2009 -0700
+++ b/include/topology/cycles.h	Fri May 01 15:09:38 2009 -0700
@@ -21,15 +21,7 @@
 {
     typedef             OrderIndex_                                             OrderIndex;
     typedef             ChainWrapper<vector<OrderIndex> >                       Chain;
-    typedef             Chain                                                   Cycle;
-
-    Cycle               cycle;
-
-                        VectorChains()                                          {}
-                        VectorChains(Cycle z): cycle(z)                         {}
-
-    bool                sign() const                                            { return cycle.empty(); }
-
+    
     template<class U> struct rebind
     { typedef           VectorChains<U>         other; };
 };
@@ -39,14 +31,6 @@
 {
     typedef             OrderIndex_                                             OrderIndex;
     typedef             ChainWrapper<deque<OrderIndex> >                        Chain;
-    typedef             Chain                                                   Cycle;
-
-    Cycle               cycle;
-
-                        DequeChains()                                           {}
-                        DequeChains(Cycle z): cycle(z)                          {}
-
-    bool                sign() const                                            { return cycle.empty(); }
 
     template<class U> struct rebind
     { typedef           DequeChains<U>         other; };
@@ -57,14 +41,6 @@
 {
     typedef             OrderIndex_                                             OrderIndex;
     typedef             ChainWrapper<List<OrderIndex> >                         Chain;
-    typedef             Chain                                                   Cycle;
-
-    Cycle               cycle;
-
-                        ListChains()                                            {}
-                        ListChains(Cycle z): cycle(z)                           {}
-    
-    bool                sign() const                                            { return cycle.empty(); }
     
     template<class U> struct rebind
     { typedef           ListChains<U>           other; };
--- a/include/topology/dynamic-persistence.h	Fri May 01 15:36:25 2009 -0700
+++ b/include/topology/dynamic-persistence.h	Fri May 01 15:09:38 2009 -0700
@@ -11,27 +11,31 @@
 static Counter*  cChainLength =             GetCounter("persistence/pair/chainlength");     // the size of matrix V in R=DV decomposition
 #endif // COUNTERS
 
-template<class Data, class OrderDescriptor_, class ConsistencyIndex>
-struct TrailData_: public Data
+template<class Data_, class ChainTraits_, class ContainerTraits_, class ConsistencyIndex_>
+struct TrailData: public PairCycleData<Data_, ChainTraits_, ContainerTraits_, 
+                                       TrailData<Data_, ChainTraits_, ContainerTraits_, ConsistencyIndex_> >
 {
-    typedef TrailData_<Data, OrderDescriptor_, ConsistencyIndex>                Self;
+    typedef     Data_                                                                   Data;
+    typedef     ConsistencyIndex_                                                       ConsistencyIndex;
 
-    typedef typename OrderTraits<typename OrderDescriptor_::
-                                          template RebindData<Self>::
-                                          other>::Index                         OrderIndex;
-    typedef typename OrderDescriptor_::
-                     Chains::template rebind<OrderIndex>::other::Chain          Trail;
+    typedef     PairCycleData<Data_, ChainTraits_, ContainerTraits_, TrailData>         Parent;
+    typedef     TrailData<Data_, ChainTraits_, ContainerTraits_, ConsistencyIndex_>     Self;
+
+    // typedef     typename ContainerTraits_::template rebind<Self>::other                 ContainerTraits;
+    // typedef     typename ContainerTraits::Index                                         Index;
+    // typedef     typename ChainTraits_::template rebind<Index>::other                    ChainTraits;
+    // typedef     typename ChainTraits::Chain                                             Chain;
+    typedef     typename Parent::Index                                                  Index;
+    typedef     typename Parent::Chain                                                  Chain;
+    typedef     Chain                                                                   Trail;
     
     template<class Comparison>
-    struct ConsistencyComparison
+    struct ConsistencyComparison: public std::binary_function<const Index&, const Index&, bool>
     {
-        typedef             const OrderIndex&                                   first_argument_type;
-        typedef             const OrderIndex&                                   second_argument_type;
-        typedef             bool                                                result_type;
+                        ConsistencyComparison(const Comparison& cmp = Comparison()): 
+                            cmp_(cmp)                                                   {}
 
-        ConsistencyComparison(const Comparison& cmp = Comparison()): cmp_(cmp)  {}
-
-        bool operator()(const OrderIndex& a, const OrderIndex& b) const         { return cmp_(a->consistency, b->consistency); }
+        bool            operator()(const Index& a, const Index& b) const                { return cmp_(a->consistency, b->consistency); }
 
         Comparison      cmp_;
     };
@@ -56,25 +60,28 @@
 // That way one could provide a simple consistency descriptor that just stored some integers describing the original 
 // position, or one could provide consistency that is references into the complex
 template<class Data_ =                  Empty<>, 
-         class OrderDescriptor_ =       VectorOrderDescriptor<>,
+         class ChainTraits_ =           VectorChains<>,
+         class Comparison_ =            GreaterComparison<>,
+         class ContainerTraits_ =       VectorContainer<>,
          class ConsistencyIndex_ =      size_t,
-         class ConsistencyComparison_ = std::less<ConsistencyIndex_> >
+         class ConsistencyComparison_ = std::less<ConsistencyIndex_>,
+         class Element_ =               TrailData<Data_, ChainTraits_, ContainerTraits_, ConsistencyIndex_> >
 class DynamicPersistenceTrails: 
-    public StaticPersistence<TrailData_<Data_, OrderDescriptor_, ConsistencyIndex_>, 
-                             OrderDescriptor_>
+    public StaticPersistence<Data_, ChainTraits_, Comparison_, ContainerTraits_, Element_>
 {
     public:
         typedef         Data_                                                           Data;
-        typedef         TrailData_<Data_, OrderDescriptor_, ConsistencyIndex_>          TrailData;
-        typedef         StaticPersistence<TrailData, OrderDescriptor_>                  Parent;
+        typedef         Element_                                                        Element;
+        typedef         StaticPersistence<Data_, ChainTraits_, Comparison_,
+                                          ContainerTraits_, Element_>                   Parent;
  
-        typedef         typename Parent::Traits                                         Traits;
-        typedef         typename Parent::OrderDescriptor                                OrderDescriptor;
+        typedef         typename Parent::ContainerTraits                                Traits;
+        typedef         typename Parent::Order                                          Order;
         typedef         typename Parent::OrderComparison                                OrderComparison;
         typedef         typename Parent::OrderIndex                                     OrderIndex;
         typedef         ConsistencyIndex_                                               ConsistencyIndex;
         typedef         ThreeOutcomeCompare<
-                            typename TrailData::
+                            typename Element::
                             template ConsistencyComparison<ConsistencyComparison_> >    ConsistencyComparison;
 
         /**
@@ -86,7 +93,7 @@
          */
         template<class Filtration>      DynamicPersistenceTrails(const Filtration&              f, 
                                                                  const OrderComparison&         ocmp =  OrderComparison(),
-                                                                 const ConsistencyComparison_&  ccmp =  ConsistencyComparison_());
+                                                                 const ConsistencyComparison&   ccmp =  ConsistencyComparison());
         
         void                            pair_simplices();
 
@@ -143,23 +150,27 @@
         ConsistencyComparison           ccmp_;
 };
 
-template<class Data, class OrderDescriptor_, class ConsistencyIndex>
-struct ChainData_: public Data
+template<class Data_, class ChainTraits_, class ContainerTraits_, class ConsistencyIndex_>
+struct ChainData: public PairCycleData<Data_, ChainTraits_, ContainerTraits_,
+                                       ChainData<Data_, ChainTraits_, ContainerTraits_, ConsistencyIndex_> >
 {
-    typedef ChainData_<Data, OrderDescriptor_, ConsistencyIndex>                Self;
+    typedef     Data_                                                                   Data;
+    typedef     ConsistencyIndex_                                                       ConsistencyIndex;
 
-    typedef typename OrderTraits<typename OrderDescriptor_::
-                                          template RebindData<Self>::
-                                          other>::Index                         OrderIndex;
-    typedef typename OrderDescriptor_::
-                     Chains::template rebind<OrderIndex>::other::Chain          Chain;
+    typedef     PairCycleData<Data_, ChainTraits_, ContainerTraits_, ChainData>         Parent;
+    typedef     ChainData<Data_, ChainTraits_, ContainerTraits_, ConsistencyIndex_>     Self;
+
+    typedef     typename Parent::Index                                                  Index;
+    typedef     typename Parent::Chain                                                  Chain;
+    typedef     Chain                                                                   Trail;
     
     template<class Comparison>
-    struct ConsistencyComparison: public std::binary_function<const OrderIndex&, const OrderIndex&, bool>
+    struct ConsistencyComparison: public std::binary_function<const Index&, const Index&, bool>
     {
-        ConsistencyComparison(const Comparison& cmp = Comparison()): cmp_(cmp)  {}
+                        ConsistencyComparison(const Comparison& cmp = Comparison()): 
+                            cmp_(cmp)                                                   {}
 
-        bool operator()(const OrderIndex& a, const OrderIndex& b) const         { return cmp_(a->consistency, b->consistency); }
+        bool            operator()(const Index& a, const Index& b) const                { return cmp_(a->consistency, b->consistency); }
 
         Comparison      cmp_;
     };
@@ -183,25 +194,28 @@
  *                          which serves as a prototypical class
  */
 template<class Data_ =                  Empty<>, 
-         class OrderDescriptor_ =       VectorOrderDescriptor<>,
+         class ChainTraits_ =           VectorChains<>,
+         class Comparison_ =            GreaterComparison<>,
+         class ContainerTraits_ =       VectorContainer<>,
          class ConsistencyIndex_ =      size_t,
-         class ConsistencyComparison_ = std::less<ConsistencyIndex_> >
+         class ConsistencyComparison_ = std::less<ConsistencyIndex_>,
+         class Element_ =               ChainData<Data_, ChainTraits_, ContainerTraits_, ConsistencyIndex_> >
 class DynamicPersistenceChains: 
-    public StaticPersistence<ChainData_<Data_, OrderDescriptor_, ConsistencyIndex_>, 
-                             OrderDescriptor_>
+    public StaticPersistence<Data_, ChainTraits_, Comparison_, ContainerTraits_, Element_>
 {
     public:
         typedef         Data_                                                           Data;
-        typedef         ChainData_<Data_, OrderDescriptor_, ConsistencyIndex_>          ChainData;
-        typedef         StaticPersistence<ChainData, OrderDescriptor_>                  Parent;
+        typedef         Element_                                                        Element;
+        typedef         StaticPersistence<Data_, ChainTraits_, Comparison_,
+                                          ContainerTraits_, Element_>                   Parent;
  
-        typedef         typename Parent::Traits                                         Traits;
-        typedef         typename Parent::OrderDescriptor                                OrderDescriptor;
+        typedef         typename Parent::ContainerTraits                                Traits;
+        typedef         typename Parent::Order                                          Order;
         typedef         typename Parent::OrderComparison                                OrderComparison;
         typedef         typename Parent::OrderIndex                                     OrderIndex;
         typedef         ConsistencyIndex_                                               ConsistencyIndex;
         typedef         ThreeOutcomeCompare<
-                            typename ChainData::
+                            typename Element::
                             template ConsistencyComparison<ConsistencyComparison_> >    ConsistencyComparison;
 
         /**
@@ -213,7 +227,7 @@
          */
         template<class Filtration>      DynamicPersistenceChains(const Filtration&              f, 
                                                                  const OrderComparison&         ocmp =  OrderComparison(),
-                                                                 const ConsistencyComparison_&  ccmp =  ConsistencyComparison_());
+                                                                 const ConsistencyComparison&   ccmp =  ConsistencyComparison());
         
         void                            pair_simplices();
 
--- a/include/topology/dynamic-persistence.hpp	Fri May 01 15:36:25 2009 -0700
+++ b/include/topology/dynamic-persistence.hpp	Fri May 01 15:09:38 2009 -0700
@@ -22,25 +22,25 @@
 
 /* Trails */
 
-template<class D, class OD, class CI, class CC>
+template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
 template<class Filtration>
-DynamicPersistenceTrails<D,OD,CI,CC>::
-DynamicPersistenceTrails(const Filtration& f, const OrderComparison& ocmp, const CC& ccmp):
+DynamicPersistenceTrails<D,CT,Cmp,OT,CI,CC,E>::
+DynamicPersistenceTrails(const Filtration& f, const OrderComparison& ocmp, const ConsistencyComparison& ccmp):
     Parent(f, ocmp), ccmp_(ccmp)
 {}
         
-template<class D, class OD, class CI, class CC>
+template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
 void
-DynamicPersistenceTrails<D,OD,CI,CC>::
+DynamicPersistenceTrails<D,CT,Cmp,OT,CI,CC,E>::
 pair_simplices()
 { 
     Parent::pair_simplices(begin(), end(), PairingTrailsVisitor(begin(), ccmp_));
 }
 
-template<class D, class OD, class CI, class CC>
+template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
 template<class Visitor>
 bool
-DynamicPersistenceTrails<D,OD,CI,CC>::
+DynamicPersistenceTrails<D,CT,Cmp,OT,CI,CC,E>::
 transpose(OrderIndex i, const Visitor& visitor)
 {
 #if LOGGING
@@ -49,7 +49,7 @@
 
     Count(cTransposition);
     typedef                 OrderIndex                                  Index;
-    typedef                 typename TrailData::Trail::iterator         TrailIterator;
+    typedef                 typename Element::Trail::iterator           TrailIterator;
 
     visitor.transpose(i);
     
@@ -222,9 +222,9 @@
     return false; // to avoid compiler complaints; we should never reach this point
 }
 
-template<class D, class OD, class CI, class CC>
+template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
 void
-DynamicPersistenceTrails<D,OD,CI,CC>::
+DynamicPersistenceTrails<D,CT,Cmp,OT,CI,CC,E>::
 swap(OrderIndex i, OrderIndex j)
 {
     std::swap<Data>(*i, *j);
@@ -234,9 +234,9 @@
     std::swap(i->trail, j->trail);
 }
 
-template<class D, class OD, class CI, class CC>
+template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
 void
-DynamicPersistenceTrails<D,OD,CI,CC>::
+DynamicPersistenceTrails<D,CT,Cmp,OT,CI,CC,E>::
 pairing_switch(OrderIndex i, OrderIndex j)
 {
     OrderIndex i_pair = i->pair;
@@ -262,16 +262,16 @@
 
 /* Chains */
 
-template<class D, class OD, class CI, class CC>
+template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
 template<class Filtration>
-DynamicPersistenceChains<D,OD,CI,CC>::
-DynamicPersistenceChains(const Filtration& f, const OrderComparison& ocmp, const CC& ccmp):
+DynamicPersistenceChains<D,CT,Cmp,OT,CI,CC,E>::
+DynamicPersistenceChains(const Filtration& f, const OrderComparison& ocmp, const ConsistencyComparison& ccmp):
     Parent(f, ocmp), ccmp_(ccmp)
 {}
         
-template<class D, class OD, class CI, class CC>
+template<class D, class CT, class Cmp, class OT, class CI, class CC, class E>
 void
-DynamicPersistenceChains<D,OD,CI,CC>::
+DynamicPersistenceChains<D,CT,Cmp,OT,CI,CC,E>::
 pair_simplices()
 { 
     Parent::pair_simplices(begin(), end(), PairingChainsVisitor(begin(), ccmp_, size()));
--- a/include/topology/order.h	Fri May 01 15:36:25 2009 -0700
+++ b/include/topology/order.h	Fri May 01 15:09:38 2009 -0700
@@ -1,69 +1,28 @@
 #ifndef __ORDER_H__
 #define __ORDER_H__
 
-#include "cycles.h"
 #include "utilities/types.h"
 #include "utilities/indirect.h"
 
 #include <vector>
-#include <list>
 
 //#include <iostream>
 #include <sstream>
 #include <string>
 
-template<class OrderDescriptor>
-struct OrderTraits {};
-
-/** 
- * Class: VectorOrderDescriptor
- * Class that stores a dense order of simplices in a vector. 
- * That prevents it from performing efficient insertions.
- */
-template<class Chains_ =    VectorChains<>,
-         class Data_ =      Empty<> >
-struct VectorOrderDescriptor: 
-    public Chains_::template rebind<typename OrderTraits<VectorOrderDescriptor<Chains_, Data_> >::Index>::other,
-    public Data_
-{
-    typedef         VectorOrderDescriptor<Chains_, Data_>                       Self;
-    
-    typedef         typename OrderTraits<Self>::Index                           OrderIndex;
-    typedef         typename Chains_::template rebind<OrderIndex>::other        Chains;
-    typedef         Data_                                                       Data;
-
-    template<class OtherData_> struct                                           RebindData
-    { typedef       VectorOrderDescriptor<Chains_, OtherData_>                  other; };
 
-  
-    // TODO: Do we need any of these constructors?
-    VectorOrderDescriptor(const Data& d = Data()):
-        Data(d)                                                                 {}
-    VectorOrderDescriptor(typename Chains::Cycle z, const Data& d = Data()):
-        Chains(z), Data(d)                                                      {}
-    VectorOrderDescriptor(OrderIndex i, const Data& d = Data()):
-        Data(d), pair(i)                                                        {}
-    VectorOrderDescriptor(OrderIndex i, typename Chains::Cycle z, const Data& d = Data()):
-        Chains(z), Data(d), pair(i)                                             {}
+template<class Element_ = Empty<> >
+struct VectorContainer
+{
+    typedef         Element_                                                    Element;
+    typedef         std::vector<Element>                                        Container;
 
-    OrderIndex      pair;
-};
-
-// Specialization for VectorOrderDescriptor
-template<class Chains, class Data>
-struct OrderTraits<VectorOrderDescriptor<Chains, Data> >
-{
-    typedef         VectorOrderDescriptor<Chains, Data>                         Descriptor;
-
-    typedef         std::vector<Descriptor>                                     Order;
-    typedef         Descriptor                                                  Element;
-    typedef         typename Order::iterator                                    Index;
-    typedef         ThreeOutcomeCompare<std::greater<Index> >                   Comparison;
+    typedef         typename Container::iterator                                Index;
 
     class OutputMap
     {
         public:
-                                OutputMap(const Order& order):
+                                OutputMap(const Container& order):
                                     bg_(order.begin())                          {}
 
             // returns a string with (i - bg_)                                
@@ -74,50 +33,18 @@
             }
 
         private:
-            typename Order::const_iterator          bg_;
+            typename Container::const_iterator          bg_;
     };
-};
 
-#if 0
-template<class Chains_      = VectorChains<>,
-         class Data_        = Empty>
-struct ListOrderDescriptor: 
-    public Chains_::template rebding<typename OrderTraits<ListOrderDescriptor<Chains_, Data_> >::Index>::other,
-    public Data_
-{
-    typedef         ListOrderDescriptor<Chains_, Data_>                         Self;
-
-    typedef         typename OrderTraits<Self>::Index                           OrderIndex;
-    typedef         typename Chains_::template rebind<OrderIndex>::other        Chains;
-    typedef         Data_                                                       Data;
-
-    template<class OtherData_> struct                                           RebindData
-    { typedef       ListOrderDescriptor<Chains_, OtherData_>                    other; };
-    
-    OrderIndex      pair;
+    template<class U> struct rebind
+    { typedef           VectorContainer<U>              other; };
 };
 
-
-// Specialization for ListOrderDescriptor
-template<class Chains, class Data>
-struct OrderTraits<ListOrderDescriptor<Chains, Data> >
+template<class Index = int>
+struct GreaterComparison: public std::greater<Index>
 {
-    typedef         ListOrderDescriptor<Chains, Data>                       Descriptor;
-
-    typedef         std::list<Descriptor>                                   Order;
-    typedef         Descriptor                                              Element;
-    typedef         Order::iterator                                         Index;
-
-    // FIXME
-    typedef         std::less<Index>                                        OrderComparison;
-    typedef         ConsistencyCmp<Index>                                   ConsistencyComparison;      
-
-    static Index    begin(Order& order)                                     { return order.begin(); }
-    static Index    end(Order& order)                                       { return order.end(); }
-    
-    template<class Comparison>
-    static void     sort(Order& order, const Comparison& cmp)               { order.sort(cmp); }
+    template<class U> struct rebind
+    { typedef           GreaterComparison<U>            other; };
 };
-#endif
 
 #endif // __ORDER_H__
--- a/include/topology/static-persistence.h	Fri May 01 15:36:25 2009 -0700
+++ b/include/topology/static-persistence.h	Fri May 01 15:09:38 2009 -0700
@@ -2,8 +2,35 @@
 #define __STATIC_PERSISTENCE_H__
 
 #include "order.h"
+#include "cycles.h"
 #include "filtration.h"
 
+#include <utilities/types.h>
+
+
+template<class Data_, class ChainTraits_, class ContainerTraits_, class Element_ = use_default> 
+struct PairCycleData: public Data_
+{
+    typedef     Data_                                                                   Data;
+    typedef     typename if_default<Element_, PairCycleData>::type                      Element;
+    typedef     PairCycleData<Data, ChainTraits_, ContainerTraits_, Element>            Self;
+
+    typedef     typename ContainerTraits_::template rebind<Element>::other              ContainerTraits;
+    typedef     typename ContainerTraits::Index                                         Index;
+    typedef     typename ChainTraits_::template rebind<Index>::other                    ChainTraits;
+    typedef     typename ChainTraits::Chain                                             Chain;
+    typedef     Chain                                                                   Cycle;
+
+                PairCycleData(Index p = Index(), const Cycle& z = Cycle(), const Data& d = Data()):
+                    Data(d), pair(p), cycle(z)
+                {}
+    
+    bool        sign() const                                                            { return cycle.empty(); }
+
+    Index       pair;
+    Cycle       cycle;
+};
+
 /**
  * Class: StaticPersistence
  * The class that encapsulates order and pairing information as well as 
@@ -15,8 +42,11 @@
  *   OrderDescriptor_ -     class describing how the order is stored; it defaults to <VectorOrderDescriptor> 
  *                          which serves as a prototypical class
  */
-template<class Data_ = Empty<>,
-         class OrderDescriptor_ =   VectorOrderDescriptor<> >
+template<class Data_ =              Empty<>,
+         class ChainTraits_ =       VectorChains<>,
+         class Comparison_ =        GreaterComparison<>,
+         class ContainerTraits_ =   VectorContainer<>,
+         class Element_ =           PairCycleData<Data_, ChainTraits_, ContainerTraits_> >
 class StaticPersistence
 {
     public:
@@ -24,22 +54,20 @@
         // The data type stored in each order element
         typedef                         Data_                                                   Data;
 
-        /* Typedefs: Order
-         * Types associated with the order
-         *
-         * OrderDescriptor -        template parameter rebound with `Data` carrying all the necessary information
-         * Order -                  the container class itself
-         * OrderIndex -             iterator into the Order
-         * OrderComparison -        a class for comparing OrderIndices
-         */
-        typedef                         typename OrderDescriptor_::
-                                                 template RebindData<Data>::
-                                                 other                                          OrderDescriptor;
-        typedef                         OrderTraits<OrderDescriptor>                            Traits;
-        typedef                         typename Traits::Order                                  Order;
-        typedef                         typename Traits::Index                                  OrderIndex;
-        typedef                         typename Traits::Element                                OrderElement;
-        typedef                         typename Traits::Comparison                             OrderComparison;
+        typedef                         Element_                                                Element;
+        typedef                         typename ContainerTraits_::
+                                                    template rebind<Element>::other             ContainerTraits;
+        typedef                         typename ContainerTraits::Container                     Container;
+        typedef                         Container                                               Order;
+        typedef                         typename ContainerTraits::Index                         OrderIndex;
+        typedef                         typename ContainerTraits::Element                       OrderElement;
+        typedef                         typename ChainTraits_::
+                                                    template rebind<OrderIndex>::other          ChainTraits;
+        typedef                         typename ChainTraits::Chain                             Chain;
+        typedef                         Chain                                                   Cycle;
+        
+        typedef                         typename Comparison_::
+                                                    template rebind<OrderIndex>::other          OrderComparison;
 
         /* Constructor: StaticPersistence()
          * TODO: write a description
--- a/include/topology/static-persistence.hpp	Fri May 01 15:36:25 2009 -0700
+++ b/include/topology/static-persistence.hpp	Fri May 01 15:09:38 2009 -0700
@@ -14,9 +14,9 @@
 static Counter*  cPersistencePairCycleLength =              GetCounter("persistence/pair/cyclelength");
 #endif // COUNTERS
 
-template<class D, class OD>
+template<class D, class CT, class Cmp, class OT, class E>
 template<class Filtration>
-StaticPersistence<D, OD>::
+StaticPersistence<D, CT, Cmp, OT, E>::
 StaticPersistence(const Filtration& filtration, 
                   const OrderComparison& ocmp):
     order_(filtration.size()),
@@ -26,9 +26,6 @@
     OffsetMap<typename Filtration::IntermediateIndex, OrderIndex>       om(0, ocur);            // TODO: this is customized for std::vector Order
     for (typename Filtration::Index cur = filtration.begin(); cur != filtration.end(); ++cur, ++ocur)
     {
-        // Convert the Filtration::IndexBoundary into a Cycle, and 
-        typedef typename OrderDescriptor::Chains::Cycle         Cycle;
-
         OrderElement& oe = *ocur;
         oe.pair = ocur;
 
@@ -37,10 +34,10 @@
     }
 }
 
-template<class D, class OD>
+template<class D, class CT, class Cmp, class OT, class E>
 template<class Visitor>
 void 
-StaticPersistence<D, OD>::
+StaticPersistence<D, CT, Cmp, OT, E>::
 pair_simplices(OrderIndex bg, OrderIndex end, const Visitor& visitor)
 {
 #if LOGGING
@@ -55,8 +52,7 @@
         rLog(rlPersistence, "Simplex %s", outmap(j).c_str());
 
         OrderElement& oe = *j;
-        typedef typename OrderDescriptor::Chains::Cycle         Cycle;
-        Cycle& z = oe.cycle;
+        typename OrderElement::Cycle& z = oe.cycle;
         rLog(rlPersistence, "  has boundary: %s", z.tostring(outmap).c_str());
         
         CountNum(cPersistencePairBoundaries, oe.cycle.size());
--- a/include/utilities/types.h	Fri May 01 15:36:25 2009 -0700
+++ b/include/utilities/types.h	Fri May 01 15:09:38 2009 -0700
@@ -21,6 +21,18 @@
 template<typename T = void>
 struct      Empty                   {};
 
+
+struct      use_default             {};
+
+template<class T, class Default>
+struct      if_default
+{ typedef   T           type; };
+
+template<class Default>
+struct      if_default<use_default, Default>
+{ typedef   Default     type; };
+
+
 template<typename T>
 std::ostream& operator<<(std::ostream& out, Empty<T> e) { return out; }