Added Persistence::initialize(f) + fixed minor bug LinearKernel::sign_at_negative_infinity() dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Tue, 09 Mar 2010 15:22:57 -0800
branchdev
changeset 207 6f1ed27850c8
parent 206 4a80392ab462
child 208 36ea2751f290
child 209 324354e0d3bf
Added Persistence::initialize(f) + fixed minor bug LinearKernel::sign_at_negative_infinity()
include/geometry/linear-kernel.h
include/geometry/weighted-l2distance.h
include/topology/dynamic-persistence.h
include/topology/dynamic-persistence.hpp
include/topology/static-persistence.h
include/topology/static-persistence.hpp
--- a/include/geometry/linear-kernel.h	Sat Mar 06 14:39:15 2010 -0800
+++ b/include/geometry/linear-kernel.h	Tue Mar 09 15:22:57 2010 -0800
@@ -18,7 +18,7 @@
 		static RootType				root(const T& r)									{ return r; }
 		static int					sign_at(const Function& f, const RootType& r)       { RootType y = f(r); if (y < 0) return -1; if (y > 0) return 1; return 0; }
 		static RootType				between(const RootType& r1, const RootType& r2)		{ return (r1 + r2)/2; }
-		static int					sign_at_negative_infinity(const Function& f)        { if (f.a1 < 0) return 1; if (f.a1 > 0) return -1; return 0; }
+		static int					sign_at_negative_infinity(const Function& f)        { if (f.a1 < 0) return 1; if (f.a1 > 0) return -1; if (f.a0 > 0) return 1; if (f.a0 < 0) return -1; return 0; }
 };
 
 template<class T>
--- a/include/geometry/weighted-l2distance.h	Sat Mar 06 14:39:15 2010 -0800
+++ b/include/geometry/weighted-l2distance.h	Tue Mar 09 15:22:57 2010 -0800
@@ -2,6 +2,7 @@
 #define __L2_DISTANCE_H__
 
 #include <utilities/types.h>
+#include <utilities/log.h>
 
 #include <vector>
 #include <fstream>
--- a/include/topology/dynamic-persistence.h	Sat Mar 06 14:39:15 2010 -0800
+++ b/include/topology/dynamic-persistence.h	Tue Mar 09 15:22:57 2010 -0800
@@ -83,6 +83,9 @@
         typedef         typename Element::Trail                                         Trail;
         typedef         typename Element::Cycle                                         Cycle;
 
+         /* Constructor: DynamicPersistenceTrails() */
+                                        DynamicPersistenceTrails();
+
         /**
          * Constructor: DynamicPersistenceTrails()
          * TODO: write a description
@@ -92,6 +95,9 @@
          */
         template<class Filtration>      DynamicPersistenceTrails(const Filtration& f);
         
+        template<class Filtration>
+        void                            initialize(const Filtration& f)                 { Parent::initialize(f); }
+
         void                            pair_simplices();
 
         // Function: transpose(i)
@@ -236,6 +242,9 @@
         typedef         typename Element::Chain                                         Chain;
         typedef         typename Element::Cycle                                         Cycle;
 
+        /* Constructor: DynamicPersistenceChains() */
+                                        DynamicPersistenceChains();
+
         /**
          * Constructor: DynamicPersistenceChains()
          * TODO: write a description
@@ -245,6 +254,8 @@
          */
         template<class Filtration>      DynamicPersistenceChains(const Filtration& f);
         
+        template<class Filtration>
+        void                            initialize(const Filtration& f)                 { Parent::initialize(f); }
         void                            pair_simplices();
 
         // Function: transpose(i)
--- a/include/topology/dynamic-persistence.hpp	Sat Mar 06 14:39:15 2010 -0800
+++ b/include/topology/dynamic-persistence.hpp	Tue Mar 09 15:22:57 2010 -0800
@@ -23,6 +23,12 @@
 /* Trails */
 
 template<class D, class CT, class OT, class E, class Cmp, class CCmp>
+DynamicPersistenceTrails<D,CT,OT,E,Cmp,CCmp>::
+DynamicPersistenceTrails():
+    ccmp_(consistent_order())
+{}
+
+template<class D, class CT, class OT, class E, class Cmp, class CCmp>
 template<class Filtration>
 DynamicPersistenceTrails<D,CT,OT,E,Cmp,CCmp>::
 DynamicPersistenceTrails(const Filtration& f):
@@ -290,12 +296,18 @@
 /* Chains */
 
 template<class D, class CT, class OT, class E, class Cmp, class CCmp>
+DynamicPersistenceChains<D,CT,OT,E,Cmp,CCmp>::
+DynamicPersistenceChains():
+    ccmp_(order().get<consistency>())
+{}
+
+template<class D, class CT, class OT, class E, class Cmp, class CCmp>
 template<class Filtration>
 DynamicPersistenceChains<D,CT,OT,E,Cmp,CCmp>::
 DynamicPersistenceChains(const Filtration& f):
     Parent(f), ccmp_(order().get<consistency>())
 {}
-        
+
 template<class D, class CT, class OT, class E, class Cmp, class CCmp>
 void
 DynamicPersistenceChains<D,CT,OT,E,Cmp,CCmp>::
--- a/include/topology/static-persistence.h	Sat Mar 06 14:39:15 2010 -0800
+++ b/include/topology/static-persistence.h	Tue Mar 09 15:22:57 2010 -0800
@@ -80,13 +80,21 @@
         
         typedef                         Comparison_                                             OrderComparison;
 
+        /* Constructor: StaticPersistence() */
+                                        StaticPersistence(): ocmp_(order_)                      {}
+
         /* Constructor: StaticPersistence()
          * TODO: write a description
          *
          * Template parameters:
          *   Filtration -           filtration of the complex whose persistence we are computing
          */
-        template<class Filtration>      StaticPersistence(const Filtration& f);
+        template<class Filtration>      StaticPersistence(const Filtration& f): ocmp_(order_)   { initialize(f); }
+
+        // Function: initialize(const Filtration& f)
+        // Initialize the boundary map from the Filtration
+        template<class Filtration>
+        void                            initialize(const Filtration& f);
         
         // Function: pair_simplices()                                        
         // Compute persistence of the filtration
--- a/include/topology/static-persistence.hpp	Sat Mar 06 14:39:15 2010 -0800
+++ b/include/topology/static-persistence.hpp	Tue Mar 09 15:22:57 2010 -0800
@@ -20,9 +20,9 @@
 
 template<class D, class CT, class OT, class E, class Cmp>
 template<class Filtration>
+void
 StaticPersistence<D, CT, OT, E, Cmp>::
-StaticPersistence(const Filtration& filtration):
-    ocmp_(order_)
+initialize(const Filtration& filtration)
 { 
     order_.assign(filtration.size(), OrderElement());
     rLog(rlPersistence, "Initializing persistence");