Completed
Push — master ( 8c6692...c118e7 )
by Andrei
01:09
created

sync_connectivity_matrix()   A

Complexity

Conditions 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
"""!
2
3
@brief CCORE Wrapper for oscillatory neural network based on Kuramoto model.
4
5
@authors Andrei Novikov ([email protected])
6
@date 2014-2017
7
@copyright GNU Public License
8
9
@cond GNU_PUBLIC_LICENSE
10
    PyClustering is free software: you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation, either version 3 of the License, or
13
    (at your option) any later version.
14
    
15
    PyClustering is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
    
20
    You should have received a copy of the GNU General Public License
21
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
@endcond
23
24
"""
25
26
from pyclustering.core.wrapper import *;
0 ignored issues
show
Unused Code introduced by
byref was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int64 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int32 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
memset was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
ArgumentError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
resize was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Array was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
HRESULT was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_buffer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
hsyncnet_process was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ushort was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
pyclustering_type_data was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
hsyncnet_analyser_destroy was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
addressof was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_longlong was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int16 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
PyDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
get_last_error was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
core was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
data_representation was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
extract_dynamics was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
os was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_long was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
pydll was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Structure was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
SetPointerType was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_voidp was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint16 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_float was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
FormatError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint64 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
CDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
windll was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
kind was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
memmove was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
cluster_representation was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
WinDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
WinError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_char was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
WINFUNCTYPE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_wchar_p was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
get_errno was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
ARRAY was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
DEFAULT_MODE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
extract_clusters was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
wstring_at was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint8 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
hsyncnet_destroy_network was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
PYFUNCTYPE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
pythonapi was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
set_last_error was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
create_pointer_data was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
string_at was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_uint32 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
RTLD_LOCAL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_short was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
dynamic_result was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
BigEndianStructure was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
clustering_result was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ulong was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
GetLastError was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ubyte was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
create_string_buffer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
cast was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
alignment was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
hsyncnet_create_network was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
create_unicode_buffer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
OleDLL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
py_object was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_longdouble was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
Union was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_int8 was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
DllCanUnloadNow was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
CFUNCTYPE was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
set_errno was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_wchar was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_char_p was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_byte was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ulonglong was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
pointer was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
sizeof was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
c_ssize_t was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
LibraryLoader was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
oledll was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
LittleEndianStructure was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
RTLD_GLOBAL was imported with wildcard, but is not used.
Loading history...
Unused Code introduced by
DllGetClassObject was imported with wildcard, but is not used.
Loading history...
27
28
29
def sync_create_network(num_osc, weight, frequency, type_conn, initial_phases):
30
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
31
    
32
    ccore.sync_create_network.restype = POINTER(c_void_p);
33
    pointer_network = ccore.sync_create_network(c_uint(num_osc), c_double(weight), c_double(frequency), c_uint(type_conn), c_uint(initial_phases));
34
    
35
    return pointer_network;
36
37
38
def sync_destroy_network(pointer_network):
39
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
40
    ccore.sync_destroy_network(pointer_network);
41
42
43
def sync_simulate_static(pointer_network, steps, time, solution, collect_dynamic):
44
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
45
    ccore.sync_simulate_static.restype = POINTER(c_void_p);
46
    return ccore.sync_simulate_static(pointer_network, c_uint(steps), c_double(time), c_uint(solution), c_bool(collect_dynamic));
47
48
49
def sync_simulate_dynamic(pointer_network, order, solution, collect_dynamic, step, int_step, threshold_changes):
50
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
51
    ccore.sync_simulate_dynamic.restype = POINTER(c_void_p);
52
    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));
53
54
55
def sync_order(pointer_network):
56
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
57
    ccore.sync_order.restype = c_double;
58
    
59
    return ccore.sync_order(pointer_network);
60
    
61
    
62
def sync_local_order(pointer_network):
63
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
64
    ccore.sync_local_order.restype = c_double;
65
    
66
    return ccore.sync_local_order(pointer_network);
67
68
69
def sync_connectivity_matrix(pointer_network):
70
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
71
    ccore.sync_connectivity_matrix.restype = POINTER(pyclustering_package);
72
    
73
    package = ccore.sync_connectivity_matrix(pointer_network);
74
    
75
    connectivity_matrix = extract_pyclustering_package(package);
76
    ccore.free_pyclustering_package(package);
77
    
78
    return connectivity_matrix;
79
80
81
def sync_dynamic_get_size(pointer_dynamic):
82
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
83
    ccore.sync_dynamic_get_time.restype = c_size_t;
84
    return ccore.sync_dynamic_get_size(pointer_dynamic);
85
86
87
def sync_dynamic_destroy(pointer_dynamic):
88
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
89
    ccore.sync_dynamic_destroy(pointer_dynamic);
90
91
92
def sync_dynamic_allocate_sync_ensembles(pointer_dynamic, tolerance, iteration):
93
    if (iteration is None):
94
        iteration = sync_dynamic_get_size(pointer_dynamic) - 1;
95
    
96
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
97
    
98
    ccore.sync_dynamic_allocate_sync_ensembles.restype = POINTER(pyclustering_package);
99
    package = ccore.sync_dynamic_allocate_sync_ensembles(pointer_dynamic, c_double(tolerance), c_size_t(iteration));
100
    
101
    result = extract_pyclustering_package(package);
102
    ccore.free_pyclustering_package(package);
103
    
104
    return result;
105
106
107
def sync_dynamic_allocate_correlation_matrix(pointer_dynamic, iteration):
108
    analyse_iteration = iteration;
109
    if (analyse_iteration is None):
110
        analyse_iteration = sync_dynamic_get_size(pointer_dynamic) - 1;
111
    
112
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
113
    
114
    ccore.sync_dynamic_allocate_correlation_matrix.restype = POINTER(pyclustering_package);
115
    package = ccore.sync_dynamic_allocate_correlation_matrix(pointer_dynamic, c_uint(analyse_iteration));
116
    
117
    result = extract_pyclustering_package(package);
118
    ccore.free_pyclustering_package(package);
119
    
120
    return result;
121
122
123
def sync_dynamic_get_output(pointer_dynamic):
124
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
125
    
126
    ccore.sync_dynamic_get_output.restype = POINTER(pyclustering_package);
127
    package = ccore.sync_dynamic_get_output(pointer_dynamic);
128
    
129
    result = extract_pyclustering_package(package);
130
    ccore.free_pyclustering_package(package);
131
    
132
    return result;
133
134
135
def sync_dynamic_get_time(pointer_dynamic):
136
    ccore = cdll.LoadLibrary(PATH_DLL_CCORE_64);
137
    
138
    ccore.sync_dynamic_get_time.restype = POINTER(pyclustering_package);
139
    package = ccore.sync_dynamic_get_time(pointer_dynamic);
140
    
141
    result = extract_pyclustering_package(package);
142
    ccore.free_pyclustering_package(package);
143
    
144
    return result;
145