| 1 |
{# USES_VARIABLES { N } #} |
| 2 |
{% extends 'common_group.cpp' %} |
| 3 |
{% block maincode %} |
| 4 |
{# not_refractory and lastspike are added as needed_variables in the |
| 5 |
Thresholder class, we cannot use the USES_VARIABLE mechanism |
| 6 |
conditionally |
| 7 |
Same goes for "eventspace" (e.g. spikespace) which depends on the type of |
| 8 |
event #} |
| 9 |
|
| 10 |
//// MAIN CODE //////////// |
| 11 |
// scalar code |
| 12 |
const int _vectorisation_idx = -1; |
| 13 |
{{scalar_code|autoindent}} |
| 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 |
long _count = 0; |
| 19 |
for(size_t _idx=0; _idx<N; _idx++) |
| 20 |
{ |
| 21 |
const size_t _vectorisation_idx = _idx; |
| 22 |
{{vector_code|autoindent}} |
| 23 |
if(_cond) { |
| 24 |
{{_eventspace}}[_count++] = _idx; |
| 25 |
{% if _uses_refractory %} |
| 26 |
{{not_refractory}}[_idx] = false; |
| 27 |
{{lastspike}}[_idx] = {{t}}; |
| 28 |
{% endif %} |
| 29 |
} |
| 30 |
} |
| 31 |
{{_eventspace}}[N] = _count; |
| 32 |
{% endblock %} |
| 33 |
|
| 34 |
{% block after_code %} |
| 35 |
{% set _eventspace = get_array_name(eventspace_variable) %} |
| 36 |
{{_eventspace}}[N] = 0; // Note that this is not an off-by-1-error: the array has N+1 elements |
| 37 |
{% endblock %} |