File: sync_wrapper.py

package info (click to toggle)
python-pyclustering 0.10.1.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 38,888; python: 24,311; sh: 384; makefile: 105
file content (161 lines) | stat: -rwxr-xr-x 5,541 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
"""!

@brief CCORE Wrapper for oscillatory neural network based on Kuramoto model.

@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause

"""


from pyclustering.core.wrapper import *
from pyclustering.core.pyclustering_package import pyclustering_package, package_extractor


def sync_create_network(num_osc, weight, frequency, type_conn, initial_phases):
    ccore = ccore_library.get()
    
    ccore.sync_create_network.restype = POINTER(c_void_p)
    pointer_network = ccore.sync_create_network(c_uint(num_osc), c_double(weight), c_double(frequency), c_uint(type_conn), c_uint(initial_phases))
    
    return pointer_network


def sync_get_size(pointer_network):
    ccore = ccore_library.get()
    ccore.sync_get_size.restype = c_size_t
    return ccore.sync_get_size(pointer_network)


def sync_destroy_network(pointer_network):
    ccore = ccore_library.get()
    ccore.sync_destroy_network(pointer_network)


def sync_simulate_static(pointer_network, steps, time, solution, collect_dynamic):
    ccore = ccore_library.get()
    ccore.sync_simulate_static.restype = POINTER(c_void_p)
    return ccore.sync_simulate_static(pointer_network, c_uint(steps), c_double(time), c_uint(solution), c_bool(collect_dynamic))


def sync_simulate_dynamic(pointer_network, order, solution, collect_dynamic, step, int_step, threshold_changes):
    ccore = ccore_library.get()
    ccore.sync_simulate_dynamic.restype = POINTER(c_void_p)
    return ccore.sync_simulate_dynamic(pointer_network, c_double(order), c_uint(solution), c_bool(collect_dynamic), c_double(step), c_double(int_step), c_double(threshold_changes))


def sync_order(pointer_network):
    ccore = ccore_library.get()
    ccore.sync_order.restype = c_double
    
    return ccore.sync_order(pointer_network)
    
    
def sync_local_order(pointer_network):
    ccore = ccore_library.get()
    ccore.sync_local_order.restype = c_double
    
    return ccore.sync_local_order(pointer_network)


def sync_connectivity_matrix(pointer_network):
    ccore = ccore_library.get()
    ccore.sync_connectivity_matrix.restype = POINTER(pyclustering_package)
    
    package = ccore.sync_connectivity_matrix(pointer_network)
    
    connectivity_matrix = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return connectivity_matrix


def sync_dynamic_get_size(pointer_dynamic):
    ccore = ccore_library.get()
    ccore.sync_dynamic_get_time.restype = c_size_t
    return ccore.sync_dynamic_get_size(pointer_dynamic)


def sync_dynamic_destroy(pointer_dynamic):
    ccore = ccore_library.get()
    ccore.sync_dynamic_destroy(pointer_dynamic)


def sync_dynamic_allocate_sync_ensembles(pointer_dynamic, tolerance, iteration):
    if iteration is None:
        iteration = sync_dynamic_get_size(pointer_dynamic) - 1
    
    ccore = ccore_library.get()
    
    ccore.sync_dynamic_allocate_sync_ensembles.restype = POINTER(pyclustering_package)
    package = ccore.sync_dynamic_allocate_sync_ensembles(pointer_dynamic, c_double(tolerance), c_size_t(iteration))
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result


def sync_dynamic_allocate_correlation_matrix(pointer_dynamic, iteration):
    analyse_iteration = iteration
    if analyse_iteration is None:
        analyse_iteration = sync_dynamic_get_size(pointer_dynamic) - 1
    
    ccore = ccore_library.get()
    
    ccore.sync_dynamic_allocate_correlation_matrix.restype = POINTER(pyclustering_package)
    package = ccore.sync_dynamic_allocate_correlation_matrix(pointer_dynamic, c_uint(analyse_iteration))
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result


def sync_dynamic_get_output(pointer_dynamic):
    ccore = ccore_library.get()
    
    ccore.sync_dynamic_get_output.restype = POINTER(pyclustering_package)
    package = ccore.sync_dynamic_get_output(pointer_dynamic)
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result


def sync_dynamic_get_time(pointer_dynamic):
    ccore = ccore_library.get()
    
    ccore.sync_dynamic_get_time.restype = POINTER(pyclustering_package)
    package = ccore.sync_dynamic_get_time(pointer_dynamic)
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result


def sync_dynamic_calculate_order(pointer_dynamic, start_iteration, stop_iteration):
    ccore = ccore_library.get()
    
    ccore.sync_dynamic_calculate_order.restype = POINTER(pyclustering_package)
    package = ccore.sync_dynamic_calculate_order(pointer_dynamic, start_iteration, stop_iteration)
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result


def sync_dynamic_calculate_local_order(pointer_dynamic, pointer_network, start_iteration, stop_iteration):
    ccore = ccore_library.get()

    ccore.sync_dynamic_calculate_local_order.restype = POINTER(pyclustering_package)
    package = ccore.sync_dynamic_calculate_local_order(pointer_dynamic, pointer_network, c_size_t(start_iteration), c_size_t(stop_iteration))
    
    result = package_extractor(package).extract()
    ccore.free_pyclustering_package(package)
    
    return result