fun_ofdm  1.0
802.11a Physical Layer for USRP
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
fun::circular_accumulator< T > Struct Template Reference

The circular_accumulator template. More...

#include <circular_accumulator.h>

Public Member Functions

 circular_accumulator (int _size)
 Constructor for circular_accumulator. More...
 
void add (T sample)
 Adds a sample to the accumulator. More...
 

Public Attributes

sum
 The sum of the current samples in the samples vector. More...
 
std::vector< T > samples
 The vector containing the past size samples of type T. More...
 
int index
 The current index where the newest sample will be inserted on the next call to add(). More...
 
int size
 The max number of samples the accumulator holds at any give time. More...
 

Detailed Description

template<typename T>
struct fun::circular_accumulator< T >

The circular_accumulator template.

This class is a template class for the circular accumulator which is used to keep a running sum of the past size samples

Definition at line 25 of file circular_accumulator.h.

Constructor & Destructor Documentation

template<typename T>
fun::circular_accumulator< T >::circular_accumulator ( int  _size)
inline

Constructor for circular_accumulator.

Parameters
_sizeThe max number of samples that the accumulator can hold at any given time.

Initializes the samples vector to contain size elements and sets each element to 0 along with the initial sum.

Definition at line 69 of file circular_accumulator.h.

70  {
71  size = _size;
72  samples.resize(size);
73  index = 0;
74  for(int x = 0; x < size; x++) samples[x] = T(0);
75  sum = T(0);
76  }

Member Function Documentation

template<typename T>
void fun::circular_accumulator< T >::add ( sample)
inline

Adds a sample to the accumulator.

Parameters
sampleThe sample to add to the accumulator

If the accumulator is full the oldest sample in the accumulator is overwritten by the new sample and the current value of sum is updated accordingly.

Definition at line 88 of file circular_accumulator.h.

Referenced by fun::frame_detector::work().

89  {
90  if(sample != sample) sample = 0;
91  sum -= samples[index];
92  sum += sample;
93  samples[index++] = sample;
94  if(index >= size) index = 0;
95  }

Member Data Documentation

template<typename T>
int fun::circular_accumulator< T >::index

The current index where the newest sample will be inserted on the next call to add().

This variable is essentially private as the user should not interface with it directly.

Definition at line 51 of file circular_accumulator.h.

Referenced by fun::circular_accumulator< std::complex< double > >::add(), and fun::circular_accumulator< std::complex< double > >::circular_accumulator().

template<typename T>
std::vector<T> fun::circular_accumulator< T >::samples

The vector containing the past size samples of type T.

This member is essentially private as the user should not interface with it directly.

Definition at line 42 of file circular_accumulator.h.

Referenced by fun::circular_accumulator< std::complex< double > >::add(), and fun::circular_accumulator< std::complex< double > >::circular_accumulator().

template<typename T>
int fun::circular_accumulator< T >::size

The max number of samples the accumulator holds at any give time.

This variable is essentially private as the user should not interface with it directly.

Definition at line 59 of file circular_accumulator.h.

Referenced by fun::circular_accumulator< std::complex< double > >::add(), and fun::circular_accumulator< std::complex< double > >::circular_accumulator().

template<typename T>
T fun::circular_accumulator< T >::sum

The sum of the current samples in the samples vector.

This is the key variable from this class that the user should be interested in. In other words, it is essentially the only public variable.

Definition at line 34 of file circular_accumulator.h.

Referenced by fun::circular_accumulator< std::complex< double > >::add(), fun::circular_accumulator< std::complex< double > >::circular_accumulator(), and fun::frame_detector::work().


The documentation for this struct was generated from the following file: