multipers 2.0.0__cp311-cp311-macosx_13_0_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of multipers might be problematic. Click here for more details.

Files changed (78) hide show
  1. multipers/.dylibs/libc++.1.0.dylib +0 -0
  2. multipers/.dylibs/libtbb.12.12.dylib +0 -0
  3. multipers/.dylibs/libtbbmalloc.2.12.dylib +0 -0
  4. multipers/__init__.py +11 -0
  5. multipers/_signed_measure_meta.py +268 -0
  6. multipers/_slicer_meta.py +171 -0
  7. multipers/data/MOL2.py +350 -0
  8. multipers/data/UCR.py +18 -0
  9. multipers/data/__init__.py +1 -0
  10. multipers/data/graphs.py +466 -0
  11. multipers/data/immuno_regions.py +27 -0
  12. multipers/data/minimal_presentation_to_st_bf.py +0 -0
  13. multipers/data/pytorch2simplextree.py +91 -0
  14. multipers/data/shape3d.py +101 -0
  15. multipers/data/synthetic.py +68 -0
  16. multipers/distances.py +198 -0
  17. multipers/euler_characteristic.pyx +132 -0
  18. multipers/filtration_conversions.pxd +229 -0
  19. multipers/filtrations.pxd +225 -0
  20. multipers/function_rips.cpython-311-darwin.so +0 -0
  21. multipers/function_rips.pyx +105 -0
  22. multipers/grids.cpython-311-darwin.so +0 -0
  23. multipers/grids.pyx +281 -0
  24. multipers/hilbert_function.pyi +46 -0
  25. multipers/hilbert_function.pyx +153 -0
  26. multipers/io.cpython-311-darwin.so +0 -0
  27. multipers/io.pyx +571 -0
  28. multipers/ml/__init__.py +0 -0
  29. multipers/ml/accuracies.py +90 -0
  30. multipers/ml/convolutions.py +532 -0
  31. multipers/ml/invariants_with_persistable.py +79 -0
  32. multipers/ml/kernels.py +176 -0
  33. multipers/ml/mma.py +659 -0
  34. multipers/ml/one.py +472 -0
  35. multipers/ml/point_clouds.py +238 -0
  36. multipers/ml/signed_betti.py +50 -0
  37. multipers/ml/signed_measures.py +1542 -0
  38. multipers/ml/sliced_wasserstein.py +461 -0
  39. multipers/ml/tools.py +113 -0
  40. multipers/mma_structures.cpython-311-darwin.so +0 -0
  41. multipers/mma_structures.pxd +127 -0
  42. multipers/mma_structures.pyx +2433 -0
  43. multipers/multiparameter_edge_collapse.py +41 -0
  44. multipers/multiparameter_module_approximation.cpython-311-darwin.so +0 -0
  45. multipers/multiparameter_module_approximation.pyx +211 -0
  46. multipers/pickle.py +53 -0
  47. multipers/plots.py +326 -0
  48. multipers/point_measure_integration.cpython-311-darwin.so +0 -0
  49. multipers/point_measure_integration.pyx +139 -0
  50. multipers/rank_invariant.cpython-311-darwin.so +0 -0
  51. multipers/rank_invariant.pyx +229 -0
  52. multipers/simplex_tree_multi.cpython-311-darwin.so +0 -0
  53. multipers/simplex_tree_multi.pxd +129 -0
  54. multipers/simplex_tree_multi.pyi +715 -0
  55. multipers/simplex_tree_multi.pyx +4655 -0
  56. multipers/slicer.cpython-311-darwin.so +0 -0
  57. multipers/slicer.pxd +781 -0
  58. multipers/slicer.pyx +3393 -0
  59. multipers/tensor.pxd +13 -0
  60. multipers/test.pyx +44 -0
  61. multipers/tests/__init__.py +40 -0
  62. multipers/tests/old_test_rank_invariant.py +91 -0
  63. multipers/tests/test_diff_helper.py +74 -0
  64. multipers/tests/test_hilbert_function.py +82 -0
  65. multipers/tests/test_mma.py +51 -0
  66. multipers/tests/test_point_clouds.py +59 -0
  67. multipers/tests/test_python-cpp_conversion.py +82 -0
  68. multipers/tests/test_signed_betti.py +181 -0
  69. multipers/tests/test_simplextreemulti.py +98 -0
  70. multipers/tests/test_slicer.py +63 -0
  71. multipers/torch/__init__.py +1 -0
  72. multipers/torch/diff_grids.py +217 -0
  73. multipers/torch/rips_density.py +257 -0
  74. multipers-2.0.0.dist-info/LICENSE +21 -0
  75. multipers-2.0.0.dist-info/METADATA +29 -0
  76. multipers-2.0.0.dist-info/RECORD +78 -0
  77. multipers-2.0.0.dist-info/WHEEL +5 -0
  78. multipers-2.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,139 @@
1
+ # cimport multipers.tensor as mt
2
+ from libc.stdint cimport intptr_t, uint16_t, uint32_t, int32_t, int64_t
3
+ from libcpp.vector cimport vector
4
+ from libcpp cimport bool, int, float
5
+ import numpy as np
6
+ cimport numpy as cnp
7
+
8
+ from collections import defaultdict
9
+ cnp.import_array()
10
+ from scipy import sparse
11
+
12
+
13
+ import multipers.grids as mpg
14
+
15
+ ctypedef fused some_int:
16
+ int32_t
17
+ int64_t
18
+ int
19
+
20
+ ctypedef fused some_float:
21
+ float
22
+ double
23
+
24
+
25
+ import cython
26
+ cimport cython
27
+ @cython.boundscheck(False)
28
+ @cython.wraparound(False)
29
+ def integrate_measure(
30
+ some_float[:,:] pts,
31
+ some_int[:] weights,
32
+ filtration_grid:Optional[list[np.ndarray]]=None,
33
+ grid_strategy:str="regular",
34
+ resolution:int|list[int]=100,
35
+ bool return_grid=False,
36
+ **get_fitration_kwargs,
37
+ ):
38
+ """
39
+ Integrate a point measure on a grid.
40
+ Measure is a sum of diracs, based on points `pts` and weights `weights`.
41
+ For instance, if the signed measure comes from the hilbert signed measure,
42
+ this integration will return the hilbert function on this grid.
43
+ - pts : array of points (num_pts, D)
44
+ - weights : array of weights (num_pts,)
45
+ - filtration_grid (optional) : list of 1d arrays
46
+ - resolution : int or list of int
47
+ - return_grid : return the grid of the measure
48
+ - **get_fitration_kwargs : arguments to compute the grid,
49
+ if the grid is not given.
50
+ """
51
+ if filtration_grid is None:
52
+ import multipers.simplex_tree_multi
53
+ filtration_grid = mpg.compute_grid(
54
+ np.asarray(pts).T,
55
+ strategy=grid_strategy,
56
+ resolution=resolution,
57
+ **get_fitration_kwargs
58
+ )
59
+ resolution = np.asarray([len(f) for f in filtration_grid])
60
+ cdef int num_pts = pts.shape[0]
61
+ cdef int num_parameters = pts.shape[1]
62
+ assert weights.shape[0] == num_pts
63
+ out = np.zeros(shape=resolution, dtype=np.int32) ## dim cannot be known at compiletime
64
+ # cdef some_float[:] filtration_of_parameter
65
+ # cdef cnp.ndarray indices = np.zeros(shape=num_parameters, dtype=int)
66
+ #
67
+ pts_coords = np.empty((num_parameters, num_pts), dtype=np.int64)
68
+ for parameter in range(num_parameters):
69
+ pts_coords[parameter] = np.searchsorted(filtration_grid[parameter], pts[:,parameter])
70
+ for i in range(num_pts):
71
+ cone = tuple(slice(c,r) for r,c in zip(resolution,pts_coords[:,i]))
72
+ out[cone] += weights[i]
73
+ if return_grid:
74
+ return out,filtration_grid
75
+ return out
76
+
77
+ ## for benchmark purposes
78
+ def integrate_measure_python(pts, weights, filtrations):
79
+ resolution = tuple([len(f) for f in filtrations])
80
+ out = np.zeros(shape=resolution, dtype=pts.dtype)
81
+ num_pts = pts.shape[0]
82
+ num_parameters = pts.shape[1]
83
+ for i in range(num_pts): #this is slow.
84
+ indices = (filtrations[parameter]>=pts[i][parameter] for parameter in range(num_parameters))
85
+ out[np.ix_(*indices)] += weights[i]
86
+ return out
87
+
88
+
89
+ def sparsify(x):
90
+ """
91
+ Given an arbitrary dimensional numpy array, returns (coordinates,data).
92
+ --
93
+ cost : scipy sparse + num_points*num_parameters^2 divisions
94
+ """
95
+ num_parameters = x.ndim
96
+ sx = sparse.coo_array(x.ravel())
97
+ idx = sx.col
98
+ data = sx.data
99
+ coords = np.empty((data.shape[0], num_parameters), dtype=np.int64)
100
+ for parameter in range(num_parameters-1,-1,-1):
101
+ idx,coord_of_parameter = np.divmod(idx, x.shape[parameter])
102
+ coords[:, parameter] = coord_of_parameter
103
+ return coords,data
104
+
105
+
106
+
107
+
108
+ @cython.boundscheck(False)
109
+ @cython.wraparound(False)
110
+ def clean_signed_measure(some_float[:,:] pts, some_int[:] weights, dtype = np.float32):
111
+ """
112
+ Sum the diracs at the same locations. i.e.,
113
+ returns the minimal sized measure to represent the input.
114
+ Mostly useful for, e.g., euler_characteristic from simplical complexes.
115
+ """
116
+ cdef dict[tuple, int] out = {}
117
+ cdef int num_diracs
118
+ cdef int num_parameters
119
+ num_diracs, num_parameters = pts.shape[:2]
120
+ for i in range(num_diracs):
121
+ key = tuple(pts[i]) # size cannot be known at compiletime
122
+ out[tuple(pts[i])] = out.get(key,0)+ weights[i]
123
+ num_keys = len(out)
124
+ new_pts = np.fromiter(out.keys(), dtype=np.dtype((dtype,num_parameters)), count=num_keys)
125
+ new_weights = np.fromiter(out.values(), dtype=np.int32, count=num_keys)
126
+ idx = np.nonzero(new_weights)
127
+ new_pts = new_pts[idx]
128
+ new_weights = new_weights[idx]
129
+ return (new_pts, new_weights)
130
+
131
+ def clean_sms(sms):
132
+ """
133
+ Sum the diracs at the same locations. i.e.,
134
+ returns the minimal sized measure to represent the input.
135
+ Mostly useful for, e.g., euler_characteristic from simplical complexes.
136
+ """
137
+ return tuple(clean_signed_measure(pts,weights) for pts,weights in sms)
138
+
139
+
@@ -0,0 +1,229 @@
1
+ # cimport multipers.tensor as mt
2
+ from libc.stdint cimport intptr_t, uint16_t, uint32_t, int32_t, int16_t, int8_t
3
+ from libcpp.vector cimport vector
4
+ from libcpp cimport bool, int, float
5
+ from libcpp.utility cimport pair
6
+ from typing import Optional,Iterable,Callable
7
+ from cython.operator import dereference
8
+
9
+ import numpy as np
10
+ cimport numpy as cnp
11
+ cnp.import_array()
12
+
13
+ ctypedef float value_type
14
+ python_value_type=np.float32
15
+
16
+ ctypedef int32_t indices_type # uint fails for some reason
17
+ python_indices_type=np.int32
18
+
19
+ ctypedef int32_t tensor_dtype # sizes should be less than 32k (int16), but int32 to be safe
20
+ python_tensor_dtype = np.int32
21
+ import multipers.grids as mpg
22
+ import multipers.slicer as mps
23
+ from multipers.slicer cimport *
24
+
25
+ # ctypedef pair[vector[vector[indices_type]], vector[tensor_dtype]] signed_measure_type
26
+
27
+ # cdef extern from "multi_parameter_rank_invariant/rank_invariant.h" namespace "Gudhi::multiparameter::rank_invariant":
28
+ # void compute_rank_invariant_python(const intptr_t, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type, bool) except + nogil
29
+
30
+ # void compute_rank_invariant_python(GeneralNoVineTruc, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type) except + nogil
31
+ # void compute_rank_invariant_python(GeneralVineTruc, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type) except + nogil
32
+ # void compute_rank_invariant_python(SimplicialVineMatrixTruc, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type) except + nogil
33
+ # void compute_rank_invariant_python(SimplicialVineGraphTruc, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type) except + nogil
34
+ # void compute_rank_invariant_python(GeneralVineClementTruc, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type) except + nogil
35
+
36
+ from multipers.ml.signed_betti import rank_decomposition_by_rectangles
37
+ from multipers.point_measure_integration import sparsify
38
+
39
+ # def rank_invariant(simplextree, vector[indices_type] degrees, mass_default=None, plot=False, indices_type n_jobs=0, bool verbose=False, bool expand_collapse=False):
40
+ # """
41
+ # Computes the signed measures given by the decomposition of the hilbert function.
42
+ #
43
+ # Input
44
+ # -----
45
+ # - simplextree:SimplexTreeMulti, the multifiltered simplicial complex
46
+ # - degrees:array-like of ints, the degrees to compute
47
+ # - mass_default: Either None, or 'auto' or 'inf', or array-like of floats. Where to put the default mass to get a zero-mass measure.
48
+ # - plot:bool, plots the computed measures if true.
49
+ # - n_jobs:int, number of jobs. Defaults to #cpu, but when doing parallel computations of signed measures, we recommend setting this to 1.
50
+ # - verbose:bool, prints c++ logs.
51
+ #
52
+ # Output
53
+ # ------
54
+ # `[signed_measure_of_degree for degree in degrees]`
55
+ # with `signed_measure_of_degree` of the form `(dirac location, dirac weights)`.
56
+ # """
57
+ # assert simplextree._is_squeezed, "Squeeze grid first."
58
+ # assert simplextree.dtype == np.int32
59
+ # cdef bool zero_pad = mass_default is not None
60
+ # grid_conversion = [np.asarray(f) for f in simplextree.filtration_grid]
61
+ # # assert simplextree.num_parameters == 2
62
+ # grid_shape = np.array([len(f) for f in grid_conversion])
63
+ #
64
+ # if mass_default is None:
65
+ # mass_default = mass_default
66
+ # else:
67
+ # mass_default = np.asarray(mass_default)
68
+ # assert mass_default.ndim == 1 and mass_default.shape[0] == simplextree.num_parameters
69
+ # if zero_pad:
70
+ # for i, _ in enumerate(grid_shape):
71
+ # grid_shape[i] += 1 # adds a 0
72
+ # for i,f in enumerate(grid_conversion):
73
+ # grid_conversion[i] = np.concatenate([f, [mass_default[i]]])
74
+ #
75
+ # assert len(grid_shape) == simplextree.num_parameters, "Grid shape size has to be the number of parameters."
76
+ # grid_shape_with_degree = np.asarray(np.concatenate([[len(degrees)], grid_shape, grid_shape]), dtype=python_indices_type)
77
+ # container_array = np.ascontiguousarray(np.zeros(grid_shape_with_degree, dtype=python_tensor_dtype).flatten())
78
+ # assert len(container_array) < np.iinfo(python_indices_type).max, "Too large container. Raise an issue on github if you encounter this issue. (Due to tensor's operator[])"
79
+ # cdef intptr_t simplextree_ptr = simplextree.thisptr
80
+ # cdef vector[indices_type] c_grid_shape = grid_shape_with_degree
81
+ # cdef tensor_dtype[::1] container = container_array
82
+ # cdef tensor_dtype* container_ptr = &container[0]
83
+ # with nogil:
84
+ # compute_rank_invariant_python(simplextree_ptr, container_ptr,c_grid_shape,degrees, n_jobs, expand_collapse)
85
+ # container_array = container_array.reshape(grid_shape_with_degree)
86
+ # if plot:
87
+ # from multipers.plots import plot_surfaces
88
+ # plot_surfaces((grid_conversion, container_array))
89
+ # return (grid_conversion, container_array)
90
+ #
91
+ #
92
+ # def signed_measure(simplextree, vector[indices_type] degrees, mass_default=None, plot=False, indices_type n_jobs=0, bool verbose=False, bool expand_collapse=False):
93
+ # """
94
+ # Computes the signed measures given by the decomposition of the hilbert function.
95
+ #
96
+ # Input
97
+ # -----
98
+ # - simplextree:SimplexTreeMulti, the multifiltered simplicial complex
99
+ # - degrees:array-like of ints, the degrees to compute
100
+ # - mass_default: Either None, or 'auto' or 'inf', or array-like of floats. Where to put the default mass to get a zero-mass measure.
101
+ # - plot:bool, plots the computed measures if true.
102
+ # - n_jobs:int, number of jobs. Defaults to #cpu, but when doing parallel computations of signed measures, we recommend setting this to 1.
103
+ # - verbose:bool, prints c++ logs.
104
+ #
105
+ # Output
106
+ # ------
107
+ # `[signed_measure_of_degree for degree in degrees]`
108
+ # with `signed_measure_of_degree` of the form `(dirac location, dirac weights)`.
109
+ # """
110
+ # assert simplextree._is_squeezed, "Squeeze grid first."
111
+ # cdef bool zero_pad = mass_default is not None
112
+ # grid_conversion = [np.asarray(f) for f in simplextree.filtration_grid]
113
+ # # assert simplextree.num_parameters == 2
114
+ # grid_shape = np.array([len(f) for f in grid_conversion])
115
+ #
116
+ # if mass_default is None:
117
+ # mass_default = mass_default
118
+ # else:
119
+ # mass_default = np.asarray(mass_default)
120
+ # assert mass_default.ndim == 1 and mass_default.shape[0] == simplextree.num_parameters, "Mass default has to be an array like of shape (num_parameters,)"
121
+ # if zero_pad:
122
+ # for i, _ in enumerate(grid_shape):
123
+ # grid_shape[i] += 1 # adds a 0
124
+ # for i,f in enumerate(grid_conversion):
125
+ # grid_conversion[i] = np.concatenate([f, [mass_default[i]]])
126
+ #
127
+ # assert len(grid_shape) == simplextree.num_parameters, "Grid shape size has to be the number of parameters."
128
+ # grid_shape_with_degree = np.asarray(np.concatenate([[len(degrees)], grid_shape, grid_shape]), dtype=python_indices_type)
129
+ # container_array = np.ascontiguousarray(np.zeros(grid_shape_with_degree, dtype=python_tensor_dtype).flatten())
130
+ # assert len(container_array) < np.iinfo(python_indices_type).max, "Too large container. Raise an issue on github if you encounter this issue. (Due to tensor's operator[])"
131
+ # cdef intptr_t simplextree_ptr = simplextree.thisptr
132
+ # cdef vector[indices_type] c_grid_shape = grid_shape_with_degree
133
+ # cdef tensor_dtype[::1] container = container_array
134
+ # cdef tensor_dtype* container_ptr = &container[0]
135
+ # with nogil:
136
+ # compute_rank_invariant_python(simplextree_ptr, container_ptr,c_grid_shape,degrees, n_jobs, expand_collapse)
137
+ # rank = container_array.reshape(grid_shape_with_degree)
138
+ # rank = tuple(rank_decomposition_by_rectangles(rank_of_degree) for rank_of_degree in rank)
139
+ # out = []
140
+ # cdef int num_parameters = simplextree.num_parameters
141
+ # for rank_decomposition in rank:
142
+ # (coords, weights) = sparsify(np.ascontiguousarray(rank_decomposition))
143
+ # births = coords[:,:num_parameters]
144
+ # deaths = coords[:,num_parameters:]
145
+ # correct_indices = np.all(births<=deaths, axis=1) # TODO : correct this
146
+ # coords = coords[correct_indices]
147
+ # weights = weights[correct_indices]
148
+ # if len(correct_indices) == 0:
149
+ # pts, weights = np.empty((0, 2*num_parameters)), np.empty((0))
150
+ # else:
151
+ # pts = np.empty(shape=coords.shape, dtype=grid_conversion[0].dtype)
152
+ # for i in range(pts.shape[1]):
153
+ # pts[:,i] = grid_conversion[i % num_parameters][coords[:,i]]
154
+ # rank_decomposition = (pts,weights)
155
+ # out.append(rank_decomposition)
156
+ #
157
+ # if plot:
158
+ # from multipers.plots import plot_signed_measures
159
+ # plot_signed_measures(out)
160
+ # return out
161
+
162
+
163
+
164
+ ## TODO : It is not necessary to do the Möbius inversion in python.
165
+ ## fill rank in flipped death, then differentiate in cpp, then reflip with numpy.
166
+ def rank_from_slicer(
167
+ slicer,
168
+ vector[indices_type] degrees,
169
+ bool verbose=False,
170
+ indices_type n_jobs=1,
171
+ mass_default = None,
172
+ grid_shape=None,
173
+ grid_conversion=None,
174
+ bool plot=False,
175
+ bool return_raw=False,
176
+ ):
177
+ # cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
178
+ if grid_shape is None:
179
+ grid_shape = (slicer.compute_box()[1]).astype(python_indices_type)
180
+ cdef int num_parameters = len(grid_shape)
181
+ cdef bool zero_pad = mass_default is not None
182
+
183
+ if mass_default is None:
184
+ mass_default = mass_default
185
+ else:
186
+ mass_default = np.asarray(mass_default)
187
+ assert mass_default.ndim == 1 and mass_default.shape[0] == num_parameters, "Mass default has to be an array like of shape (num_parameters,)"
188
+ if zero_pad:
189
+ for i, _ in enumerate(grid_shape):
190
+ grid_shape[i] += 1 # adds a 0
191
+ for i,f in enumerate(grid_conversion):
192
+ grid_conversion[i] = np.concatenate([f, [mass_default[i]]])
193
+
194
+ grid_shape_with_degree = np.asarray(np.concatenate([[len(degrees)], grid_shape, grid_shape]), dtype=python_indices_type)
195
+ container_array = np.ascontiguousarray(np.zeros(grid_shape_with_degree, dtype=python_tensor_dtype).flatten())
196
+ assert len(container_array) < np.iinfo(python_indices_type).max, "Too large container. Raise an issue on github if you encounter this issue. (Due to tensor's operator[])"
197
+ cdef vector[indices_type] c_grid_shape = grid_shape_with_degree
198
+ cdef tensor_dtype[::1] container = container_array
199
+ cdef tensor_dtype* container_ptr = &container[0]
200
+
201
+ ## SLICERS
202
+ _compute_rank_invariant(slicer, container_ptr, c_grid_shape, degrees, n_jobs)
203
+
204
+ rank = container_array.reshape(grid_shape_with_degree)
205
+ rank = tuple(rank_decomposition_by_rectangles(rank_of_degree) for rank_of_degree in rank)
206
+ if return_raw:
207
+ return rank
208
+ out = []
209
+ def clean_rank(rank_decomposition):
210
+ (coords, weights) = sparsify(np.ascontiguousarray(rank_decomposition))
211
+ births = coords[:,:num_parameters]
212
+ deaths = coords[:,num_parameters:]
213
+ correct_indices = np.all(births<=deaths, axis=1)
214
+ coords = coords[correct_indices]
215
+ weights = weights[correct_indices]
216
+ return coords, weights
217
+
218
+ out = mpg.sms_in_grid(tuple(clean_rank(rank_decomposition) for rank_decomposition in rank), grid_conversion, num_parameters=num_parameters)
219
+
220
+ if plot:
221
+ from multipers.plots import plot_signed_measures
222
+ plot_signed_measures(out)
223
+ return out
224
+
225
+
226
+
227
+
228
+
229
+
@@ -0,0 +1,129 @@
1
+ # This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2
+ # See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3
+ # Author(s): Vincent Rouvreau
4
+ #
5
+ # Copyright (C) 2016 Inria
6
+ #
7
+ # Modification(s):
8
+ # - 2022 David Loiseaux, Hannah Schreiber: adapt for multipersistence.
9
+ # - YYYY/MM Author: Description of the modification
10
+
11
+ from cython cimport numeric
12
+ from libcpp.vector cimport vector
13
+ from libcpp.utility cimport pair
14
+ from libcpp cimport bool
15
+ from libcpp.string cimport string
16
+ from libcpp.map cimport map
17
+
18
+ from libc.stdint cimport intptr_t, int32_t
19
+
20
+ __author__ = "Vincent Rouvreau"
21
+ __copyright__ = "Copyright (C) 2016 Inria"
22
+ __license__ = "MIT"
23
+
24
+
25
+ from multipers.filtrations cimport *
26
+
27
+
28
+ ctypedef int dimension_type
29
+ ctypedef vector[int] simplex_type
30
+ ctypedef vector[simplex_type] simplex_list
31
+ ctypedef vector[pair[pair[int,int], pair[double, double]]] edge_list
32
+ ctypedef vector[int] euler_char_list
33
+
34
+ ctypedef vector[unsigned int] boundary_type
35
+ ctypedef vector[boundary_type] boundary_matrix
36
+
37
+ cdef extern from "Simplex_tree_multi_interface.h" namespace "Gudhi::multiparameter::python_interface":
38
+
39
+ cdef cppclass Simplex_tree_multi_simplex_handle[F=*]:
40
+ pass
41
+
42
+ cdef cppclass Simplex_tree_multi_simplices_iterator[F=*]:
43
+ Simplex_tree_multi_simplices_iterator() nogil
44
+ Simplex_tree_multi_simplex_handle& operator*() nogil
45
+ Simplex_tree_multi_simplices_iterator operator++() nogil
46
+ bint operator!=(Simplex_tree_multi_simplices_iterator) nogil
47
+
48
+ cdef cppclass Simplex_tree_multi_skeleton_iterator[F=*]:
49
+ Simplex_tree_multi_skeleton_iterator() nogil
50
+ Simplex_tree_multi_simplex_handle& operator*() nogil
51
+ Simplex_tree_multi_skeleton_iterator operator++() nogil
52
+ bint operator!=(Simplex_tree_multi_skeleton_iterator) nogil
53
+
54
+ cdef cppclass Simplex_tree_multi_boundary_iterator[F=*]:
55
+ Simplex_tree_multi_boundary_iterator() nogil
56
+ Simplex_tree_multi_simplex_handle& operator*() nogil
57
+ Simplex_tree_multi_boundary_iterator operator++() nogil
58
+ bint operator!=(Simplex_tree_multi_boundary_iterator) nogil
59
+
60
+
61
+ cdef cppclass Simplex_tree_multi_interface[F=*, value_type=*]:
62
+ ctypedef pair[simplex_type, F*] simplex_filtration_type
63
+ Simplex_tree_multi_interface() nogil
64
+ Simplex_tree_multi_interface(Simplex_tree_multi_interface&) nogil
65
+ F* simplex_filtration(const vector[int]& simplex) nogil
66
+ void assign_simplex_filtration(vector[int]& simplex, const F& filtration) noexcept nogil
67
+ void initialize_filtration() nogil
68
+ int num_vertices() nogil
69
+ int num_simplices() nogil
70
+ void set_dimension(int dimension) nogil
71
+ dimension_type dimension() nogil
72
+ dimension_type upper_bound_dimension() nogil
73
+ bool find_simplex(vector[int]& simplex) nogil
74
+ bool insert(vector[int]& simplex, F& filtration) noexcept nogil
75
+ # vector[simplex_filtration_type] get_star(const vector[int]& simplex) nogil
76
+ # vector[simplex_filtration_type] get_cofaces(const vector[int]& simplex, int dimension) nogil
77
+ void expansion(int max_dim) except + nogil
78
+ void remove_maximal_simplex(simplex_type simplex) nogil
79
+ # bool prune_above_filtration(filtration_type filtration) nogil
80
+ bool prune_above_dimension(int dimension) nogil
81
+ bool make_filtration_non_decreasing() except + nogil
82
+ # void compute_extended_filtration() nogil
83
+ # Simplex_tree_multi_interface* collapse_edges(int nb_collapse_iteration) except + nogil
84
+ void reset_filtration(const F& filtration, int dimension) nogil
85
+ bint operator==(Simplex_tree_multi_interface) nogil
86
+ # Iterators over Simplex tree
87
+ pair[simplex_type,F*] get_simplex_and_filtration(Simplex_tree_multi_simplex_handle f_simplex) nogil
88
+ Simplex_tree_multi_simplices_iterator[F] get_simplices_iterator_begin() nogil
89
+ Simplex_tree_multi_simplices_iterator[F] get_simplices_iterator_end() nogil
90
+ vector[Simplex_tree_multi_simplex_handle[F]].const_iterator get_filtration_iterator_begin() nogil
91
+ vector[Simplex_tree_multi_simplex_handle[F]].const_iterator get_filtration_iterator_end() nogil
92
+ Simplex_tree_multi_skeleton_iterator get_skeleton_iterator_begin(int dimension) nogil
93
+ Simplex_tree_multi_skeleton_iterator get_skeleton_iterator_end(int dimension) nogil
94
+ pair[Simplex_tree_multi_boundary_iterator, Simplex_tree_multi_boundary_iterator] get_boundary_iterators(vector[int] simplex) except + nogil
95
+ # Expansion with blockers
96
+ ctypedef bool (*blocker_func_t)(vector[int], void *user_data)
97
+ void expansion_with_blockers_callback(int dimension, blocker_func_t user_func, void *user_data)
98
+
99
+ ## MULTIPERS STUFF
100
+ void set_keys_to_enumerate() nogil const
101
+ int get_key(const simplex_type) nogil
102
+ void set_key(simplex_type, int) nogil
103
+ void fill_lowerstar(const F&, int) nogil
104
+ simplex_list get_simplices_of_dimension(int) nogil
105
+ edge_list get_edge_list() nogil
106
+ # euler_char_list euler_char(const vector[filtration_type]&) nogil
107
+ void resize_all_filtrations(int) nogil
108
+ void set_number_of_parameters(int) nogil
109
+ int get_number_of_parameters() nogil
110
+
111
+
112
+ void from_std(intptr_t,int, F&) nogil
113
+ void to_std(intptr_t, Line[double],int ) nogil
114
+ void to_std_linear_projection(intptr_t, vector[double]) nogil
115
+ void squeeze_filtration_inplace(vector[vector[double]] &, bool) nogil
116
+ void squeeze_filtration(intptr_t, vector[vector[double]] &) nogil
117
+ vector[vector[vector[value_type]]] get_filtration_values(const vector[int]&) nogil
118
+
119
+
120
+ pair[boundary_matrix, vector[Finitely_critical_multi_filtration[value_type]]] simplextree_to_boundary_filtration()
121
+ vector[pair[ vector[vector[value_type]],boundary_matrix]] simplextree_to_scc()
122
+ vector[pair[ vector[vector[vector[value_type]]],boundary_matrix]] kcritical_simplextree_to_scc()
123
+
124
+ vector[pair[ vector[vector[vector[value_type]]],boundary_matrix]] function_simplextree_to_scc()
125
+ pair[vector[vector[value_type]],boundary_matrix ] simplextree_to_ordered_bf()
126
+ # vector[map[value_type,int32_t]] build_idx_map(const vector[int]&) nogil
127
+ # pair[vector[vector[int32_t]],vector[vector[int32_t]]] get_pts_indices(const vector[map[value_type,int32_t]]&, const vector[vector[value_type]]&) nogil
128
+ pair[vector[vector[int32_t]],vector[vector[int32_t]]] pts_to_indices(vector[vector[value_type]]&, vector[int]&) nogil
129
+