From 318c309206f1cffcc17c9333bb6ac9e2f90b7610 Mon Sep 17 00:00:00 2001 From: pdlotko Date: Fri, 31 Mar 2017 13:22:29 +0000 Subject: solved problem with cmake. git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/gudhi_stat@2294 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 34fc791c80d9e66ab18e992f73bbf3252b3d5e1e --- src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp | 114 +++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp (limited to 'src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp') diff --git a/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp b/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp new file mode 100644 index 00000000..5556a8ee --- /dev/null +++ b/src/Gudhi_stat/utilities/Hausdorff_subsampling.cpp @@ -0,0 +1,114 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): Pawel Dlotko + * + * Copyright (C) 2015 INRIA (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +#include +#include +#include +#include + + +using namespace Gudhi; +using namespace Gudhi::Gudhi_stat; + + + +int main( int argc , char** argv ) +{ + std::cout << "The parameters of this program are : " << std::endl; + std::cout << "(a) a name of a file with points," << std:: endl; + std::cout << "(b) a number of repetitions of bootstrap (integer)," << std::endl; + std::cout << "(c) a size of subsample (integer, smaller than the number of points," << std::endl; + std::cout << "(d) a quantile (real number between 0 and 1. If you do not know what to set, set it to 0.95." << std::endl; + if ( argc != 5 ) + { + std::cerr << "Wrong number of parameters, the program will now terminate.\n"; + return 1; + } + + const char* filename = argv[1]; + size_t number_of_repetitions_of_subsampling = (size_t)atoi( argv[2] ); + size_t size_of_subsample = (size_t)atoi( argv[3] ); + double quantile = atof( argv[4] ); + + std::cout << "Now we will read points from the file : " << filename << " and then perform " << number_of_repetitions_of_subsampling << " times the subsampling on it by choosing subsample of a size " << size_of_subsample << std::endl; + + std::vector< std::vector< double > > points = read_numbers_from_file_line_by_line( filename ); + /* + std::vector< std::vector< double > > points; + std::vector< double > point1(2); + point1[0] = -1; + point1[1] = 0; + std::vector< double > point2(2); + point2[0] = 1; + point2[1] = 0; + std::vector< double > point3(2); + point3[0] = -1; + point3[1] = 3; + std::vector< double > point4(2); + point4[0] = 1; + point4[1] = 3; + points.push_back( point1 ); + points.push_back( point2 ); + points.push_back( point3 ); + points.push_back( point4 ); + + + std::vector< std::vector > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector , Euclidean_distance >( points ); + Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points ); + + std::vector characteristic_of_all_points = {0,1,2,3}; + std::vector characteristic_of_subsampled_points = {2,3}; + std::cerr << "DISTANCE BETWEEN SAMPLE AND SUBSAMPLE: " << distance( characteristic_of_subsampled_points , characteristic_of_all_points ) << std::endl; + */ + + + std::cout << "Read : " << points.size() << " points.\n"; + + //comute all-to-all distance matrix: + std::vector< std::vector > all_to_all_distance_matrix_between_points = compute_all_to_all_distance_matrix_between_points< std::vector , Euclidean_distance >( points ); + Hausdorff_distance_between_subspace_and_the_whole_metric_space distance( all_to_all_distance_matrix_between_points ); + identity< std::vector > identity_char; + + + + + + + //and now we can run the real bootstrap. + //template < typename PointCloudCharacteristics , typename CharacteristicFunction , typename DistanceBetweenPointsCharacteristics > + //In this case, the PointCloudCharacteristics is just a vector of numbers of points (in a order fixed on points vector). + //CharacteristicFunction is just identity, transforming std::vector< size_t > to itself. + //DistanceBetweenPointsCharacteristics is the place were all happens. This class have the information about the coordinates of the points, and allows to compute a Hausdorff distance between + //the collection of all points, and the subsample. + double result = bootstrap< + std::vector< size_t > , //PointCloudCharacteristics + identity< std::vector > , //CharacteristicFunction + Hausdorff_distance_between_subspace_and_the_whole_metric_space //DistanceBetweenPointsCharacteristics. This function have the information about point's coordinates. + > + ( points.size() , identity_char , distance , number_of_repetitions_of_subsampling , size_of_subsample , quantile ); + + std::cout << "result of the subsampling : " << result << std::endl; + + + return 0; +} -- cgit v1.2.3