summaryrefslogtreecommitdiff
path: root/src/Subsampling/example/example_custom_kernel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Subsampling/example/example_custom_kernel.cpp')
-rw-r--r--src/Subsampling/example/example_custom_kernel.cpp38
1 files changed, 16 insertions, 22 deletions
diff --git a/src/Subsampling/example/example_custom_kernel.cpp b/src/Subsampling/example/example_custom_kernel.cpp
index 05797ebe..f87ef0b3 100644
--- a/src/Subsampling/example/example_custom_kernel.cpp
+++ b/src/Subsampling/example/example_custom_kernel.cpp
@@ -7,7 +7,7 @@
#include <iterator>
-/* The class Kernel contains a distance function defined on the set of points {0,1,2,3}
+/* The class Kernel contains a distance function defined on the set of points {0, 1, 2, 3}
* and computes a distance according to the matrix:
* 0 1 2 4
* 1 0 4 2
@@ -15,41 +15,35 @@
* 4 2 1 0
*/
class Kernel {
-public:
+ public:
typedef double FT;
typedef unsigned Point_d;
// Class Squared_distance_d
class Squared_distance_d {
- private:
+ private:
std::vector<std::vector<FT>> matrix_;
-
- public:
- Squared_distance_d()
- {
- matrix_.push_back(std::vector<FT>({0,1,2,4}));
- matrix_.push_back(std::vector<FT>({1,0,4,2}));
- matrix_.push_back(std::vector<FT>({2,4,0,1}));
- matrix_.push_back(std::vector<FT>({4,2,1,0}));
- }
-
- FT operator()(Point_d p1, Point_d p2)
- {
+ public:
+ Squared_distance_d() {
+ matrix_.push_back(std::vector<FT>({0,1,2,4}));
+ matrix_.push_back(std::vector<FT>({1,0,4,2}));
+ matrix_.push_back(std::vector<FT>({2,4,0,1}));
+ matrix_.push_back(std::vector<FT>({4,2,1,0}));
+ }
+
+ FT operator()(Point_d p1, Point_d p2) {
return matrix_[p1][p2];
}
};
// Constructor
- Kernel()
- {}
+ Kernel() {}
// Object of type Squared_distance_d
- Squared_distance_d squared_distance_d_object() const
- {
+ Squared_distance_d squared_distance_d_object() const {
return Squared_distance_d();
}
-
};
int main(void) {
@@ -57,9 +51,9 @@ int main(void) {
typedef typename K::Point_d Point_d;
K k;
- std::vector<Point_d> points = {0,1,2,3};
+ std::vector<Point_d> points = {0, 1, 2, 3};
std::vector<Point_d> results;
-
+
Gudhi::subsampling::choose_n_farthest_points(k, points, 2, std::back_inserter(results));
std::cout << "Before sparsification: " << points.size() << " points.\n";
std::cout << "After sparsification: " << results.size() << " points.\n";