Debian Codegraph @

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

raw
1 {# USES_VARIABLES { t, _clock_t, _indices, N } #}
2 {% extends 'common_group.pyx' %}
3
4 {% block maincode %}
5
6 cdef size_t _new_len = {{N}} + 1
7
8 # Resize the recorded times
9 {{_dynamic_t_ptr}}.resize(_new_len)
10 cdef double* _t_data = {{_dynamic_t_ptr}}.get_data_ptr()
11 _t_data[_new_len-1] = {{_clock_t}}
12
13 # scalar code
14 _vectorisation_idx = 1
15 {{ scalar_code|autoindent }}
16
17 cdef size_t _i
18
19 {% for varname, var in _recorded_variables | dictsort %}
20 {% set c_type = cpp_dtype(variables[varname].dtype) %}
21 {% set array_name = get_array_name(var, access_data=False) %}
22
23 # Resize the recorded variable "{{varname}}" and get the (potentially
24 # changed) reference to the underlying data
25 {{array_name}}_ptr.resize(_new_len, _num{{_indices}})
26 cdef {{c_type}}* _record_data_{{varname}} = <{{c_type}}*> {{get_array_name(var, access_data=False) + "_ptr"}}.get_data_ptr()
27 for _i in range(_num{{_indices}}):
28 # vector code
29 _idx = {{_indices}}[_i]
30 _vectorisation_idx = _idx
31
32 {{ vector_code | autoindent }}
33
34 _record_data_{{varname}}[(_new_len-1)*_num{{_indices}} + _i] = _to_record_{{varname}}
35 {% endfor %}
36
37 # set the N variable explicitly (since we do not call `StateMonitor.resize`)
38 {{N}} = _new_len
39
40 {% endblock %}