diff options
author | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-01-03 15:30:49 +0000 |
---|---|---|
committer | mcarrier <mcarrier@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2018-01-03 15:30:49 +0000 |
commit | 82dca01519298502af4d478f47cd8e42d0d9478f (patch) | |
tree | e884d366d973736c05c52990b0ac3889f2990af1 /src/Kernels/example/kernel_basic_example.cpp | |
parent | 5708c93251625133598739f42ed106aac83bf18a (diff) |
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/kernels@3110 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 95fd5b9e4cd4738ecdeaeb27f20d267816b7bead
Diffstat (limited to 'src/Kernels/example/kernel_basic_example.cpp')
-rw-r--r-- | src/Kernels/example/kernel_basic_example.cpp | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/Kernels/example/kernel_basic_example.cpp b/src/Kernels/example/kernel_basic_example.cpp index 8e9925c5..46e42c9d 100644 --- a/src/Kernels/example/kernel_basic_example.cpp +++ b/src/Kernels/example/kernel_basic_example.cpp @@ -20,29 +20,41 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#define NUMPI 3.14159265359 #include <gudhi/kernel.h> -int main() { +void usage(int nbArgs, char *const progName) { + std::cerr << "Error: Number of arguments (" << nbArgs << ") is not correct\n"; + std::cerr << "Usage: " << progName << " PD1 PD2 \n"; + std::cerr << " i.e.: " << progName << " ../../../../data/persistence_diagram/PD1 ../../../../data/persistence_diagram/PD2 \n"; + exit(-1); // ----- >> +} + +int main(int argc, char **argv) { - std::vector< std::pair<double, double> > v1, v2; + if (argc != 3) usage(argc, argv[0]); double sigma = 2; double tau = 5; - v1.emplace_back(2.7, 3.7); - v1.emplace_back(9.6, 14.); - v1.emplace_back(34.2, 34.974); - - v2.emplace_back(2.8, 4.45); - v2.emplace_back(9.5, 14.1); - - std::cout << "SW exact = " << Gudhi::kernel::sw (v1, v2) << std::endl; - std::cout << "SW approx = " << Gudhi::kernel::approx_sw (v1, v2) << std::endl; - std::cout << "PSS exact = " << Gudhi::kernel::pss (v1,v2,sigma) << std::endl; - std::cout << "PSS approx = " << Gudhi::kernel::approx_pss (v1,v2,sigma) << std::endl; - std::cout << "PWG exact = " << Gudhi::kernel::lpwg (v1,v2,sigma) << std::endl; - std::cout << "PWG approx = " << Gudhi::kernel::approx_lpwg (v1,v2,sigma) << std::endl; - std::cout << "GPWG exact = " << Gudhi::kernel::gpwg (v1,v2,sigma,tau) << std::endl; - std::cout << "GPWG approx = " << Gudhi::kernel::approx_gpwg (v1,v2,sigma,tau) << std::endl; + std::string PDname1(argv[1]); std::string PDname2(argv[2]); + std::vector< std::pair<double, double> > v1, v2; std::string line; double b,d; + + std::ifstream input1(PDname1); + while(std::getline(input1,line)){ + std::stringstream stream(line); stream >> b; stream >> d; v1.push_back(std::pair<double,double>(b,d)); + } + + std::ifstream input2(PDname2); + while(std::getline(input2,line)){ + std::stringstream stream(line); stream >> b; stream >> d; v2.push_back(std::pair<double,double>(b,d)); + } + + std::cout << "SWK exact = " << Gudhi::kernel::swk (v1,v2,sigma) << std::endl; + std::cout << "SWK approx = " << Gudhi::kernel::approx_swk (v1,v2,sigma) << std::endl; + std::cout << "PSSK exact = " << Gudhi::kernel::pssk (v1,v2,sigma) << std::endl; + std::cout << "PSSK approx = " << Gudhi::kernel::approx_pssk (v1,v2,sigma) << std::endl; + std::cout << "LPWGK exact = " << Gudhi::kernel::lpwgk (v1,v2,sigma) << std::endl; + std::cout << "LPWGK approx = " << Gudhi::kernel::approx_lpwgk (v1,v2,sigma) << std::endl; + std::cout << "GPWGK exact = " << Gudhi::kernel::gpwgk (v1,v2,sigma,tau) << std::endl; + std::cout << "GPWGK approx = " << Gudhi::kernel::approx_gpwgk (v1,v2,sigma,tau) << std::endl; } |