SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Public Member Functions | Private Attributes | List of all members
MovingAverage2D< T > Class Template Reference

#include <movingaverage2d.h>

Public Member Functions

 MovingAverage2D ()
 
 ~MovingAverage2D ()
 
void resize (unsigned int width, unsigned int depth)
 
storeAndGetAvg (T v, unsigned int index)
 
storeAndGetSum (T v, unsigned int index)
 
void nextAverage ()
 

Private Attributes

T * m_data
 
T * m_sum
 
unsigned int m_dataSize
 
unsigned int m_sumSize
 
unsigned int m_width
 
unsigned int m_depth
 
unsigned int m_avgIndex
 

Detailed Description

template<typename T>
class MovingAverage2D< T >

Definition at line 25 of file movingaverage2d.h.

Constructor & Destructor Documentation

◆ MovingAverage2D()

template<typename T>
MovingAverage2D< T >::MovingAverage2D ( )
inline

Definition at line 28 of file movingaverage2d.h.

28 : m_data(0), m_sum(0), m_dataSize(0), m_sumSize(0), m_width(0), m_depth(0), m_avgIndex(0) {}
unsigned int m_sumSize
unsigned int m_width
unsigned int m_dataSize
unsigned int m_avgIndex
unsigned int m_depth

◆ ~MovingAverage2D()

template<typename T>
MovingAverage2D< T >::~MovingAverage2D ( )
inline

Definition at line 30 of file movingaverage2d.h.

31  {
32  if (m_data) {
33  delete[] m_data;
34  }
35 
36  if (m_sum) {
37  delete[] m_sum;
38  }
39  }

Member Function Documentation

◆ nextAverage()

template<typename T>
void MovingAverage2D< T >::nextAverage ( )
inline

Definition at line 108 of file movingaverage2d.h.

Referenced by SpectrumVis::feed().

108  {
109  m_avgIndex = m_avgIndex == m_depth-1 ? 0 : m_avgIndex+1;
110  }
unsigned int m_avgIndex
unsigned int m_depth
+ Here is the caller graph for this function:

◆ resize()

template<typename T>
void MovingAverage2D< T >::resize ( unsigned int  width,
unsigned int  depth 
)
inline

Definition at line 41 of file movingaverage2d.h.

Referenced by SpectrumVis::handleConfigure().

42  {
43  if (width*depth > m_dataSize)
44  {
45  m_dataSize = width*depth;
46  if (m_data) {
47  delete[] m_data;
48  }
49  m_data = new T[m_dataSize];
50  }
51 
52  if (width > m_sumSize)
53  {
54  m_sumSize = width;
55  if (m_sum) {
56  delete[] m_sum;
57  }
58  m_sum = new T[m_sumSize];
59  }
60 
61  m_width = width;
62  m_depth = depth;
63 
64  std::fill(m_data, m_data+(m_width*m_depth), 0.0);
65  std::fill(m_sum, m_sum+m_width, 0.0);
66 
67  m_avgIndex = 0;
68  }
unsigned int m_sumSize
unsigned int m_width
unsigned int m_dataSize
unsigned int m_avgIndex
unsigned int m_depth
+ Here is the caller graph for this function:

◆ storeAndGetAvg()

template<typename T>
T MovingAverage2D< T >::storeAndGetAvg ( v,
unsigned int  index 
)
inline

Definition at line 70 of file movingaverage2d.h.

Referenced by SpectrumVis::feed().

71  {
72  if (m_depth <= 1)
73  {
74  return v;
75  }
76  else if (index < m_width)
77  {
78  T first = m_data[m_avgIndex*m_width+index];
79  m_sum[index] += (v - first);
80  m_data[m_avgIndex*m_width+index] = v;
81  return m_sum[index] / m_depth;
82  }
83  else
84  {
85  return 0;
86  }
87  }
unsigned int m_width
unsigned int m_avgIndex
unsigned int m_depth
+ Here is the caller graph for this function:

◆ storeAndGetSum()

template<typename T>
T MovingAverage2D< T >::storeAndGetSum ( v,
unsigned int  index 
)
inline

Definition at line 89 of file movingaverage2d.h.

90  {
91  if (m_depth == 1)
92  {
93  return v;
94  }
95  else if (index < m_width)
96  {
97  T first = m_data[m_avgIndex*m_width+index];
98  m_sum[index] += (v - first);
99  m_data[m_avgIndex*m_width+index] = v;
100  return m_sum[index];
101  }
102  else
103  {
104  return 0;
105  }
106  }
unsigned int m_width
unsigned int m_avgIndex
unsigned int m_depth

Member Data Documentation

◆ m_avgIndex

template<typename T>
unsigned int MovingAverage2D< T >::m_avgIndex
private

◆ m_data

template<typename T>
T* MovingAverage2D< T >::m_data
private

◆ m_dataSize

template<typename T>
unsigned int MovingAverage2D< T >::m_dataSize
private

Definition at line 115 of file movingaverage2d.h.

Referenced by MovingAverage2D< double >::resize().

◆ m_depth

template<typename T>
unsigned int MovingAverage2D< T >::m_depth
private

◆ m_sum

template<typename T>
T* MovingAverage2D< T >::m_sum
private

◆ m_sumSize

template<typename T>
unsigned int MovingAverage2D< T >::m_sumSize
private

Definition at line 116 of file movingaverage2d.h.

Referenced by MovingAverage2D< double >::resize().

◆ m_width

template<typename T>
unsigned int MovingAverage2D< T >::m_width
private

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