Class SpikeArray

Class Documentation

class SpikeArray

An array of Spike. SpikeArray objects must be sorted in time before being used for inference.

Public Types

using const_iterator = EvSpikeSim::vector<Spike>::const_iterator

Type definition of const iterator of Spike objects

Public Functions

SpikeArray()

Constructs an empty array of spikes.

SpikeArray(const std::vector<unsigned int> &indices, const std::vector<float> &times)

Constructs an array of spikes with the given spike indices and spike timings.

Parameters
  • indices – Indices of spikes.

  • times – Timings of spikes.

template<class IndexIterator, class TimeIterator>
inline SpikeArray(IndexIterator begin_indices, IndexIterator end_indices, TimeIterator begin_times)

Constructs an array of spikes with the given spike index and spike timing iterators (number of indices and timings must match).

Template Parameters
  • IndexIterator – Type of index iterator.

  • TimeIterator – Type of time iterator.

Parameters
  • begin_indices – First spike index.

  • end_indices – Last spike index.

  • begin_times – First spike timing.

void add(unsigned int index, float time)

Adds a single spike to the array.

Parameters
  • index – Index of the neuron.

  • time – Timing of the spike.

void add(const std::vector<unsigned int> &indices, const std::vector<float> &times)

Adds several spikes to the array given indices and timings.

Parameters
  • indices – Neuron indices that fired the spikes.

  • times – Timings of the spikes.

template<class IndexIterator, class TimeIterator>
inline void add(IndexIterator begin_indices, IndexIterator end_indices, TimeIterator begin_times)

Adds spikes with the given spike index and spike timing iterators (number of indices and timings must match).

Template Parameters
  • IndexIterator – Type of index iterator.

  • TimeIterator – Type of time iterator.

Parameters
  • begin_indices – First spike index.

  • end_indices – Last spike index.

  • begin_times – First spike timing.

void sort()

Sorts the spike array in time. Must be called before being used for inference.

void clear()

Empty the spike array.

const_iterator begin() const

Gets a constant iterator on the first spike.

Returns

A constant iterator on the first spike.

const_iterator end() const

Gets a constant iterator on the end of the spike array.

Returns

A constant iterator on the end of the spike array.

std::size_t n_spikes() const

Gets the number of spikes in the array.

Returns

The size of the array.

bool is_sorted() const

Checks if the spike array is sorted in time.

Returns

True if the array is sorted in time.

bool is_empty() const

Checks if the spike array is empty.

Returns

True if the array is empty.

const Spike *get_c_ptr() const

Gets the raw pointer of the spike array.

Returns

The raw pointer of the spike array.

bool operator==(const SpikeArray &rhs) const

Checks the equality betweentwo spike arrays.

Parameters

rhs – The other spike array to compare.

Returns

True if the two arrays have the same number of spikes and if all the spikes are equals.

bool operator!=(const SpikeArray &rhs) const

Checks the equality between two spike arrays.

Parameters

rhs – The other spike array to compare.

Returns

True if the two arrays do not have the same number of spikes or if at least one spike is not equal to the corresponding one in rhs.

Friends

friend std::ostream &operator<<(std::ostream &os, const EvSpikeSim::SpikeArray &array)

Formats the spike array to the given output stream.

Parameters
  • os – The output stream to write.

  • array – The array of spikes to format.

Returns

The output stream os.