sPyNNaker neural_modelling 7.1.1
Loading...
Searching...
No Matches
param_generator_exponential.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
21#include <stdfix.h>
22#include <spin1_api.h>
23#include <stdfix-full-iso.h>
24#include <random.h>
27
34
42
50 // Allocate memory for the data
52 spin1_malloc(sizeof(struct param_generator_exponential));
53
54 // Copy the parameters in
56 params->params = *params_sdram;
57 *region = &params_sdram[1];
58 log_debug("exponential beta = %k", params->params.beta);
59
60 return params;
61}
62
67static void param_generator_exponential_free(void *generator) {
68 sark_free(generator);
69}
70
76static accum param_generator_exponential_generate(void *generator) {
77 // generate an exponentially distributed value
78 struct param_generator_exponential *params = generator;
79 return rng_exponential(core_rng) * params->params.beta;
80}
void log_debug(const char *message,...)
General types associated with generators.
rng_t * core_rng
An RNG that is local to the current core.
static accum param_generator_exponential_generate(void *generator)
How to generate values with the exponential RNG parameter generator.
static void param_generator_exponential_free(void *generator)
How to free any data for the exponential RNG parameter generator.
static void * param_generator_exponential_initialize(void **region)
How to initialise the exponential RNG parameter generator.
The data structure to be passed around for this generator. This includes the parameters and an RNG.
The parameters that can be copied in from SDRAM.
accum rng_exponential(rng_t *rng)
Generate an exponentially-distributed random number.
Definition rng.c:30
Random number generator interface.
void sark_free(void *ptr)
region
spike source array region IDs in human readable form
static stdp_params params
Configuration parameters.