|
sPyNNaker neural_modelling 7.4.2
|
maths-util.h - first created 7/10/2013 version 0.1 More...
Go to the source code of this file.
Macros | |
| #define | START 0 |
| just for my convenience with zero offset arrays | |
| #define | REAL_CONST(x) x##k |
| Define a constant of type REAL. | |
| #define | UREAL_CONST(x) x##uk |
| Define a constant of type UREAL. | |
| #define | FRACT_CONST(x) x##lr |
| Define a constant of type FRACT. | |
| #define | UFRACT_CONST(x) x##ulr |
| Define a constant of type UFRACT. | |
| #define | ONE REAL_CONST(1.0000) |
| A REAL 1.0. | |
| #define | HALF REAL_CONST(0.5000) |
| A REAL 0.5. | |
| #define | ZERO REAL_CONST(0.0000) |
| A REAL 0.0. | |
| #define | ACS_DBL_TINY REAL_CONST(0.000001) |
| A REAL "very small number" (0.000001) | |
| #define | SQRT(x) sqrtk(x) |
| This calculates the square-root of the argument. | |
| #define | SQRTU(x) sqrtuk(x) |
| This calculates the square-root of the argument. | |
| #define | EXP(x) expk(x) |
| This calculates the exponential (to base e) of the argument. | |
| #define | EXPU(x) expuk(x) |
| This calculates the exponential (to base e) of the argument. | |
| #define | ABS(x) absfx(x) |
| This calculates the absolute value of the argument. | |
| #define | SIGN(x, y) ((macro_arg_1=(y)) >= ZERO ? ABS(x) : -ABS(x)) |
| This calculates the value of an argument with the sign copied from another argument. | |
| #define | REAL_COMPARE(x, op, y) (bitsk((x)) op bitsk((y))) |
| Compare two REAL numbers. | |
| #define | REAL_TWICE(x) ((x) * 2.000000k) |
| Multiply by two. | |
| #define | REAL_HALF(x) ((x) * 0.500000k) |
| Divide by two. | |
| #define | MIN_HR(a, b) |
| Minimum of two values. | |
| #define | MAX_HR(a, b) |
| Maximum of two values. | |
| #define | SQR(a) |
| Square of a value. | |
| #define | CUBE(a) |
| Cube of a value. | |
Typedefs | |
| typedef unsigned int | Card |
| A Cardinal type. | |
| typedef accum | REAL |
| Type used for "real" numbers. | |
| typedef unsigned accum | UREAL |
| Type used for "unsigned real" numbers. | |
| typedef long fract | FRACT |
| Type used for "fractional" numbers. | |
| typedef unsigned long fract | UFRACT |
| Type used for "unsigned fractional" numbers. | |
Functions | |
| uint64_t | udiv64 (uint64_t, uint64_t) |
| static REAL | kdivk (REAL a, REAL b) |
| Divides an accum by another accum. | |
| static UREAL | ukdivuk (UREAL a, UREAL b) |
| Divides an unsigned accum by another unsigned accum. | |
| static int32_t | udivk (int32_t a, REAL b) |
| Divides an integer by an accum. | |
| static REAL | kdivui (REAL a, uint32_t b) |
| Divides an accum by an unsigned integer. | |
| static UREAL | pow_of_2 (REAL p) |
| Calculates 2^p where p is a real number (rather than just an integer). This is still quicker than general power operations. | |
Variables | |
| static const uint32_t | fract_powers_2 [] |
| static const uint32_t | fract_powers_half [] |
maths-util.h - first created 7/10/2013 version 0.1
some defines and other helper types/functions for applying ACS/HR types and ideas to SpiNNaker numerical coding
loose and transient toolbox of helper functions and macros until more structure present in maths libraries
this version 4-2-2014 is slightly cut down to allow source builds of neuron update code
Definition in file maths-util.h.
| #define START 0 |
just for my convenience with zero offset arrays
Definition at line 44 of file maths-util.h.
Define a constant of type REAL.
| x | The literal form of the number |
Definition at line 104 of file maths-util.h.
Define a constant of type UREAL.
| x | The literal form of the number |
Definition at line 108 of file maths-util.h.
Define a constant of type FRACT.
| x | The literal form of the number |
Definition at line 112 of file maths-util.h.
Define a constant of type UFRACT.
| x | The literal form of the number |
Definition at line 116 of file maths-util.h.
| #define ONE REAL_CONST(1.0000) |
A REAL 1.0.
Definition at line 119 of file maths-util.h.
| #define HALF REAL_CONST(0.5000) |
A REAL 0.5.
Definition at line 121 of file maths-util.h.
| #define ZERO REAL_CONST(0.0000) |
A REAL 0.0.
Definition at line 123 of file maths-util.h.
| #define ACS_DBL_TINY REAL_CONST(0.000001) |
A REAL "very small number" (0.000001)
Definition at line 125 of file maths-util.h.
This calculates the square-root of the argument.
| [in] | x | The REAL-valued argument |
Definition at line 130 of file maths-util.h.
This calculates the square-root of the argument.
| [in] | x | The UREAL-valued argument |
Definition at line 135 of file maths-util.h.
This calculates the exponential (to base e) of the argument.
| [in] | x | The REAL-valued argument |
Definition at line 140 of file maths-util.h.
This calculates the exponential (to base e) of the argument.
| [in] | x | The UREAL-valued argument |
Definition at line 145 of file maths-util.h.
This calculates the absolute value of the argument.
| [in] | x | The REAL-valued argument |
Definition at line 163 of file maths-util.h.
This calculates the value of an argument with the sign copied from another argument.
| [in] | x | The REAL value to take the absolute value from |
| [in] | y | The REAL value to take the sign from. |
Definition at line 174 of file maths-util.h.
Compare two REAL numbers.
| [in] | x | The first REAL value to compare |
| op | The comparison operator (e.g., >=) | |
| [in] | y | The second REAL value to compare |
Definition at line 192 of file maths-util.h.
Multiply by two.
| [in] | x | The REAL argument |
Definition at line 197 of file maths-util.h.
Divide by two.
| [in] | x | The REAL argument |
Definition at line 202 of file maths-util.h.
| #define MIN_HR | ( | a, | |
| b | |||
| ) |
Minimum of two values.
Definition at line 207 of file maths-util.h.
| #define MAX_HR | ( | a, | |
| b | |||
| ) |
Maximum of two values.
Definition at line 213 of file maths-util.h.
| #define SQR | ( | a | ) |
Square of a value.
Definition at line 219 of file maths-util.h.
| #define CUBE | ( | a | ) |
Cube of a value.
Definition at line 224 of file maths-util.h.
| typedef unsigned int Card |
A Cardinal type.
Definition at line 41 of file maths-util.h.
| typedef accum REAL |
Type used for "real" numbers.
Definition at line 91 of file maths-util.h.
| typedef unsigned accum UREAL |
Type used for "unsigned real" numbers.
Definition at line 94 of file maths-util.h.
| typedef long fract FRACT |
Type used for "fractional" numbers.
Definition at line 97 of file maths-util.h.
| typedef unsigned long fract UFRACT |
Type used for "unsigned fractional" numbers.
Definition at line 100 of file maths-util.h.
|
extern |
Definition at line 27 of file c_main_neuron_common.h.
Divides an accum by another accum.
| [in] | a | The dividend |
| [in] | b | The divisor |
Definition at line 234 of file maths-util.h.
Divides an unsigned accum by another unsigned accum.
| [in] | a | The dividend |
| [in] | b | The divisor |
Definition at line 242 of file maths-util.h.
|
inlinestatic |
Divides an integer by an accum.
| [in] | a | The dividend |
| [in] | b | The divisor |
Definition at line 250 of file maths-util.h.
Divides an accum by an unsigned integer.
| [in] | a | The dividend |
| [in] | b | The divisor |
Definition at line 258 of file maths-util.h.
Calculates 2^p where p is a real number (rather than just an integer). This is still quicker than general power operations.
| [in] | p | The power to raise 2 to; if p >= 16 or <= -16 the result will be saturated to MAX_U_REAL or 0 respectively. |
Definition at line 283 of file maths-util.h.
|
static |
2^(1/(2^n)) for values of n between 1 and 15, in U1616 format, then converted to uint32_t for computation. These can be used to work out fractional powers of 2 by multiplication.
Definition at line 265 of file maths-util.h.
|
static |
2^-(1/2^n)) for values of n between 1 and 15, in U1616 format, then converted to uint32_t for computation. These can be used to work out negative fractional power of 2 by multiplication.
Definition at line 274 of file maths-util.h.