Moved l2distance.h into include/geometry dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Thu, 09 Apr 2009 14:43:37 -0700
branchdev
changeset 122 51a7ed5b51f0
parent 121 b2103b289f06
child 123 c50e7020a1e4
Moved l2distance.h into include/geometry
examples/cohomology/rips-pairwise-cohomology.cpp
examples/consistency/rips-consistency-zigzag.cpp
examples/rips/l2distance.h
examples/rips/rips-pairwise.cpp
examples/rips/rips-zigzag.cpp
include/geometry/l2distance.h
--- a/examples/cohomology/rips-pairwise-cohomology.cpp	Thu Apr 09 14:39:12 2009 -0700
+++ b/examples/cohomology/rips-pairwise-cohomology.cpp	Thu Apr 09 14:43:37 2009 -0700
@@ -1,6 +1,8 @@
 #include <topology/cohomology-persistence.h>
 #include <topology/rips.h>
 
+#include <geometry/l2distance.h>
+
 #include <utilities/containers.h>           // for BackInsertFunctor
 #include <utilities/timer.h>
 
@@ -9,8 +11,6 @@
 #include <boost/tuple/tuple.hpp>
 #include <boost/program_options.hpp>
 
-#include "../rips/l2distance.h"
-
 typedef     PairwiseDistances<PointContainer, L2Distance>           PairDistances;
 typedef     PairDistances::DistanceType                             DistanceType;
 typedef     PairDistances::IndexType                                Vertex;
--- a/examples/consistency/rips-consistency-zigzag.cpp	Thu Apr 09 14:39:12 2009 -0700
+++ b/examples/consistency/rips-consistency-zigzag.cpp	Thu Apr 09 14:43:37 2009 -0700
@@ -1,8 +1,10 @@
 #include <topology/rips.h>
 #include <topology/zigzag-persistence.h>
+
+#include <geometry/l2distance.h>    // Point, PointContainer, L2DistanceType, read_points
+
 #include <utilities/types.h>
 #include <utilities/containers.h>
-
 #include <utilities/log.h>
 #include <utilities/memory.h>       // for report_memory()
 #include <utilities/timer.h>
@@ -18,8 +20,6 @@
 #include <boost/program_options.hpp>
 #include <boost/progress.hpp>
 
-#include "../rips/l2distance.h"         // Point, PointContainer, L2DistanceType
-
 #ifdef COUNTERS
 static Counter*  cComplexSize =                     GetCounter("rips/size");
 static Counter*  cOperations =                      GetCounter("rips/operations");
--- a/examples/rips/l2distance.h	Thu Apr 09 14:39:12 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#ifndef __L2_DISTANCE_H__
-#define __L2_DISTANCE_H__
-
-#include <utilities/types.h>
-
-#include <vector>
-#include <fstream>
-#include <functional>
-#include <cmath>
-
-
-typedef     std::vector<double>                                     Point;
-typedef     std::vector<Point>                                      PointContainer;
-
-struct L2Distance:
-    public std::binary_function<const Point&, const Point&, double>
-{
-    result_type     operator()(const Point& p1, const Point& p2) const
-    {
-        AssertMsg(p1.size() == p2.size(), "Points must be in the same dimension (in L2Distance): dim1=%d, dim2=%d", p1.size(), p2.size());
-        result_type sum = 0;
-        for (size_t i = 0; i < p1.size(); ++i)
-            sum += (p1[i] - p2[i])*(p1[i] - p2[i]);
-
-        return sqrt(sum);
-    }
-};
-
-void    read_points(const std::string& infilename, PointContainer& points, Dimension ambient)
-{
-    std::ifstream in(infilename.c_str());
-    while(in)
-    {
-        points.push_back(Point());
-        for (unsigned i = 0; i < ambient; ++i)
-        {
-            double      x;
-            in >> x;
-            if (!in) { points.pop_back(); break; }
-            points.back().push_back(x);
-        }
-    }
-}
-
-#endif // __L2_DISTANCE_H__
--- a/examples/rips/rips-pairwise.cpp	Thu Apr 09 14:39:12 2009 -0700
+++ b/examples/rips/rips-pairwise.cpp	Thu Apr 09 14:43:37 2009 -0700
@@ -4,6 +4,8 @@
 #include <topology/dynamic-persistence.h>
 #include <topology/persistence-diagram.h>
 
+#include <geometry/l2distance.h>
+
 #include <utilities/containers.h>           // for BackInsertFunctor
 #include <utilities/timer.h>
 
@@ -11,7 +13,6 @@
 
 #include <boost/program_options.hpp>
 
-#include "l2distance.h"
 
 typedef         PairwiseDistances<PointContainer, L2Distance>           PairDistances;
 typedef         PairDistances::DistanceType                             DistanceType;
--- a/examples/rips/rips-zigzag.cpp	Thu Apr 09 14:39:12 2009 -0700
+++ b/examples/rips/rips-zigzag.cpp	Thu Apr 09 14:43:37 2009 -0700
@@ -3,6 +3,8 @@
 #include <utilities/types.h>
 #include <utilities/containers.h>
 
+#include <geometry/l2distance.h>    // Point, PointContainer, L2DistanceType, read_points
+
 #include <utilities/log.h>
 #include <utilities/memory.h>       // for report_memory()
 #include <utilities/timer.h>
@@ -17,8 +19,6 @@
 #include <boost/program_options.hpp>
 #include <boost/progress.hpp>
 
-#include "l2distance.h"         // Point, PointContainer, L2DistanceType
-
 #ifdef COUNTERS
 static Counter*  cComplexSize =                     GetCounter("rips/size");
 static Counter*  cOperations =                      GetCounter("rips/operations");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/geometry/l2distance.h	Thu Apr 09 14:43:37 2009 -0700
@@ -0,0 +1,45 @@
+#ifndef __L2_DISTANCE_H__
+#define __L2_DISTANCE_H__
+
+#include <utilities/types.h>
+
+#include <vector>
+#include <fstream>
+#include <functional>
+#include <cmath>
+
+
+typedef     std::vector<double>                                     Point;
+typedef     std::vector<Point>                                      PointContainer;
+
+struct L2Distance:
+    public std::binary_function<const Point&, const Point&, double>
+{
+    result_type     operator()(const Point& p1, const Point& p2) const
+    {
+        AssertMsg(p1.size() == p2.size(), "Points must be in the same dimension (in L2Distance): dim1=%d, dim2=%d", p1.size(), p2.size());
+        result_type sum = 0;
+        for (size_t i = 0; i < p1.size(); ++i)
+            sum += (p1[i] - p2[i])*(p1[i] - p2[i]);
+
+        return sqrt(sum);
+    }
+};
+
+void    read_points(const std::string& infilename, PointContainer& points, Dimension ambient)
+{
+    std::ifstream in(infilename.c_str());
+    while(in)
+    {
+        points.push_back(Point());
+        for (unsigned i = 0; i < ambient; ++i)
+        {
+            double      x;
+            in >> x;
+            if (!in) { points.pop_back(); break; }
+            points.back().push_back(x);
+        }
+    }
+}
+
+#endif // __L2_DISTANCE_H__