multipers 2.4.0b1__cp312-cp312-macosx_11_0_arm64.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.
- multipers/.dylibs/libboost_timer.dylib +0 -0
- multipers/.dylibs/libc++.1.0.dylib +0 -0
- multipers/.dylibs/libtbb.12.17.dylib +0 -0
- multipers/__init__.py +33 -0
- multipers/_signed_measure_meta.py +426 -0
- multipers/_slicer_meta.py +231 -0
- multipers/array_api/__init__.py +62 -0
- multipers/array_api/numpy.py +124 -0
- multipers/array_api/torch.py +133 -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 +736 -0
- multipers/filtration_conversions.pxd.tp +226 -0
- multipers/filtrations/__init__.py +21 -0
- multipers/filtrations/density.py +529 -0
- multipers/filtrations/filtrations.py +480 -0
- multipers/filtrations.pxd +534 -0
- multipers/filtrations.pxd.tp +332 -0
- multipers/function_rips.cpython-312-darwin.so +0 -0
- multipers/function_rips.pyx +104 -0
- multipers/grids.cpython-312-darwin.so +0 -0
- multipers/grids.pyx +538 -0
- multipers/gudhi/Persistence_slices_interface.h +213 -0
- multipers/gudhi/Simplex_tree_interface.h +274 -0
- multipers/gudhi/Simplex_tree_multi_interface.h +648 -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 +52 -0
- multipers/gudhi/gudhi/Degree_rips_bifiltration.h +2307 -0
- multipers/gudhi/gudhi/Dynamic_multi_parameter_filtration.h +2524 -0
- multipers/gudhi/gudhi/Fields/Multi_field.h +453 -0
- multipers/gudhi/gudhi/Fields/Multi_field_operators.h +460 -0
- multipers/gudhi/gudhi/Fields/Multi_field_shared.h +444 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small.h +584 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_operators.h +490 -0
- multipers/gudhi/gudhi/Fields/Multi_field_small_shared.h +580 -0
- multipers/gudhi/gudhi/Fields/Z2_field.h +391 -0
- multipers/gudhi/gudhi/Fields/Z2_field_operators.h +389 -0
- multipers/gudhi/gudhi/Fields/Zp_field.h +493 -0
- multipers/gudhi/gudhi/Fields/Zp_field_operators.h +384 -0
- multipers/gudhi/gudhi/Fields/Zp_field_shared.h +492 -0
- multipers/gudhi/gudhi/Flag_complex_edge_collapser.h +337 -0
- multipers/gudhi/gudhi/Matrix.h +2200 -0
- multipers/gudhi/gudhi/Multi_filtration/Multi_parameter_generator.h +1712 -0
- multipers/gudhi/gudhi/Multi_filtration/multi_filtration_conversions.h +237 -0
- multipers/gudhi/gudhi/Multi_filtration/multi_filtration_utils.h +225 -0
- multipers/gudhi/gudhi/Multi_parameter_filtered_complex.h +485 -0
- multipers/gudhi/gudhi/Multi_parameter_filtration.h +2643 -0
- multipers/gudhi/gudhi/Multi_persistence/Box.h +233 -0
- multipers/gudhi/gudhi/Multi_persistence/Line.h +309 -0
- multipers/gudhi/gudhi/Multi_persistence/Multi_parameter_filtered_complex_pcoh_interface.h +268 -0
- multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_cohomology.h +159 -0
- multipers/gudhi/gudhi/Multi_persistence/Persistence_interface_matrix.h +463 -0
- multipers/gudhi/gudhi/Multi_persistence/Point.h +853 -0
- multipers/gudhi/gudhi/Off_reader.h +173 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix.h +834 -0
- multipers/gudhi/gudhi/Persistence_matrix/Base_matrix_with_column_compression.h +838 -0
- multipers/gudhi/gudhi/Persistence_matrix/Boundary_matrix.h +833 -0
- multipers/gudhi/gudhi/Persistence_matrix/Chain_matrix.h +1367 -0
- multipers/gudhi/gudhi/Persistence_matrix/Id_to_index_overlay.h +1157 -0
- multipers/gudhi/gudhi/Persistence_matrix/Position_to_index_overlay.h +869 -0
- multipers/gudhi/gudhi/Persistence_matrix/RU_matrix.h +905 -0
- multipers/gudhi/gudhi/Persistence_matrix/allocators/entry_constructors.h +122 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_pairing.h +260 -0
- multipers/gudhi/gudhi/Persistence_matrix/base_swap.h +288 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_pairing.h +170 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_rep_cycles.h +247 -0
- multipers/gudhi/gudhi/Persistence_matrix/chain_vine_swap.h +571 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/chain_column_extra_properties.h +182 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_dimension_holder.h +130 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/column_utilities.h +235 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/entry_types.h +312 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/heap_column.h +1092 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_list_column.h +923 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/intrusive_set_column.h +914 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/list_column.h +930 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/naive_vector_column.h +1071 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/row_access.h +203 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/set_column.h +886 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/unordered_set_column.h +984 -0
- multipers/gudhi/gudhi/Persistence_matrix/columns/vector_column.h +1213 -0
- multipers/gudhi/gudhi/Persistence_matrix/index_mapper.h +58 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_dimension_holders.h +227 -0
- multipers/gudhi/gudhi/Persistence_matrix/matrix_row_access.h +200 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_pairing.h +166 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_rep_cycles.h +319 -0
- multipers/gudhi/gudhi/Persistence_matrix/ru_vine_swap.h +562 -0
- multipers/gudhi/gudhi/Persistence_on_a_line.h +152 -0
- multipers/gudhi/gudhi/Persistence_on_rectangle.h +617 -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 +769 -0
- multipers/gudhi/gudhi/Points_off_io.h +171 -0
- multipers/gudhi/gudhi/Projective_cover_kernel.h +379 -0
- multipers/gudhi/gudhi/Simple_object_pool.h +69 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_iterators.h +559 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h +83 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_siblings.h +121 -0
- multipers/gudhi/gudhi/Simplex_tree/Simplex_tree_star_simplex_iterators.h +277 -0
- multipers/gudhi/gudhi/Simplex_tree/filtration_value_utils.h +155 -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 +60 -0
- multipers/gudhi/gudhi/Simplex_tree/simplex_tree_options.h +105 -0
- multipers/gudhi/gudhi/Simplex_tree.h +3170 -0
- multipers/gudhi/gudhi/Slicer.h +848 -0
- multipers/gudhi/gudhi/Thread_safe_slicer.h +393 -0
- multipers/gudhi/gudhi/distance_functions.h +62 -0
- multipers/gudhi/gudhi/graph_simplicial_complex.h +104 -0
- multipers/gudhi/gudhi/multi_simplex_tree_helpers.h +147 -0
- multipers/gudhi/gudhi/persistence_interval.h +263 -0
- multipers/gudhi/gudhi/persistence_matrix_options.h +188 -0
- multipers/gudhi/gudhi/reader_utils.h +367 -0
- multipers/gudhi/gudhi/simple_mdspan.h +484 -0
- multipers/gudhi/gudhi/slicer_helpers.h +779 -0
- multipers/gudhi/tmp_h0_pers/mma_interface_h0.h +223 -0
- multipers/gudhi/tmp_h0_pers/naive_merge_tree.h +536 -0
- multipers/io.cpython-312-darwin.so +0 -0
- multipers/io.pyx +472 -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 +1667 -0
- multipers/ml/sliced_wasserstein.py +461 -0
- multipers/ml/tools.py +113 -0
- multipers/mma_structures.cpython-312-darwin.so +0 -0
- multipers/mma_structures.pxd +134 -0
- multipers/mma_structures.pyx +1483 -0
- multipers/mma_structures.pyx.tp +1126 -0
- multipers/multi_parameter_rank_invariant/diff_helpers.h +85 -0
- multipers/multi_parameter_rank_invariant/euler_characteristic.h +95 -0
- multipers/multi_parameter_rank_invariant/function_rips.h +317 -0
- multipers/multi_parameter_rank_invariant/hilbert_function.h +761 -0
- multipers/multi_parameter_rank_invariant/persistence_slices.h +149 -0
- multipers/multi_parameter_rank_invariant/rank_invariant.h +350 -0
- multipers/multiparameter_edge_collapse.py +41 -0
- multipers/multiparameter_module_approximation/approximation.h +2541 -0
- multipers/multiparameter_module_approximation/debug.h +107 -0
- multipers/multiparameter_module_approximation/format_python-cpp.h +292 -0
- multipers/multiparameter_module_approximation/utilities.h +428 -0
- multipers/multiparameter_module_approximation.cpython-312-darwin.so +0 -0
- multipers/multiparameter_module_approximation.pyx +286 -0
- multipers/ops.cpython-312-darwin.so +0 -0
- multipers/ops.pyx +231 -0
- multipers/pickle.py +89 -0
- multipers/plots.py +550 -0
- multipers/point_measure.cpython-312-darwin.so +0 -0
- multipers/point_measure.pyx +409 -0
- multipers/simplex_tree_multi.cpython-312-darwin.so +0 -0
- multipers/simplex_tree_multi.pxd +136 -0
- multipers/simplex_tree_multi.pyx +11719 -0
- multipers/simplex_tree_multi.pyx.tp +2102 -0
- multipers/slicer.cpython-312-darwin.so +0 -0
- multipers/slicer.pxd +2097 -0
- multipers/slicer.pxd.tp +263 -0
- multipers/slicer.pyx +13042 -0
- multipers/slicer.pyx.tp +1259 -0
- multipers/tensor/tensor.h +672 -0
- multipers/tensor.pxd +13 -0
- multipers/test.pyx +44 -0
- multipers/tests/__init__.py +70 -0
- multipers/torch/__init__.py +1 -0
- multipers/torch/diff_grids.py +240 -0
- multipers/torch/rips_density.py +310 -0
- multipers/vector_interface.pxd +46 -0
- multipers-2.4.0b1.dist-info/METADATA +131 -0
- multipers-2.4.0b1.dist-info/RECORD +184 -0
- multipers-2.4.0b1.dist-info/WHEEL +6 -0
- multipers-2.4.0b1.dist-info/licenses/LICENSE +21 -0
- multipers-2.4.0b1.dist-info/top_level.txt +1 -0
multipers/slicer.pxd.tp
ADDED
|
@@ -0,0 +1,263 @@
|
|
|
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
|
+
with open("build/tmp/_simplextrees_.pkl", "rb") as f:
|
|
18
|
+
simplex_trees = pickle.load(f)
|
|
19
|
+
|
|
20
|
+
}}
|
|
21
|
+
|
|
22
|
+
cimport numpy as cnp
|
|
23
|
+
|
|
24
|
+
# SequentialDataset and its two concrete subclasses are (optionally randomized)
|
|
25
|
+
# iterators over the rows of a matrix X and corresponding target values y.
|
|
26
|
+
|
|
27
|
+
from libcpp.utility cimport pair
|
|
28
|
+
from libcpp cimport bool, int, float
|
|
29
|
+
from libcpp.vector cimport vector
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
from libc.stdint cimport intptr_t, uint16_t, uint32_t, int32_t, uint64_t, int64_t
|
|
33
|
+
from cython cimport uint
|
|
34
|
+
|
|
35
|
+
import numpy as np
|
|
36
|
+
python_value_type=np.float32
|
|
37
|
+
from libcpp.string cimport string
|
|
38
|
+
|
|
39
|
+
cdef extern from "Simplex_tree_multi_interface.h" namespace "Gudhi::multiparameter::python_interface":
|
|
40
|
+
cdef cppclass Simplex_tree_multi_interface[F=*, value_type=*]:
|
|
41
|
+
pass
|
|
42
|
+
|
|
43
|
+
from multipers.filtrations cimport *
|
|
44
|
+
ctypedef vector[uint] cycle_type ## its the cycle type of matrix
|
|
45
|
+
|
|
46
|
+
cdef extern from "gudhi/Multi_parameter_filtered_complex.h" namespace "Gudhi::multi_persistence":
|
|
47
|
+
cdef cppclass Multi_parameter_filtered_complex[F]:
|
|
48
|
+
Multi_parameter_filtered_complex()
|
|
49
|
+
Multi_parameter_filtered_complex(vector[vector[uint32_t]]&, vector[int]&, vector[F]&)
|
|
50
|
+
|
|
51
|
+
{{for D in slicers}}
|
|
52
|
+
#------------------------------------------------------------------------------
|
|
53
|
+
cdef extern from "Persistence_slices_interface.h" namespace "multipers::tmp_interface":
|
|
54
|
+
cdef cppclass Bar[T]:
|
|
55
|
+
pass
|
|
56
|
+
|
|
57
|
+
cdef cppclass Barcode[S, T]:
|
|
58
|
+
size_t size()
|
|
59
|
+
Bar[T]* data()
|
|
60
|
+
|
|
61
|
+
cdef cppclass Dim_barcode[S, T]:
|
|
62
|
+
size_t size()
|
|
63
|
+
Barcode[S,T]& operator[](size_t)
|
|
64
|
+
|
|
65
|
+
cdef cppclass {{D['C_TEMPLATE_TYPE']}} "{{D['TRUC_TYPE']}}":
|
|
66
|
+
ctypedef {{D['C_VALUE_TYPE']}} value_type
|
|
67
|
+
|
|
68
|
+
{{D['C_TEMPLATE_TYPE']}}()
|
|
69
|
+
{{D['C_TEMPLATE_TYPE']}}(Multi_parameter_filtered_complex[{{D['FILTRATION_TYPE']}}]&) except +
|
|
70
|
+
|
|
71
|
+
{{for D2 in slicers}}
|
|
72
|
+
{{D['C_TEMPLATE_TYPE']}}(const {{D2['C_TEMPLATE_TYPE']}}&) except + nogil
|
|
73
|
+
{{endfor}}
|
|
74
|
+
|
|
75
|
+
uint32_t num_generators "get_number_of_cycle_generators"() nogil
|
|
76
|
+
uint32_t num_parameters "get_number_of_parameters"() nogil
|
|
77
|
+
{{if D['IS_VINE']}}
|
|
78
|
+
vector[uint32_t] get_current_order() nogil
|
|
79
|
+
void vineyard_update() nogil
|
|
80
|
+
vector[vector[vector[uint32_t]]] get_representative_cycles(bool) nogil
|
|
81
|
+
vector[uint32_t] get_most_persistent_cycle(int, bool) nogil
|
|
82
|
+
{{endif}}
|
|
83
|
+
vector[{{D['C_VALUE_TYPE']}}] get_one_filtration "get_slice"()
|
|
84
|
+
pair[{{D['FILTRATION_TYPE']}}, {{D['FILTRATION_TYPE']}}] get_bounding_box() except + nogil
|
|
85
|
+
vector[{{D['FILTRATION_TYPE']}}]& get_filtrations "get_filtration_values"() nogil
|
|
86
|
+
vector[int] get_dimensions() nogil
|
|
87
|
+
int get_dimension(uint32_t) nogil
|
|
88
|
+
const vector[vector[uint32_t]]& get_boundaries() nogil
|
|
89
|
+
vector[uint32_t] get_boundary(uint32_t) nogil
|
|
90
|
+
void set_one_filtration "set_slice"(const vector[{{D['C_VALUE_TYPE']}}]&) nogil
|
|
91
|
+
void push_to(const Line[{{D['C_VALUE_TYPE']}}]&) nogil
|
|
92
|
+
int prune_above_dimension(int) except + nogil
|
|
93
|
+
void coarsen_on_grid_inplace "coarsen_on_grid"(vector[vector[{{D['C_VALUE_TYPE']}}]], bool) nogil
|
|
94
|
+
void initialize_persistence_computation(bool) except+ nogil
|
|
95
|
+
void initialize_persistence_computation() except+ nogil # ignore_inf = true
|
|
96
|
+
Dim_barcode[{{D['C_TEMPLATE_TYPE']}}, {{D['C_VALUE_TYPE']}}] get_barcode "get_flat_barcode<true, {{D['C_VALUE_TYPE']}}, false>"() nogil
|
|
97
|
+
Dim_barcode[{{D['C_TEMPLATE_TYPE']}}, int] get_barcode_idx "get_flat_barcode<true, int, true>"() nogil
|
|
98
|
+
string slicer_to_str({{D['C_TEMPLATE_TYPE']}}&) nogil #to_str
|
|
99
|
+
{{D['C_TEMPLATE_TYPE']}} build_permuted_slicer "build_permuted_slicer"({{D['C_TEMPLATE_TYPE']}}&, vector[uint32_t]&) except + nogil #permute
|
|
100
|
+
pair[{{D['C_TEMPLATE_TYPE']}}, vector[uint32_t]] build_permuted_slicer "build_permuted_slicer"({{D['C_TEMPLATE_TYPE']}}&) except + nogil #colexical_rearange
|
|
101
|
+
{{if D['COLUMN_TYPE'] is not None}}
|
|
102
|
+
{{D['C_TEMPLATE_TYPE'][:-3]+"i32"}} build_slicer_coarsen_on_grid "build_slicer_coarsen_on_grid"({{D['C_TEMPLATE_TYPE']}}&, vector[vector[{{D['C_VALUE_TYPE']}}]]&) nogil #coarsen_on_grid
|
|
103
|
+
{{endif}}
|
|
104
|
+
{{if D['COLUMN_TYPE'] is not None}}
|
|
105
|
+
{{D['C_TEMPLATE_TYPE']}} build_slicer_from_projective_cover_kernel "build_slicer_from_projective_cover_kernel"({{D['C_TEMPLATE_TYPE']}}&, int) except + nogil #projective_cover_kernel
|
|
106
|
+
{{endif}}
|
|
107
|
+
void write_slicer_to_scc_file "write_slicer_to_scc_file"(string&, {{D['C_TEMPLATE_TYPE']}}&, int, bool, bool, bool, bool) nogil #write_to_scc_file
|
|
108
|
+
|
|
109
|
+
#------------------------------------------------------------------------------
|
|
110
|
+
cdef extern from "gudhi/slicer_helpers.h" namespace "Gudhi::multi_persistence":
|
|
111
|
+
{{D['C_TEMPLATE_TYPE']}} build_slicer_from_scc_file_{{D['C_TEMPLATE_TYPE']}} "Gudhi::multi_persistence::build_slicer_from_scc_file<{{D['TRUC_TYPE']}}>"(string&, bool, bool, int) except + nogil #build_from_scc_file
|
|
112
|
+
{{for ST in simplex_trees}}
|
|
113
|
+
{{D['C_TEMPLATE_TYPE']}} build_slicer_from_simplex_tree_{{D['C_TEMPLATE_TYPE']}}_{{ST["PyFil"]}} "Gudhi::multi_persistence::build_slicer_from_simplex_tree<{{D['TRUC_TYPE']}}>"({{ST["ST_INTERFACE"]}}&) except + nogil
|
|
114
|
+
{{endfor}}
|
|
115
|
+
{{D['C_TEMPLATE_TYPE']}} build_slicer_from_bitmap_{{D['C_TEMPLATE_TYPE']}} "Gudhi::multi_persistence::build_slicer_from_bitmap<{{D['TRUC_TYPE']}}>"(vector[{{D['FILTRATION_TYPE']}}], vector[unsigned int]) except + nogil
|
|
116
|
+
vector[Dim_barcode[{{D['C_TEMPLATE_TYPE']}}, int]] custom_persistences "persistence_on_slices<{{D['TRUC_TYPE']}}, {{D['C_VALUE_TYPE']}}, int, true>"({{D['C_TEMPLATE_TYPE']}}&, {{D['C_VALUE_TYPE']}}*, int, bool) except + nogil
|
|
117
|
+
vector[Dim_barcode[{{D['C_TEMPLATE_TYPE']}}, {{D['C_VALUE_TYPE']}}]] persistence_on_lines "persistence_on_slices"({{D['C_TEMPLATE_TYPE']}}&, vector[vector[{{D['C_VALUE_TYPE']}}]]&, vector[vector[{{D['C_VALUE_TYPE']}}]]&, bool) except + nogil
|
|
118
|
+
|
|
119
|
+
cdef inline _b2np_{{D['C_TEMPLATE_TYPE']}}(const Barcode[{{D['C_TEMPLATE_TYPE']}}, {{D['C_VALUE_TYPE']}}]& barcode):
|
|
120
|
+
cdef Py_ssize_t size = barcode.size() * 2
|
|
121
|
+
if size == 0:
|
|
122
|
+
return np.empty(shape=(0, 2), dtype={{D['PY_VALUE_TYPE']}})
|
|
123
|
+
cdef {{D['C_VALUE_TYPE']}}[:] view = <{{D['C_VALUE_TYPE']}}[:size]>(<{{D['C_VALUE_TYPE']}}*>(barcode.data()))
|
|
124
|
+
#copy as the barcode will very probably be destroyed afterwards
|
|
125
|
+
return np.array(view).reshape((-1, 2))
|
|
126
|
+
|
|
127
|
+
cdef inline _db2np_{{D['C_TEMPLATE_TYPE']}}(const Dim_barcode[{{D['C_TEMPLATE_TYPE']}}, {{D['C_VALUE_TYPE']}}]& barcode):
|
|
128
|
+
cdef Py_ssize_t dims = barcode.size()
|
|
129
|
+
return [_b2np_{{D['C_TEMPLATE_TYPE']}}(barcode[i]) for i in range(dims)]
|
|
130
|
+
|
|
131
|
+
cdef inline _b2np_{{D['C_TEMPLATE_TYPE']}}_idx(const Barcode[{{D['C_TEMPLATE_TYPE']}}, int]& barcode):
|
|
132
|
+
cdef Py_ssize_t size = barcode.size() * 2
|
|
133
|
+
if size == 0:
|
|
134
|
+
return np.empty(shape=(0, 2), dtype=np.dtype(int))
|
|
135
|
+
cdef int[:] view = <int[:size]>(<int*>(barcode.data()))
|
|
136
|
+
#copy as the barcode will very probably be destroyed afterwards
|
|
137
|
+
return np.array(view).reshape((-1, 2))
|
|
138
|
+
|
|
139
|
+
cdef inline _db2np_{{D['C_TEMPLATE_TYPE']}}_idx(const Dim_barcode[{{D['C_TEMPLATE_TYPE']}}, int]& barcode):
|
|
140
|
+
cdef Py_ssize_t dims = barcode.size()
|
|
141
|
+
return [_b2np_{{D['C_TEMPLATE_TYPE']}}_idx(barcode[i]) for i in range(dims)]
|
|
142
|
+
|
|
143
|
+
{{endfor}}
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
#### MMA Stuff
|
|
147
|
+
|
|
148
|
+
from multipers.mma_structures cimport Module
|
|
149
|
+
cdef extern from "multiparameter_module_approximation/approximation.h" namespace "Gudhi::multiparameter::mma":
|
|
150
|
+
{{for D in slicers}}
|
|
151
|
+
{{if D['IS_VINE'] and D['IS_FLOAT']}}
|
|
152
|
+
Module[{{D['C_VALUE_TYPE']}}] multiparameter_module_approximation({{D['C_TEMPLATE_TYPE']}}&, vector[{{D['C_VALUE_TYPE']}}]&, {{D['C_VALUE_TYPE']}}, Box[{{D['C_VALUE_TYPE']}}]&, bool, bool, bool) except + nogil
|
|
153
|
+
{{endif}}
|
|
154
|
+
{{endfor}}
|
|
155
|
+
pass
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
import multipers.slicer as mps
|
|
161
|
+
from cython.operator cimport dereference
|
|
162
|
+
{{for C_VALUE_TYPE,PYTHON_VALUE_TYPE,SHORT_VALUE_TYPE in float_value_types}}
|
|
163
|
+
cdef inline Module[{{C_VALUE_TYPE}}] _multiparameter_module_approximation_{{SHORT_VALUE_TYPE}}(object slicer, vector[{{C_VALUE_TYPE}}] direction, {{C_VALUE_TYPE}} max_error, Box[{{C_VALUE_TYPE}}] box, bool threshold, bool complete, bool verbose):
|
|
164
|
+
import multipers.slicer as mps
|
|
165
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
166
|
+
cdef Module[{{C_VALUE_TYPE}}] mod
|
|
167
|
+
if False:
|
|
168
|
+
pass
|
|
169
|
+
{{for D in slicers}}
|
|
170
|
+
{{if D['IS_VINE'] and D['SHORT_VALUE_TYPE'] == SHORT_VALUE_TYPE}}
|
|
171
|
+
elif isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
172
|
+
with nogil:
|
|
173
|
+
mod = multiparameter_module_approximation(dereference(<{{D['C_TEMPLATE_TYPE']}}*>(slicer_ptr)), direction, max_error, box, threshold, complete, verbose)
|
|
174
|
+
return mod
|
|
175
|
+
{{endif}}
|
|
176
|
+
{{endfor}}
|
|
177
|
+
else:
|
|
178
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|
|
179
|
+
{{endfor}}
|
|
180
|
+
|
|
181
|
+
###### RANK INVARIANT
|
|
182
|
+
from libc.stdint cimport intptr_t, uint16_t, uint32_t, int32_t, int16_t, int8_t
|
|
183
|
+
ctypedef int32_t tensor_dtype
|
|
184
|
+
ctypedef int32_t indices_type
|
|
185
|
+
python_indices_type=np.int32
|
|
186
|
+
python_tensor_dtype = np.int32
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
ctypedef pair[vector[vector[indices_type]], vector[tensor_dtype]] signed_measure_type
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
cdef extern from "multi_parameter_rank_invariant/rank_invariant.h" namespace "Gudhi::multiparameter::rank_invariant":
|
|
195
|
+
## from slicers
|
|
196
|
+
{{for D in slicers}}
|
|
197
|
+
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
|
|
198
|
+
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
|
|
199
|
+
{{endfor}}
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
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):
|
|
206
|
+
import multipers.slicer as mps
|
|
207
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
208
|
+
{{for D in slicers}}
|
|
209
|
+
if isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
210
|
+
with nogil:
|
|
211
|
+
compute_rank_invariant_python(dereference(<{{D['C_TEMPLATE_TYPE']}}*>(slicer_ptr)),container_ptr, c_grid_shape,degrees, n_jobs,ignore_inf)
|
|
212
|
+
return
|
|
213
|
+
{{endfor}}
|
|
214
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
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):
|
|
219
|
+
import multipers.slicer as mps
|
|
220
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
221
|
+
cdef signed_measure_type sm
|
|
222
|
+
cdef cnp.ndarray[indices_type, ndim=2] pts
|
|
223
|
+
cdef cnp.ndarray[tensor_dtype, ndim=1] weights
|
|
224
|
+
{{for D in slicers}}
|
|
225
|
+
if isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
226
|
+
with nogil:
|
|
227
|
+
sm = compute_rank_signed_measure(dereference(<{{D['C_TEMPLATE_TYPE']}}*>(slicer_ptr)),container_ptr, c_grid_shape,degrees, n_jobs, verbose, ignore_inf)
|
|
228
|
+
pts = np.asarray(sm.first,dtype=python_indices_type)
|
|
229
|
+
weights = np.asarray(sm.second,dtype=python_tensor_dtype)
|
|
230
|
+
return (pts,weights)
|
|
231
|
+
{{endfor}}
|
|
232
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
#### Hilbert Function
|
|
237
|
+
|
|
238
|
+
cdef extern from "multi_parameter_rank_invariant/hilbert_function.h" namespace "Gudhi::multiparameter::hilbert_function":
|
|
239
|
+
## from slicers
|
|
240
|
+
{{for D in slicers}}
|
|
241
|
+
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
|
|
242
|
+
{{endfor}}
|
|
243
|
+
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):
|
|
244
|
+
import multipers.slicer as mps
|
|
245
|
+
if len(slicer) == 0:
|
|
246
|
+
return (np.empty(shape=(0, 1), dtype=slicer.dtype), np.empty(shape=(0), dtype=int))
|
|
247
|
+
cdef intptr_t slicer_ptr = <intptr_t>(slicer.get_ptr())
|
|
248
|
+
cdef signed_measure_type sm
|
|
249
|
+
cdef cnp.ndarray[indices_type, ndim=2] pts
|
|
250
|
+
cdef cnp.ndarray[tensor_dtype, ndim=1] weights
|
|
251
|
+
{{for D in slicers}}
|
|
252
|
+
if isinstance(slicer, mps.{{D['PYTHON_TYPE']}}):
|
|
253
|
+
with nogil:
|
|
254
|
+
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)
|
|
255
|
+
if len(sm.first) == 0:
|
|
256
|
+
pts = np.empty(shape=(0, slicer.num_parameters), dtype=python_indices_type)
|
|
257
|
+
weights = np.empty(shape=(0), dtype=python_tensor_dtype)
|
|
258
|
+
else:
|
|
259
|
+
pts = np.asarray(sm.first,dtype=python_indices_type)
|
|
260
|
+
weights = np.asarray(sm.second,dtype=python_tensor_dtype)
|
|
261
|
+
return (pts,weights)
|
|
262
|
+
{{endfor}}
|
|
263
|
+
raise ValueError(f"Unsupported slicer type {type(slicer)}")
|