Debian Codegraph @

brian2/codegen/runtime/cython_rt/templates/synapses_create_array.pyx

raw
1 {# USES_VARIABLES { _synaptic_pre, _synaptic_post, sources, targets, N,
2 N_pre, N_post, _source_offset, _target_offset }
3 #}
4 {# WRITES_TO_READ_ONLY_VARIABLES { _synaptic_pre, _synaptic_post, N}
5 #}
6 {% extends 'common_group.pyx' %}
7
8 {% block maincode %}
9 cdef size_t _old_num_synapses = {{N}}
10 cdef size_t _new_num_synapses = _old_num_synapses + _num{{sources}}
11
12 {{_dynamic__synaptic_pre_ptr}}.resize(_new_num_synapses)
13 {{_dynamic__synaptic_post_ptr}}.resize(_new_num_synapses)
14 # Get the potentially newly created underlying data arrays
15 cdef int32_t* _synaptic_pre_data = {{_dynamic__synaptic_pre_ptr}}.get_data_ptr()
16 cdef int32_t* _synaptic_post_data = {{_dynamic__synaptic_post_ptr}}.get_data_ptr()
17
18 for _idx in range(_num{{sources}}):
19 # After this code has been executed, the arrays _real_sources and
20 # _real_variables contain the final indices. Having any code here it all is
21 # only necessary for supporting subgroups
22 {{ vector_code | autoindent }}
23 _synaptic_pre_data[_idx + _old_num_synapses] = _real_sources
24 _synaptic_post_data[_idx + _old_num_synapses] = _real_targets
25
26 # now we need to resize all registered variables and set the total number
27 # of synapses (via Python)
28 _owner._resize(_new_num_synapses)
29
30 # And update N_incoming, N_outgoing and synapse_number
31 _owner._update_synapse_numbers(_old_num_synapses)
32 {% endblock %}