multipers 2.3.3b6__cp313-cp313-macosx_10_13_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.
- multipers/.dylibs/libc++.1.0.dylib +0 -0
- multipers/.dylibs/libtbb.12.16.dylib +0 -0
- multipers/__init__.py +33 -0
- multipers/_signed_measure_meta.py +453 -0
- multipers/_slicer_meta.py +211 -0
- multipers/array_api/__init__.py +45 -0
- multipers/array_api/numpy.py +41 -0
- multipers/array_api/torch.py +58 -0
- multipers/data/MOL2.py +458 -0
- multipers/data/UCR.py +18 -0
- multipers/data/__init__.py +1 -0
- multipers/data/graphs.py +466 -0
- multipers/data/immuno_regions.py +27 -0
- multipers/data/minimal_presentation_to_st_bf.py +0 -0
- multipers/data/pytorch2simplextree.py +91 -0
- multipers/data/shape3d.py +101 -0
- multipers/data/synthetic.py +113 -0
- multipers/distances.py +202 -0
- multipers/filtration_conversions.pxd +229 -0
- multipers/filtration_conversions.pxd.tp +84 -0
- multipers/filtrations/__init__.py +18 -0
- multipers/filtrations/density.py +574 -0
- multipers/filtrations/filtrations.py +361 -0
- multipers/filtrations.pxd +224 -0
- multipers/function_rips.cpython-313-darwin.so +0 -0
- multipers/function_rips.pyx +105 -0
- multipers/grids.cpython-313-darwin.so +0 -0
- multipers/grids.pyx +433 -0
- multipers/gudhi/Persistence_slices_interface.h +132 -0
- multipers/gudhi/Simplex_tree_interface.h +239 -0
- multipers/gudhi/Simplex_tree_multi_interface.h +551 -0
- multipers/gudhi/cubical_to_boundary.h +59 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex.h +450 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex_base.h +1070 -0
- multipers/gudhi/gudhi/Bitmap_cubical_complex_periodic_boundary_conditions_base.h +579 -0
- multipers/gudhi/gudhi/Debug_utils.h +45 -0
- multipers/gudhi/gudhi/Fields/Multi_field.h +484 -0
- multipers/gudhi/gudhi/Fields/Multi_field_operators.h +455 -0
- multipers/gudhi/gudhi/Fields/Multi_field_shared.h +450 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small.h +531 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +507 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +531 -0
- multipers/gudhi/gudhi/Fields/Z2_field.h +355 -0
- multipers/gudhi/gudhi/Fields/Z2_field_operators.h +376 -0
- multipers/gudhi/gudhi/Fields/Zp_field.h +420 -0
- multipers/gudhi/gudhi/Fields/Zp_field_operators.h +400 -0
- multipers/gudhi/gudhi/Fields/Zp_field_shared.h +418 -0
- multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
- multipers/gudhi/gudhi/Matrix.h +2107 -0
- multipers/gudhi/gudhi/Multi_critical_filtration.h +1038 -0
- multipers/gudhi/gudhi/Multi_persistence/Box.h +174 -0
- multipers/gudhi/gudhi/Multi_persistence/Line.h +282 -0
- multipers/gudhi/gudhi/Off_reader.h +173 -0
- multipers/gudhi/gudhi/One_critical_filtration.h +1441 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +769 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +686 -0
- multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +842 -0
- multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1350 -0
- multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1105 -0
- multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +859 -0
- multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +910 -0
- multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +139 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +230 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +211 -0
- multipers/gudhi/gudhi/Persistence_matrix/boundary_cell_position_to_id_mapper.h +60 -0
- multipers/gudhi/gudhi/Persistence_matrix/boundary_face_position_to_id_mapper.h +60 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +136 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +190 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +616 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +150 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +106 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +219 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +327 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1140 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +934 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +934 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +980 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1092 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +192 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +921 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/small_vector_column.h +1093 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +1012 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1244 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +186 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +164 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +156 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +376 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +540 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Field_Zp.h +118 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Multi_field.h +173 -0
- multipers/gudhi/gudhi/Persistent_cohomology/Persistent_cohomology_column.h +128 -0
- multipers/gudhi/gudhi/Persistent_cohomology.h +745 -0
- multipers/gudhi/gudhi/Points_off_io.h +171 -0
- multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +463 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +106 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
- multipers/gudhi/gudhi/Simplex_tree/hooks_simplex_base.h +62 -0
- multipers/gudhi/gudhi/Simplex_tree/indexing_tag.h +27 -0
- multipers/gudhi/gudhi/Simplex_tree/serialization_utils.h +62 -0
- multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +157 -0
- multipers/gudhi/gudhi/Simplex_tree.h +2794 -0
- multipers/gudhi/gudhi/Simplex_tree_multi.h +152 -0
- multipers/gudhi/gudhi/distance_functions.h +62 -0
- multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
- multipers/gudhi/gudhi/persistence_interval.h +253 -0
- multipers/gudhi/gudhi/persistence_matrix_options.h +170 -0
- multipers/gudhi/gudhi/reader_utils.h +367 -0
- multipers/gudhi/mma_interface_coh.h +256 -0
- multipers/gudhi/mma_interface_h0.h +223 -0
- multipers/gudhi/mma_interface_matrix.h +293 -0
- multipers/gudhi/naive_merge_tree.h +536 -0
- multipers/gudhi/scc_io.h +310 -0
- multipers/gudhi/truc.h +1403 -0
- multipers/io.cpython-313-darwin.so +0 -0
- multipers/io.pyx +644 -0
- multipers/ml/__init__.py +0 -0
- multipers/ml/accuracies.py +90 -0
- multipers/ml/invariants_with_persistable.py +79 -0
- multipers/ml/kernels.py +176 -0
- multipers/ml/mma.py +713 -0
- multipers/ml/one.py +472 -0
- multipers/ml/point_clouds.py +352 -0
- multipers/ml/signed_measures.py +1589 -0
- multipers/ml/sliced_wasserstein.py +461 -0
- multipers/ml/tools.py +113 -0
- multipers/mma_structures.cpython-313-darwin.so +0 -0
- multipers/mma_structures.pxd +128 -0
- multipers/mma_structures.pyx +2786 -0
- multipers/mma_structures.pyx.tp +1094 -0
- multipers/multi_parameter_rank_invariant/diff_helpers.h +84 -0
- multipers/multi_parameter_rank_invariant/euler_characteristic.h +97 -0
- multipers/multi_parameter_rank_invariant/function_rips.h +322 -0
- multipers/multi_parameter_rank_invariant/hilbert_function.h +769 -0
- multipers/multi_parameter_rank_invariant/persistence_slices.h +148 -0
- multipers/multi_parameter_rank_invariant/rank_invariant.h +369 -0
- multipers/multiparameter_edge_collapse.py +41 -0
- multipers/multiparameter_module_approximation/approximation.h +2330 -0
- multipers/multiparameter_module_approximation/combinatory.h +129 -0
- multipers/multiparameter_module_approximation/debug.h +107 -0
- multipers/multiparameter_module_approximation/euler_curves.h +0 -0
- multipers/multiparameter_module_approximation/format_python-cpp.h +286 -0
- multipers/multiparameter_module_approximation/heap_column.h +238 -0
- multipers/multiparameter_module_approximation/images.h +79 -0
- multipers/multiparameter_module_approximation/list_column.h +174 -0
- multipers/multiparameter_module_approximation/list_column_2.h +232 -0
- multipers/multiparameter_module_approximation/ru_matrix.h +347 -0
- multipers/multiparameter_module_approximation/set_column.h +135 -0
- multipers/multiparameter_module_approximation/structure_higher_dim_barcode.h +36 -0
- multipers/multiparameter_module_approximation/unordered_set_column.h +166 -0
- multipers/multiparameter_module_approximation/utilities.h +403 -0
- multipers/multiparameter_module_approximation/vector_column.h +223 -0
- multipers/multiparameter_module_approximation/vector_matrix.h +331 -0
- multipers/multiparameter_module_approximation/vineyards.h +464 -0
- multipers/multiparameter_module_approximation/vineyards_trajectories.h +649 -0
- multipers/multiparameter_module_approximation.cpython-313-darwin.so +0 -0
- multipers/multiparameter_module_approximation.pyx +235 -0
- multipers/pickle.py +90 -0
- multipers/plots.py +456 -0
- multipers/point_measure.cpython-313-darwin.so +0 -0
- multipers/point_measure.pyx +395 -0
- multipers/simplex_tree_multi.cpython-313-darwin.so +0 -0
- multipers/simplex_tree_multi.pxd +134 -0
- multipers/simplex_tree_multi.pyx +10840 -0
- multipers/simplex_tree_multi.pyx.tp +2009 -0
- multipers/slicer.cpython-313-darwin.so +0 -0
- multipers/slicer.pxd +3034 -0
- multipers/slicer.pxd.tp +234 -0
- multipers/slicer.pyx +20481 -0
- multipers/slicer.pyx.tp +1088 -0
- multipers/tensor/tensor.h +672 -0
- multipers/tensor.pxd +13 -0
- multipers/test.pyx +44 -0
- multipers/tests/__init__.py +62 -0
- multipers/torch/__init__.py +1 -0
- multipers/torch/diff_grids.py +240 -0
- multipers/torch/rips_density.py +310 -0
- multipers-2.3.3b6.dist-info/METADATA +128 -0
- multipers-2.3.3b6.dist-info/RECORD +183 -0
- multipers-2.3.3b6.dist-info/WHEEL +6 -0
- multipers-2.3.3b6.dist-info/licenses/LICENSE +21 -0
- multipers-2.3.3b6.dist-info/top_level.txt +1 -0
multipers/slicer.pxd.tp
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
{{py:
|
|
2
|
+
"""
|
|
3
|
+
Vine and non-vine slicers.
|
|
4
|
+
both type have the same interface, defined the slicer.pyx file
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
## generation with another file as Tempita is slightly bugged for python <3.12
|
|
8
|
+
import pickle
|
|
9
|
+
with open("build/tmp/_slicer_names.pkl", "rb") as f:
|
|
10
|
+
slicers = pickle.load(f)
|
|
11
|
+
|
|
12
|
+
# TODO: FIXME. This is not possible as the import is hardcoded as f32 and f64.
|
|
13
|
+
# float_value_types = set([(D['C_VALUE_TYPE'],D['PY_VALUE_TYPE'],D['SHORT_VALUE_TYPE']) for D in slicers if D['IS_FLOAT']])
|
|
14
|
+
|
|
15
|
+
float_value_types = set((("float", "np.float32", "f32"), ("double", "np.float64", "f64")) )
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
}}
|
|
19
|
+
|
|
20
|
+
cimport numpy as cnp
|
|
21
|
+
|
|
22
|
+
# SequentialDataset and its two concrete subclasses are (optionally randomized)
|
|
23
|
+
# iterators over the rows of a matrix X and corresponding target values y.
|
|
24
|
+
|
|
25
|
+
from libcpp.utility cimport pair
|
|
26
|
+
from libcpp cimport bool, int, float
|
|
27
|
+
from libcpp.vector cimport vector
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
from libc.stdint cimport intptr_t, uint16_t, uint32_t, int32_t, uint64_t, int64_t
|
|
31
|
+
from cython cimport uint
|
|
32
|
+
|
|
33
|
+
import numpy as np
|
|
34
|
+
python_value_type=np.float32
|
|
35
|
+
from libcpp.string cimport string
|
|
36
|
+
|
|
37
|
+
cdef extern from "Simplex_tree_multi_interface.h" namespace "Gudhi::multiparameter::python_interface":
|
|
38
|
+
cdef cppclass Simplex_tree_multi_interface[F=*, value_type=*]:
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
from multipers.filtrations cimport *
|
|
42
|
+
ctypedef vector[uint] cycle_type ## its the cycle type of matrix
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
{{for D in slicers}}
|
|
46
|
+
|
|
47
|
+
#------------------------------------------------------------------------------
|
|
48
|
+
cdef extern from "Persistence_slices_interface.h":
|
|
49
|
+
cdef cppclass {{D['C_TEMPLATE_TYPE']}} "{{D['TRUC_TYPE']}}":
|
|
50
|
+
ctypedef {{D['C_VALUE_TYPE']}} value_type
|
|
51
|
+
|
|
52
|
+
{{D['C_TEMPLATE_TYPE']}}()
|
|
53
|
+
|
|
54
|
+
{{if D['IS_SIMPLICIAL']}}
|
|
55
|
+
{{D['C_TEMPLATE_TYPE']}}(Simplex_tree_multi_interface[{{D['FILTRATION_TYPE']}}, {{D['C_VALUE_TYPE']}}]*)
|
|
56
|
+
{{else}}
|
|
57
|
+
{{D['C_TEMPLATE_TYPE']}}(const vector[vector[unsigned int]]&, const vector[int]&, const vector[{{D['FILTRATION_TYPE']}}]&)
|
|
58
|
+
{{endif}}
|
|
59
|
+
|
|
60
|
+
{{D['C_TEMPLATE_TYPE']}}& operator=(const {{D['C_TEMPLATE_TYPE']}}&)
|
|
61
|
+
|
|
62
|
+
pair[{{D['C_TEMPLATE_TYPE']}}, vector[unsigned int]] colexical_rearange() except + nogil
|
|
63
|
+
{{D['C_TEMPLATE_TYPE']}} permute(const vector[unsigned int]&) except + nogil
|
|
64
|
+
|
|
65
|
+
vector[vector[pair[{{D['C_VALUE_TYPE']}}, {{D['C_VALUE_TYPE']}}]]] get_barcode() nogil
|
|
66
|
+
vector[vector[pair[int,int]]] get_barcode_idx() nogil
|
|
67
|
+
vector[vector[vector[pair[int,int]]]] custom_persistences({{D['C_VALUE_TYPE']}}*, int size, bool ignore_inf) except + nogil
|
|
68
|
+
|
|
69
|
+
void push_to(const Line[{{D['C_VALUE_TYPE']}}]&) nogil
|
|
70
|
+
void set_one_filtration(const vector[{{D['C_VALUE_TYPE']}}]&) nogil
|
|
71
|
+
int prune_above_dimension(int) except + nogil
|
|
72
|
+
|
|
73
|
+
vector[{{D['C_VALUE_TYPE']}}] get_one_filtration()
|
|
74
|
+
# void compute_persistence(vector[bool]) except+ nogil
|
|
75
|
+
void compute_persistence(bool) except+ nogil # ignore_inf
|
|
76
|
+
void compute_persistence() except+ nogil # ignore_inf
|
|
77
|
+
uint32_t num_generators() nogil
|
|
78
|
+
uint32_t num_parameters() nogil
|
|
79
|
+
string to_str() nogil
|
|
80
|
+
pair[One_critical_filtration[{{D['C_VALUE_TYPE']}}], One_critical_filtration[{{D['C_VALUE_TYPE']}}]] get_bounding_box() except + nogil
|
|
81
|
+
vector[One_critical_filtration[{{D['C_VALUE_TYPE']}}]] get_filtration_values() nogil
|
|
82
|
+
vector[int] get_dimensions() nogil
|
|
83
|
+
int get_dimension(int i) nogil
|
|
84
|
+
vector[vector[uint]] get_boundaries() nogil
|
|
85
|
+
void coarsen_on_grid_inplace(vector[vector[{{D['C_VALUE_TYPE']}}]], bool) nogil
|
|
86
|
+
vector[{{D['FILTRATION_TYPE']}}]& get_filtrations() nogil
|
|
87
|
+
{{if D['COLUMN_TYPE'] is not None}}
|
|
88
|
+
{{D['C_TEMPLATE_TYPE'][:-3]+"i32"}} coarsen_on_grid(vector[vector[{{D['C_VALUE_TYPE']}}]]) nogil
|
|
89
|
+
{{endif}}
|
|
90
|
+
{{if D['IS_VINE']}}
|
|
91
|
+
void vineyard_update() nogil
|
|
92
|
+
vector[vector[vector[vector[unsigned int]]]] get_representative_cycles(bool, bool) nogil
|
|
93
|
+
vector[uint32_t] get_current_order() nogil
|
|
94
|
+
{{endif}}
|
|
95
|
+
|
|
96
|
+
{{if D['IS_KCRITICAL']}}
|
|
97
|
+
void add_generator(const One_critical_filtration[{{D['C_VALUE_TYPE']}}] &) nogil
|
|
98
|
+
{{endif}}
|
|
99
|
+
|
|
100
|
+
void write_to_scc_file(const string&, int, int, bool, bool, bool, bool) nogil
|
|
101
|
+
{{if not D['IS_KCRITICAL']}}
|
|
102
|
+
void build_from_scc_file(const string&, bool, bool, int) except + nogil
|
|
103
|
+
{{endif}}
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
vector[vector[vector[pair[{{D['C_VALUE_TYPE']}}, {{D['C_VALUE_TYPE']}}]]]] persistence_on_lines(vector[vector[{{D['C_VALUE_TYPE']}}]], bool) except + nogil
|
|
107
|
+
vector[vector[vector[pair[{{D['C_VALUE_TYPE']}}, {{D['C_VALUE_TYPE']}}]]]] persistence_on_lines(vector[pair[vector[{{D['C_VALUE_TYPE']}}],vector[{{D['C_VALUE_TYPE']}}]]],bool) except + nogil
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
{{if D['COLUMN_TYPE'] is not None}}
|
|
111
|
+
{{D['C_TEMPLATE_TYPE']}} projective_cover_kernel(int dim) except + nogil
|
|
112
|
+
{{endif}}
|
|
113
|
+
{{endfor}}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
#### MMA Stuff
|
|
118
|
+
|
|
119
|
+
from multipers.mma_structures cimport Module
|
|
120
|
+
cdef extern from "multiparameter_module_approximation/approximation.h" namespace "Gudhi::multiparameter::mma":
|
|
121
|
+
{{for D in slicers}}
|
|
122
|
+
{{if D['IS_VINE'] and D['IS_FLOAT']}}
|
|
123
|
+
Module[{{D['C_VALUE_TYPE']}}] multiparameter_module_approximation({{D['C_TEMPLATE_TYPE']}}&, One_critical_filtration[{{D['C_VALUE_TYPE']}}]&, {{D['C_VALUE_TYPE']}}, Box[{{D['C_VALUE_TYPE']}}]&, bool, bool, bool) except + nogil
|
|
124
|
+
{{endif}}
|
|
125
|
+
{{endfor}}
|
|
126
|
+
pass
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
import multipers.slicer as mps
|
|
132
|
+
from cython.operator cimport dereference
|
|
133
|
+
{{for C_VALUE_TYPE,PYTHON_VALUE_TYPE,SHORT_VALUE_TYPE in float_value_types}}
|
|
134
|
+
cdef inline Module[{{C_VALUE_TYPE}}] _multiparameter_module_approximation_{{SHORT_VALUE_TYPE}}(object slicer, One_critical_filtration[{{C_VALUE_TYPE}}] direction, {{C_VALUE_TYPE}} max_error, Box[{{C_VALUE_TYPE}}] box, bool threshold, bool complete, bool verbose):
|
|
135
|
+
import multipers.slicer as mps
|
|
136
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
137
|
+
cdef Module[{{C_VALUE_TYPE}}] mod
|
|
138
|
+
if False:
|
|
139
|
+
pass
|
|
140
|
+
{{for D in slicers}}
|
|
141
|
+
{{if D['IS_VINE'] and D['SHORT_VALUE_TYPE'] == SHORT_VALUE_TYPE}}
|
|
142
|
+
elif isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
143
|
+
with nogil:
|
|
144
|
+
mod = multiparameter_module_approximation(dereference(<{{D['C_TEMPLATE_TYPE']}}*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
|
|
145
|
+
return mod
|
|
146
|
+
{{endif}}
|
|
147
|
+
{{endfor}}
|
|
148
|
+
else:
|
|
149
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|
|
150
|
+
{{endfor}}
|
|
151
|
+
|
|
152
|
+
###### RANK INVARIANT
|
|
153
|
+
from libc.stdint cimport intptr_t, uint16_t, uint32_t, int32_t, int16_t, int8_t
|
|
154
|
+
ctypedef int32_t tensor_dtype
|
|
155
|
+
ctypedef int32_t indices_type
|
|
156
|
+
python_indices_type=np.int32
|
|
157
|
+
python_tensor_dtype = np.int32
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
ctypedef pair[vector[vector[indices_type]], vector[tensor_dtype]] signed_measure_type
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
cdef extern from "multi_parameter_rank_invariant/rank_invariant.h" namespace "Gudhi::multiparameter::rank_invariant":
|
|
166
|
+
## from slicers
|
|
167
|
+
{{for D in slicers}}
|
|
168
|
+
void compute_rank_invariant_python({{D['C_TEMPLATE_TYPE']}}&, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type, bool ignore_inf) except + nogil
|
|
169
|
+
signed_measure_type compute_rank_signed_measure({{D['C_TEMPLATE_TYPE']}}&, tensor_dtype* , const vector[indices_type], const vector[indices_type], indices_type, bool verbose, bool ignore_inf) except + nogil
|
|
170
|
+
{{endfor}}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
cdef inline void _compute_rank_invariant(object slicer, tensor_dtype* container_ptr, vector[indices_type] c_grid_shape, vector[indices_type] degrees, int n_jobs, bool ignore_inf):
|
|
177
|
+
import multipers.slicer as mps
|
|
178
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
179
|
+
{{for D in slicers}}
|
|
180
|
+
if isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
181
|
+
with nogil:
|
|
182
|
+
compute_rank_invariant_python(dereference(<{{D['C_TEMPLATE_TYPE']}}*>(slicer_ptr)),container_ptr, c_grid_shape,degrees, n_jobs,ignore_inf)
|
|
183
|
+
return
|
|
184
|
+
{{endfor}}
|
|
185
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
cdef inline _compute_rank_sm(object slicer, tensor_dtype* container_ptr, vector[indices_type] c_grid_shape, vector[indices_type] degrees, int n_jobs, bool verbose, bool ignore_inf):
|
|
190
|
+
import multipers.slicer as mps
|
|
191
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
192
|
+
cdef signed_measure_type sm
|
|
193
|
+
cdef cnp.ndarray[indices_type, ndim=2] pts
|
|
194
|
+
cdef cnp.ndarray[tensor_dtype, ndim=1] weights
|
|
195
|
+
{{for D in slicers}}
|
|
196
|
+
if isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
197
|
+
with nogil:
|
|
198
|
+
sm = compute_rank_signed_measure(dereference(<{{D['C_TEMPLATE_TYPE']}}*>(slicer_ptr)),container_ptr, c_grid_shape,degrees, n_jobs, verbose, ignore_inf)
|
|
199
|
+
pts = np.asarray(sm.first,dtype=python_indices_type)
|
|
200
|
+
weights = np.asarray(sm.second,dtype=python_tensor_dtype)
|
|
201
|
+
return (pts,weights)
|
|
202
|
+
{{endfor}}
|
|
203
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
#### Hilbert Function
|
|
208
|
+
|
|
209
|
+
cdef extern from "multi_parameter_rank_invariant/hilbert_function.h" namespace "Gudhi::multiparameter::hilbert_function":
|
|
210
|
+
## from slicers
|
|
211
|
+
{{for D in slicers}}
|
|
212
|
+
signed_measure_type get_hilbert_signed_measure({{D['C_TEMPLATE_TYPE']}}&, tensor_dtype* , const vector[indices_type], const vector[indices_type], bool zero_pad,indices_type n_jobs, bool verbose, bool ignore_inf) except + nogil
|
|
213
|
+
{{endfor}}
|
|
214
|
+
cdef inline _compute_hilbert_sm(slicer, tensor_dtype* container_ptr, vector[indices_type] c_grid_shape, vector[indices_type] degrees, int n_jobs, bool verbose,bool zero_pad, bool ignore_inf):
|
|
215
|
+
import multipers.slicer as mps
|
|
216
|
+
if len(slicer) == 0:
|
|
217
|
+
return (np.empty(shape=(0, 1), dtype=slicer.dtype), np.empty(shape=(0), dtype=int))
|
|
218
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
219
|
+
cdef signed_measure_type sm
|
|
220
|
+
cdef cnp.ndarray[indices_type, ndim=2] pts
|
|
221
|
+
cdef cnp.ndarray[tensor_dtype, ndim=1] weights
|
|
222
|
+
{{for D in slicers}}
|
|
223
|
+
if isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
224
|
+
with nogil:
|
|
225
|
+
sm = get_hilbert_signed_measure(dereference(<{{D['C_TEMPLATE_TYPE']}}*>(slicer_ptr)),container_ptr, c_grid_shape,degrees, zero_pad, n_jobs, verbose, ignore_inf)
|
|
226
|
+
if len(sm.first) == 0:
|
|
227
|
+
pts = np.empty(shape=(0, slicer.num_parameters), dtype=python_indices_type)
|
|
228
|
+
weights = np.empty(shape=(0), dtype=python_tensor_dtype)
|
|
229
|
+
else:
|
|
230
|
+
pts = np.asarray(sm.first,dtype=python_indices_type)
|
|
231
|
+
weights = np.asarray(sm.second,dtype=python_tensor_dtype)
|
|
232
|
+
return (pts,weights)
|
|
233
|
+
{{endfor}}
|
|
234
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|