File: group_get_indices.pyx

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (25 lines) | stat: -rw-r--r-- 599 bytes parent folder | download | duplicates (4)
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
{# USES_VARIABLES { N, _indices } #}
{% extends 'common_group.pyx' %}

{% block maincode %}

    _vectorisation_idx = 1

    cdef size_t _num_elements = 0
    cdef _numpy.ndarray[int, ndim=1, mode='c'] _elements = _numpy.zeros(N, dtype=_numpy.int32)
    cdef int[:] _elements_view = _elements
    
    {{scalar_code|autoindent}}

    for _idx in range(N):
        _vectorisation_idx = _idx
        
        {{vector_code|autoindent}}
        
        if _cond:
            _elements_view[_num_elements] = _idx
            _num_elements += 1
    
    return _elements[:_num_elements]

{% endblock %}