Debian Codegraph @

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

raw
1 {# USES_VARIABLES { N } #}
2 {% extends 'common_group.pyx' %}
3
4 {% block maincode %}
5 {# t, not_refractory and lastspike are added as needed_variables in the
6 Thresholder class, we cannot use the USES_VARIABLE mechanism
7 conditionally #}
8
9 # scalar code
10 _vectorisation_idx = 1
11 {{ scalar_code | autoindent }}
12
13 cdef size_t _cpp_numevents = 0
14
15 {# Get the name of the array that stores these events (e.g. the spikespace array) #}
16 {% set _eventspace = get_array_name(eventspace_variable) %}
17
18 for _idx in range(N):
19
20 # vector code
21 _vectorisation_idx = _idx
22 {{ vector_code | autoindent }}
23
24 if _cond:
25 {{_eventspace}}[_cpp_numevents] = _idx
26 _cpp_numevents += 1
27 {% if _uses_refractory %}
28 {{not_refractory}}[_idx] = False
29 {{lastspike}}[_idx] = {{t}}
30 {% endif %}
31
32 {{_eventspace}}[N] = _cpp_numevents
33
34 {% endblock %}
35
36 {% block after_code %}
37 {% set _eventspace = get_array_name(eventspace_variable) %}
38 {{_eventspace}}[N] = 0 # Note that this is not an off-by-1-error: the array has N+1 elements
39 {% endblock %}