diff options
author | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2019-08-08 10:44:30 +0200 |
---|---|---|
committer | ROUVREAU Vincent <vincent.rouvreau@inria.fr> | 2019-08-08 10:44:30 +0200 |
commit | c85464b9ea96d21731e710fa7d7a15e645d2c89a (patch) | |
tree | 660c3861f5fc09e7a3f3de39634b7f6fb964c7d5 /src/cython/gudhi/bottleneck.pyx | |
parent | d7e1a3a81dfa91a29e433887fcfdc73310f8db32 (diff) |
Rename bottleneck_distance module name as bottleneck. Cannot have gudhi.bottleneck_distance.bottleneck_distance and gudhi.bottleneck_distance.
Diffstat (limited to 'src/cython/gudhi/bottleneck.pyx')
-rw-r--r-- | src/cython/gudhi/bottleneck.pyx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/cython/gudhi/bottleneck.pyx b/src/cython/gudhi/bottleneck.pyx new file mode 100644 index 00000000..4b378cbc --- /dev/null +++ b/src/cython/gudhi/bottleneck.pyx @@ -0,0 +1,49 @@ +from cython cimport numeric +from libcpp.vector cimport vector +from libcpp.utility cimport pair +import os + +""" This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT. + See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details. + Author(s): Vincent Rouvreau + + Copyright (C) 2016 Inria + + Modification(s): + - YYYY/MM Author: Description of the modification +""" + +__author__ = "Vincent Rouvreau" +__copyright__ = "Copyright (C) 2016 Inria" +__license__ = "GPL v3" + +cdef extern from "Bottleneck_distance_interface.h" namespace "Gudhi::persistence_diagram": + double bottleneck(vector[pair[double, double]], vector[pair[double, double]], double) + double bottleneck(vector[pair[double, double]], vector[pair[double, double]]) + +def bottleneck_distance(diagram_1, diagram_2, e=None): + """This function returns the point corresponding to a given vertex. + + :param diagram_1: The first diagram. + :type diagram_1: vector[pair[double, double]] + :param diagram_2: The second diagram. + :type diagram_2: vector[pair[double, double]] + :param e: If `e` is 0, this uses an expensive algorithm to compute the + exact distance. + If `e` is not 0, it asks for an additive `e`-approximation, and + currently also allows a small multiplicative error (the last 2 or 3 + bits of the mantissa may be wrong). This version of the algorithm takes + advantage of the limited precision of `double` and is usually a lot + faster to compute, whatever the value of `e`. + + Thus, by default, `e` is the smallest positive double. + :type e: float + :rtype: float + :returns: the bottleneck distance. + """ + if e is None: + # Default value is the smallest double value (not 0, 0 is for exact version) + return bottleneck(diagram_1, diagram_2) + else: + # Can be 0 for exact version + return bottleneck(diagram_1, diagram_2, e) |