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
FixedAverage2D< T > Class Template Reference

#include <fixedaverage2d.h>

Public Member Functions

 FixedAverage2D ()
 
 ~FixedAverage2D ()
 
void resize (unsigned int width, unsigned int size)
 
bool storeAndGetAvg (T &avg, T v, unsigned int index)
 
bool storeAndGetSum (T &sum, T v, unsigned int index)
 
bool nextAverage ()
 

Private Attributes

T * m_sum
 
unsigned int m_maxSize
 
unsigned int m_width
 
unsigned int m_size
 
unsigned int m_maxIndex
 

Detailed Description

template<typename T>
class FixedAverage2D< T >

Definition at line 25 of file fixedaverage2d.h.

Constructor & Destructor Documentation

◆ FixedAverage2D()

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

Definition at line 28 of file fixedaverage2d.h.

28 : m_sum(0), m_maxSize(0), m_width(0), m_size(0), m_maxIndex(0) {}
unsigned int m_maxSize
unsigned int m_width
unsigned int m_maxIndex
unsigned int m_size

◆ ~FixedAverage2D()

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

Definition at line 30 of file fixedaverage2d.h.

31  {
32  if (m_sum) {
33  delete[] m_sum;
34  }
35  }

Member Function Documentation

◆ nextAverage()

template<typename T>
bool FixedAverage2D< T >::nextAverage ( )
inline

Definition at line 97 of file fixedaverage2d.h.

Referenced by SpectrumVis::feed().

98  {
99  if (m_size <= 1) {
100  return true;
101  }
102 
103  if (m_maxIndex == m_size - 1)
104  {
105  m_maxIndex = 0;
106  std::fill(m_sum, m_sum+m_width, 0);
107  return true;
108  }
109  else
110  {
111  m_maxIndex++;
112  return false;
113  }
114  }
unsigned int m_width
unsigned int m_maxIndex
unsigned int m_size
+ Here is the caller graph for this function:

◆ resize()

template<typename T>
void FixedAverage2D< T >::resize ( unsigned int  width,
unsigned int  size 
)
inline

Definition at line 37 of file fixedaverage2d.h.

Referenced by SpectrumVis::handleConfigure().

38  {
39  if (width > m_maxSize)
40  {
41  m_maxSize = width;
42  if (m_sum) {
43  delete[] m_sum;
44  }
45  m_sum = new T[m_maxSize];
46  }
47 
48  m_width = width;
49  m_size = size;
50 
51  std::fill(m_sum, m_sum+m_width, 0);
52  m_maxIndex = 0;
53  }
unsigned int m_maxSize
unsigned int m_width
unsigned int m_maxIndex
unsigned int m_size
+ Here is the caller graph for this function:

◆ storeAndGetAvg()

template<typename T>
bool FixedAverage2D< T >::storeAndGetAvg ( T &  avg,
v,
unsigned int  index 
)
inline

Definition at line 55 of file fixedaverage2d.h.

Referenced by SpectrumVis::feed().

56  {
57  if (m_size <= 1)
58  {
59  avg = v;
60  return true;
61  }
62 
63  m_sum[index] += v;
64 
65  if (m_maxIndex == m_size - 1)
66  {
67  avg = m_sum[index]/m_size;
68  return true;
69  }
70  else
71  {
72  return false;
73  }
74  }
unsigned int m_maxIndex
unsigned int m_size
+ Here is the caller graph for this function:

◆ storeAndGetSum()

template<typename T>
bool FixedAverage2D< T >::storeAndGetSum ( T &  sum,
v,
unsigned int  index 
)
inline

Definition at line 76 of file fixedaverage2d.h.

77  {
78  if (m_size <= 1)
79  {
80  sum = v;
81  return true;
82  }
83 
84  m_sum[index] += v;
85 
86  if (m_maxIndex < m_size - 1)
87  {
88  sum = m_sum[index];
89  return true;
90  }
91  else
92  {
93  return false;
94  }
95  }
unsigned int m_maxIndex
unsigned int m_size

Member Data Documentation

◆ m_maxIndex

template<typename T>
unsigned int FixedAverage2D< T >::m_maxIndex
private

◆ m_maxSize

template<typename T>
unsigned int FixedAverage2D< T >::m_maxSize
private

Definition at line 118 of file fixedaverage2d.h.

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

◆ m_size

template<typename T>
unsigned int FixedAverage2D< T >::m_size
private

◆ m_sum

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

◆ m_width

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

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