Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Public Member Functions | Friends | List of all members
auryn::SpikeDelay Class Reference

Delay object for spikes which is synchronized between nodes using the SyncBuffer formalism implemented in System. More...

#include <SpikeDelay.h>

Public Member Functions

 SpikeDelay (int delaysteps=MINDELAY)
 The default constructor. More...
 
virtual ~SpikeDelay ()
 The default destructor. More...
 
void set_delay (int delay)
 Set delay in number of timesteps. More...
 
int get_delay ()
 Get delay time in AurynTime. More...
 
void set_clock_ptr (AurynTime *clock)
 Internal function to set clock pointer. More...
 
void insert_spike (NeuronID i, AurynTime ahead)
 Allows to insert spikes so many time steps ahead with less than max delay. More...
 
void insert_spike_and_attrib (NeuronID i, AurynState attr, AurynTime ahead)
 Allows to insert spikes with a single attribute so many time steps ahead with less than max delay. More...
 
void push_back (NeuronID i)
 Allows to use SpikeDelay like a queue. More...
 
void push_back (NeuronID i, AurynState attr)
 Like push_back, but also allows to add an attribute. More...
 
void push_back (SpikeContainer *sc)
 Pushes all elemens from given SpikeContainer into the delay. More...
 
int get_num_attributes ()
 Returns the number of spike attributes per spike. More...
 
void inc_num_attributes (int x)
 Internally used by SyncBuffer to submit x attributes with spikes in this delay. More...
 
SpikeContainerget_spikes (unsigned int pos=1)
 Returns the spikes at a given delay position. More...
 
SpikeContainerget_spikes_immediate ()
 Returns the spikes stored into the delay within this very same time step. More...
 
AttributeContainerget_attributes (unsigned int pos=1)
 Like get_spikes but returns the spike attributes. More...
 
AttributeContainerget_attributes_immediate ()
 Like get_spikes_immediate but returns the spike attributes. More...
 
void print ()
 Print delay contents for debugging . More...
 
void clear ()
 

Friends

class boost::serialization::access
 

Detailed Description

Delay object for spikes which is synchronized between nodes using the SyncBuffer formalism implemented in System.

A simple list class to store spikes (numbers of type NeuronID). Memory allocation is only done when the container needs to grow. The class never shrinks thus optimizing performance but not memory efficiency.

Constructor & Destructor Documentation

◆ SpikeDelay()

SpikeDelay::SpikeDelay ( int  delaysteps = MINDELAY)

The default constructor.

33 {
34  numSpikeAttributes = 0;
35  delaybuf = NULL;
36  attribbuf = NULL;
37  ndelay = 0;
38  set_delay(delay);
39 }
void set_delay(int delay)
Set delay in number of timesteps.
Definition: SpikeDelay.cpp:41
Here is the call graph for this function:

◆ ~SpikeDelay()

SpikeDelay::~SpikeDelay ( )
virtual

The default destructor.

81 {
82  free();
83 }

Member Function Documentation

◆ clear()

void SpikeDelay::clear ( )

Clears all containers in delay.

73 {
74  for (unsigned int i = 0 ; i < ndelay ; ++i) {
75  delaybuf[i]->clear();
76  attribbuf[i]->clear();
77  }
78 }

◆ get_attributes()

AttributeContainer * SpikeDelay::get_attributes ( unsigned int  pos = 1)

Like get_spikes but returns the spike attributes.

96 {
97  return attribbuf[((*clock_ptr)+pos)%ndelay];
98 }

◆ get_attributes_immediate()

AttributeContainer * SpikeDelay::get_attributes_immediate ( )

Like get_spikes_immediate but returns the spike attributes.

101 {
102  return get_attributes(0);
103 }
AttributeContainer * get_attributes(unsigned int pos=1)
Like get_spikes but returns the spike attributes.
Definition: SpikeDelay.cpp:95
Here is the call graph for this function:

◆ get_delay()

int SpikeDelay::get_delay ( )

Get delay time in AurynTime.

58 {
59  return ndelay;
60 }

◆ get_num_attributes()

int SpikeDelay::get_num_attributes ( )

Returns the number of spike attributes per spike.

Spike attributes are used to implement short-term plasticity or similar mechanisms efficiently.

140 {
141  return numSpikeAttributes;
142 }

◆ get_spikes()

SpikeContainer * SpikeDelay::get_spikes ( unsigned int  pos = 1)

Returns the spikes at a given delay position.

pos == 1 corresponds to the maximum delay of the SpikeDelay and at least to MINDELAY+1. pos == 2 corresponds to the maximum delay -1, and so forth ...

86 {
87  return delaybuf[((*clock_ptr)+pos)%ndelay];
88 }

◆ get_spikes_immediate()

SpikeContainer * SpikeDelay::get_spikes_immediate ( )

Returns the spikes stored into the delay within this very same time step.

91 {
92  return get_spikes(0);
93 }
SpikeContainer * get_spikes(unsigned int pos=1)
Returns the spikes at a given delay position.
Definition: SpikeDelay.cpp:85
Here is the call graph for this function:

◆ inc_num_attributes()

void SpikeDelay::inc_num_attributes ( int  x)

Internally used by SyncBuffer to submit x attributes with spikes in this delay.

145 {
146  numSpikeAttributes += x;
147 }

◆ insert_spike()

void SpikeDelay::insert_spike ( NeuronID  i,
AurynTime  ahead 
)

Allows to insert spikes so many time steps ahead with less than max delay.

Parameters
iNeuron id of the spike
aheadTime steps in AurynTime in the future where to insert the spike in the delay
111 {
112  get_spikes(1+ahead+ndelay)->push_back(i);
113 }
SpikeContainer * get_spikes(unsigned int pos=1)
Returns the spikes at a given delay position.
Definition: SpikeDelay.cpp:85
Here is the call graph for this function:

◆ insert_spike_and_attrib()

void SpikeDelay::insert_spike_and_attrib ( NeuronID  i,
AurynState  attr,
AurynTime  ahead 
)

Allows to insert spikes with a single attribute so many time steps ahead with less than max delay.

Parameters
iNeuron id of the spike
attrThe spike attribute to insert
aheadTime steps in AurynTime in the future where to insert the spike in the delay
116 {
117  get_spikes(1+ahead+ndelay)->push_back(i);
118  get_attributes(1+ahead+ndelay)->push_back(s);
119 }
SpikeContainer * get_spikes(unsigned int pos=1)
Returns the spikes at a given delay position.
Definition: SpikeDelay.cpp:85
AttributeContainer * get_attributes(unsigned int pos=1)
Like get_spikes but returns the spike attributes.
Definition: SpikeDelay.cpp:95
Here is the call graph for this function:

◆ print()

void SpikeDelay::print ( )

Print delay contents for debugging .

151 {
152  for ( unsigned int i = 0 ; i < ndelay ; ++i ) {
153  SpikeContainer * spikes = get_spikes(i);
154  if ( spikes->size() ) {
155  std::cout << "slice " << i << ": ";
156  for ( NeuronID k = 0 ; k < spikes->size() ; ++k ) {
157  std::cout << spikes->at(k) << " ";
158  }
159  std::cout << std::endl;
160  }
161  }
162 }
std::vector< NeuronID > SpikeContainer
Spike container type. Used for storing spikes.
Definition: auryn_definitions.h:161
SpikeContainer * get_spikes(unsigned int pos=1)
Returns the spikes at a given delay position.
Definition: SpikeDelay.cpp:85
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ push_back() [1/3]

void SpikeDelay::push_back ( NeuronID  i)

Allows to use SpikeDelay like a queue.

This pushes into get_spikes_immediate()

122 {
123  get_spikes_immediate()->push_back(i);
124 }
SpikeContainer * get_spikes_immediate()
Returns the spikes stored into the delay within this very same time step.
Definition: SpikeDelay.cpp:90
Here is the call graph for this function:

◆ push_back() [2/3]

void SpikeDelay::push_back ( NeuronID  i,
AurynState  attr 
)

Like push_back, but also allows to add an attribute.

This pushes into get_spikes_immediate()

127 {
128  get_spikes_immediate()->push_back(i);
129  get_attributes_immediate()->push_back(attr);
130 }
SpikeContainer * get_spikes_immediate()
Returns the spikes stored into the delay within this very same time step.
Definition: SpikeDelay.cpp:90
AttributeContainer * get_attributes_immediate()
Like get_spikes_immediate but returns the spike attributes.
Definition: SpikeDelay.cpp:100
Here is the call graph for this function:

◆ push_back() [3/3]

void SpikeDelay::push_back ( SpikeContainer sc)

Pushes all elemens from given SpikeContainer into the delay.

This pushes into get_spikes_immediate()

133 {
134  for ( NeuronID i = 0 ; i < sc->size() ; ++i ) {
135  push_back(sc->at(i));
136  }
137 }
void push_back(NeuronID i)
Allows to use SpikeDelay like a queue.
Definition: SpikeDelay.cpp:121
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ set_clock_ptr()

void SpikeDelay::set_clock_ptr ( AurynTime clock)

Internal function to set clock pointer.

Sets internal clock pointer to system wide clock pointer. It is used by the System class

106 {
107  SpikeDelay::clock_ptr = clock;
108 }

◆ set_delay()

void SpikeDelay::set_delay ( int  delay)

Set delay in number of timesteps.

This allows to set the size of the delay in timesteps. The delay has to be at least of size MINDELAY.

42 {
43  if ( delay+1 == ndelay ) return; // we already have the right delay
44 
45  if ( delaybuf ) free(); // we have to free the old delay
46 
47  // and now create the new delay
48  ndelay = delay+1;
49  delaybuf = new SpikeContainer * [ndelay] ;
50  attribbuf = new AttributeContainer * [ndelay] ;
51  for (int i = 0 ; i < ndelay ; ++i) {
52  delaybuf[i] = new SpikeContainer( );
53  attribbuf[i] = new AttributeContainer( );
54  }
55 }
std::vector< NeuronID > SpikeContainer
Spike container type. Used for storing spikes.
Definition: auryn_definitions.h:161
std::vector< float > AttributeContainer
Attribute container type. Used for storing spike attributes that are needed for efficient STP impleme...
Definition: auryn_definitions.h:162

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

The documentation for this class was generated from the following files: