Auryn simulator
v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
|
Default Auryn vector template. More...
#include <auryn_definitions.h>
Public Member Functions | |
AurynVector (IndexType n) | |
Default constructor. More... | |
AurynVector (AurynVector *vec) | |
Copy constructor. More... | |
virtual | ~AurynVector () |
Default destructor. More... | |
virtual void | resize (IndexType new_size) |
resize data array to new_size More... | |
void | copy (AurynVector *v) |
Copies vector v. More... | |
T | get (IndexType i) |
Gets element i from vector. More... | |
T * | ptr (IndexType i=0) |
Gets pointer to element i from vector. More... | |
void | set (IndexType i, T value) |
Sets element i in vector to value. More... | |
void | set_all (const T v) |
Set all elements to value v. More... | |
void | set_zero () |
Set all elements to zero. More... | |
void | scale (const T a) |
Scales all vector elements by a. More... | |
void | add (const T c) |
Adds constant c to each vector element. More... | |
void | add_specific (const IndexType i, const T c) |
Adds the value c to specific vector element i. More... | |
void | mul_specific (const IndexType i, const T c) |
Multiply to specific vector element with data index i with the constant c. More... | |
void | add (AurynVector *v) |
Adds a vector v to the vector. More... | |
void | sub (const T c) |
Subtract constant c to each vector element. More... | |
void | sub (AurynVector *v) |
Elementwise subtraction. More... | |
void | mul (const T a) |
Multiply all vector elements by constant. More... | |
void | mul (AurynVector *v) |
Element-wise vector multiply. More... | |
void | div (const T a) |
Element-wise division. More... | |
void | div (AurynVector *v) |
Element-wise vector division. More... | |
void | div (AurynVector *a, AurynVector *b) |
Element-wise vector division which stores the result in this. More... | |
void | saxpy (const T a, AurynVector *x) |
SAXPY operation as in GSL. More... | |
void | follow (AurynVector< T, IndexType > *v, const T rate) |
Follows target vector v with rate. More... | |
void | follow_scalar (const T a, const T rate) |
Like follow but with a scalar target value a. More... | |
void | elementwise_max (AurynVector *v1, AurynVector *v2) |
Elementwise max operation. More... | |
void | elementwise_max (AurynVector *v1) |
Elementwise max operation with another vector. More... | |
void | pow (const unsigned int n) |
Takes each element to the n-th power. More... | |
void | fast_exp () |
Computes an approximation of exp(x) for each vector element. More... | |
void | exp () |
Computes exp(x) for each vector element. More... | |
void | sigmoid (AurynVector *x, const T beta, const T thr) |
Computes sigmoid(beta*(x-thr)) for each vector element and stores result in this instance. More... | |
void | sqrt () |
Takes the square root of each element. More... | |
void | neg () |
Flips the sign of all elements. More... | |
void | inv () |
Computes 1./x of each element. More... | |
void | sum (AurynVector *a, AurynVector *b) |
Computes the sum a+b and stores the result in this instance. More... | |
void | sum (AurynVector *a, const T b) |
Computes the sum a+b and stores the result in this instance. More... | |
void | diff (AurynVector *a, AurynVector *b) |
Computes the difference a-b and stores the result in this instance. More... | |
void | diff (AurynVector *a, const T b) |
Computes the difference a-b and stores the result in this instance. More... | |
void | diff (const T a, AurynVector *b) |
Computes the difference a-b and stores the result in this instance. More... | |
void | sqr () |
Squares each element. More... | |
void | abs () |
Takes absolute value of each element. More... | |
void | rect () |
Rectifies all elements. More... | |
void | neg_rect () |
Negatively rectifies all elements. More... | |
void | clip (T min, T max) |
Clips all vector elements to the range min max. More... | |
double | var () |
Computes the variance of the vector elements on this rank. More... | |
double | std () |
Computes the standard deviation of all elements on this rank. More... | |
double | mean () |
Computes the mean of the vector elements on this rank. More... | |
double | element_sum () |
Computes the sum of the vector elements. More... | |
double | l1norm () |
Computes the l1 norm of the vector. More... | |
double | l2norm () |
Computes the l2 norm of the vector. More... | |
double | max () |
Returns the max of the vector elements. More... | |
double | min () |
Returns the min of the vector elements. More... | |
IndexType | nonzero () |
Computes number of nonzero elements on this rank. More... | |
void | zero_effective_zeros (const T epsilon=1e-3) |
Sets all values whose absolute value is smaller than epsilon to zero. More... | |
void | add_random_normal (AurynState mean=0.0, AurynState sigma=1.0, unsigned int seed=8721) |
void | set_random_normal (AurynState mean=0.0, AurynState sigma=1.0, unsigned int seed=8721) |
void | set_random (unsigned int seed=0) |
Initializes vector elements with Gaussian of unit varince and a seed derived from system time if no seed or seed of 0 is given. More... | |
bool | any () |
Returns true if any element is nonzero. More... | |
bool | any (T eps) |
Returns true if any element is nonzero. More... | |
void | print () |
Print vector elements to stdout for debugging. More... | |
void | write_to_file (std::string filename) |
Print vector elements to a text file for debugging. More... | |
Public Attributes | |
IndexType | size |
Size of the vector. More... | |
T * | data |
Pointer to the array housing the data. More... | |
Protected Member Functions | |
void | check_size (IndexType x) |
Checks if argument is larger than size and throws and exception if so. More... | |
void | check_size (AurynVector *v) |
Checks if vector size matches to this instance. More... | |
void | allocate (const NeuronID n) |
Implements aligned memory allocation. More... | |
void | freebuf () |
T | fast_exp256 (T x) |
Computes approximation of exp(x) via fast series approximation up to n=256. More... | |
Friends | |
class | boost::serialization::access |
Default Auryn vector template.
This class implements the base vector class for Auryn. Neuronal or synaptic state variables are stored as AurynVectors. For performance reasons, time critical functions of this template have to be reimplemented in derived classes with a specific template parameter T. For instance I will always provide a derived type AurynVectorFloat (T=float) which per default is synonymous to AurynStateVector which implements SSE instructions for labour intensive operations on the vectors. When using the AurynStateVector in NeuronGroups etc this will speed up computation performance automatically. Note, that all Auryn vectors should initialized with multiple of 4 elements (later that number might change) when we add AVX support to the code. This is done automatically
|
inline |
Default constructor.
|
inline |
Copy constructor.
Constructs vector as a copy of argument vector.
|
inlinevirtual |
Default destructor.
|
inline |
Takes absolute value of each element.
|
inline |
Adds constant c to each vector element.
|
inline |
Adds a vector v to the vector.
No checking of the dimensions match!
|
inline |
|
inline |
Adds the value c to specific vector element i.
|
inlineprotected |
Implements aligned memory allocation.
|
inline |
Returns true if any element is nonzero.
|
inline |
Returns true if any element is nonzero.
|
inlineprotected |
Checks if argument is larger than size and throws and exception if so.
Check only enabled if NDEBUG is not defined.
|
inlineprotected |
Checks if vector size matches to this instance.
Check only enabled if NDEBUG is not defined.
|
inline |
Clips all vector elements to the range min max.
min | Minimum value |
max | Maximum value |
|
inline |
Copies vector v.
|
inline |
Computes the difference a-b and stores the result in this instance.
|
inline |
Computes the difference a-b and stores the result in this instance.
|
inline |
Computes the difference a-b and stores the result in this instance.
|
inline |
Element-wise division.
|
inline |
Element-wise vector division.
|
inline |
Element-wise vector division which stores the result in this.
Computes elemntwise a/b and stores the result in current instance.
|
inline |
Computes the sum of the vector elements.
|
inline |
Elementwise max operation.
|
inline |
Elementwise max operation with another vector.
|
inline |
Computes exp(x) for each vector element.
|
inline |
Computes an approximation of exp(x) for each vector element.
|
inlineprotected |
|
inline |
Follows target vector v with rate.
Example to implement the ODE: tau dx/dt = -(x-v)
the rate parameter should be set to auryn_timestep/tau.
|
inline |
Like follow but with a scalar target value a.
|
inlineprotected |
|
inline |
Gets element i from vector.
|
inline |
Computes 1./x of each element.
|
inline |
Computes the l1 norm of the vector.
|
inline |
Computes the l2 norm of the vector.
|
inline |
Returns the max of the vector elements.
|
inline |
Computes the mean of the vector elements on this rank.
Warning: Note that AurynVector can only compute the mean of all the subset of elements stored on rank it runs on.
|
inline |
Returns the min of the vector elements.
|
inline |
Multiply all vector elements by constant.
|
inline |
Element-wise vector multiply.
|
inline |
Multiply to specific vector element with data index i with the constant c.
|
inline |
Flips the sign of all elements.
|
inline |
Negatively rectifies all elements.
|
inline |
Computes number of nonzero elements on this rank.
Warning: Note that AurynVector can only compute the mean of all the subset of elements stored on rank it runs on.
|
inline |
Takes each element to the n-th power.
n | the exponent |
|
inline |
Print vector elements to stdout for debugging.
|
inline |
Gets pointer to element i from vector.
When no argument is given the function returns the first element of data array of the vector.
|
inline |
Rectifies all elements.
|
inlinevirtual |
resize data array to new_size
The function tries to preserve data while resizing. If a vector is downsized elements at the end are simply dropped. When the vector size is increased the new elements at the end are intialized with zeros.
Reimplemented in auryn::AurynVectorFloat, and auryn::AurynDelayVector.
|
inline |
SAXPY operation as in GSL.
Computes a*x + y and stores the result to y where y is the present instance.
a | The scaling factor for the additional vector |
x | The additional vector to add |
|
inline |
Scales all vector elements by a.
|
inline |
Sets element i in vector to value.
|
inline |
Set all elements to value v.
|
inline |
Initializes vector elements with Gaussian of unit varince and a seed derived from system time if no seed or seed of 0 is given.
|
inline |
|
inline |
Set all elements to zero.
|
inline |
Computes sigmoid(beta*(x-thr)) for each vector element and stores result in this instance.
|
inline |
Squares each element.
|
inline |
Takes the square root of each element.
|
inline |
Computes the standard deviation of all elements on this rank.
Warning: Note that AurynVector can only compute the mean of all the subset of elements stored on rank it runs on.
|
inline |
Subtract constant c to each vector element.
|
inline |
Elementwise subtraction.
|
inline |
Computes the sum a+b and stores the result in this instance.
|
inline |
Computes the sum a+b and stores the result in this instance.
|
inline |
Computes the variance of the vector elements on this rank.
Uses Bessel's correction to calculate an unbiased estimate of the population variance which requires n > 1 otherwise the output is not defined.
Warning: Note that AurynVector can only compute the mean of all the subset of elements stored on rank it runs on.
|
inline |
Print vector elements to a text file for debugging.
|
inline |
Sets all values whose absolute value is smaller than epsilon to zero.
|
friend |
T* auryn::AurynVector< T, IndexType >::data |
Pointer to the array housing the data.
IndexType auryn::AurynVector< T, IndexType >::size |
Size of the vector.