GSLCPPCodeGenerator class

(Shortest import: from brian2.codegen.generators import GSLCPPCodeGenerator)

class brian2.codegen.generators.GSL_generator.GSLCPPCodeGenerator(variables, variable_indices, owner, iterate_all, codeobj_class, name, template_name, override_conditional_write=None, allows_scalar_write=False)[source]

Bases: brian2.codegen.generators.GSL_generator.GSLCodeGenerator

Methods

c_data_type(dtype)

Get string version of object dtype that is attached to Brian variables.

initialize_array(varname, values)

Initialize a static array with given floating point values.

unpack_namespace_single(var_obj, in_vector, …)

Writes the code necessary to pull single variable out of the Brian namespace into the generated code.

var_init_lhs(var, type)

Get string version of the left hand side of an initializing expression

var_replace_diff_var_lhs(var, ind)

Details

c_data_type(dtype)[source]

Get string version of object dtype that is attached to Brian variables. c pp_generator already has this function, but the Cython generator does not, but we need it for GSL code generation.

initialize_array(varname, values)[source]

Initialize a static array with given floating point values. E.g. in C++, when called with arguments array and [1.0, 3.0, 2.0], this method should return double array[] = {1.0, 3.0, 2.0}.

Parameters

varname : str

The name of the array variable that should be initialized

values : list of float

The values that should be assigned to the array

Returns

code : str

One or more lines of array initialization code.

unpack_namespace_single(var_obj, in_vector, in_scalar)[source]

Writes the code necessary to pull single variable out of the Brian namespace into the generated code.

The code created is significantly different between cpp and cython, so I decided to not make this function general over all target languages (i.e. in contrast to most other functions that only have syntactical differences)

var_init_lhs(var, type)[source]

Get string version of the left hand side of an initializing expression

Parameters

var : str

type : str

Returns

code : str

For cpp returns type + var, while for cython just var

var_replace_diff_var_lhs(var, ind)[source]