178 void *generator, uint32_t pre_lo, uint32_t pre_hi,
179 uint32_t post_lo, uint32_t post_hi, UNUSED uint32_t post_index,
180 uint32_t post_slice_start, uint32_t post_slice_count,
181 unsigned long accum weight_scale, accum timestep_per_delay,
182 param_generator_t weight_generator, param_generator_t delay_generator,
186 uint32_t n_pre = pre_hi - pre_lo + 1;
187 uint32_t n_post = post_hi - post_lo + 1;
188 uint32_t post_slice_end = post_slice_start + post_slice_count;
189 uint32_t n_conns = obj->params.n_synapses_total;
192 if (obj->params.with_replacement) {
193 for (uint32_t i = 0; i < n_conns; i++) {
194 uint32_t post = random_in_range(
population_rng, n_post) + post_lo;
195 if (post >= post_slice_start && post < post_slice_end) {
196 uint32_t local_post = post - post_slice_start;
202 bool written =
false;
203 uint32_t n_retries = 0;
205 pre = random_in_range(
core_rng, n_pre) + pre_lo;
206 if (obj->params.allow_self_connections || pre != post) {
208 pre, local_post, weight, delay, weight_scale);
211 }
while (!written && n_retries < 10);
213 log_error(
"Couldn't find a row to write to!");
219 uint32_t pre = pre_lo;
220 uint32_t post = post_lo;
226 for (i = 0; i < n_conns; i++) {
228 conns[i].post = post;
229 fixed_total_next(&pre, &post, pre_lo, pre_hi);
230 if (!obj->params.allow_self_connections && (pre == post)) {
231 fixed_total_next(&pre, &post, pre_lo, pre_hi);
234 while (pre <= pre_hi && post <= post_hi) {
238 conns[r].post = post;
240 fixed_total_next(&pre, &post, pre_lo, pre_hi);
241 if (!obj->params.allow_self_connections && (pre == post)) {
242 fixed_total_next(&pre, &post, pre_lo, pre_hi);
246 for (uint32_t i = 0; i < n_conns; i++) {
247 uint32_t local_post = conns[i].post;
248 if (local_post >= post_slice_start && local_post < post_slice_end) {
249 local_post -= post_slice_start;
250 uint32_t local_pre = conns[i].pre;
255 weight, delay, weight_scale)) {
static bool connection_generator_fixed_total_generate(void *generator, uint32_t pre_lo, uint32_t pre_hi, uint32_t post_lo, uint32_t post_hi, uint32_t post_index, uint32_t post_slice_start, uint32_t post_slice_count, unsigned long accum weight_scale, accum timestep_per_delay, param_generator_t weight_generator, param_generator_t delay_generator, matrix_generator_t matrix_generator)
Generate connections with the fixed-total connection generator.
bool matrix_generator_write_synapse(matrix_generator_t generator, uint32_t pre_index, uint16_t post_index, accum weight, uint16_t delay, unsigned long accum weight_scale)
Write a synapse with a matrix generator.