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 | Public Attributes | Private Attributes | List of all members
leansdr::wgn_c< T > Struct Template Reference

#include <dsp.h>

+ Inheritance diagram for leansdr::wgn_c< T >:
+ Collaboration diagram for leansdr::wgn_c< T >:

Public Member Functions

 wgn_c (scheduler *sch, pipebuf< complex< T >> &_out)
 
void run ()
 
- Public Member Functions inherited from leansdr::runnable
 runnable (scheduler *_sch, const char *name)
 
- Public Member Functions inherited from leansdr::runnable_common
 runnable_common (const char *_name)
 
virtual ~runnable_common ()
 
virtual void shutdown ()
 

Public Attributes

float stddev
 
- Public Attributes inherited from leansdr::runnable_common
const char * name
 

Private Attributes

pipewriter< complex< T > > out
 

Additional Inherited Members

- Protected Attributes inherited from leansdr::runnable
schedulersch
 

Detailed Description

template<typename T>
struct leansdr::wgn_c< T >

Definition at line 201 of file dsp.h.

Constructor & Destructor Documentation

◆ wgn_c()

template<typename T >
leansdr::wgn_c< T >::wgn_c ( scheduler sch,
pipebuf< complex< T >> &  _out 
)
inline

Definition at line 203 of file dsp.h.

204  : runnable(sch, "awgn"), stddev(1.0), out(_out)
205  {
206  }
pipewriter< complex< T > > out
Definition: dsp.h:231
float stddev
Definition: dsp.h:228
runnable(scheduler *_sch, const char *name)
Definition: framework.h:193
scheduler * sch
Definition: framework.h:199

Member Function Documentation

◆ run()

template<typename T >
void leansdr::wgn_c< T >::run ( )
inlinevirtual

Reimplemented from leansdr::runnable_common.

Definition at line 207 of file dsp.h.

References leansdr::complex< T >::im, leansdr::cconverter< Tin, Zin, Tout, Zout, Gn, Gd >::out, and leansdr::complex< T >::re.

208  {
209  int n = out.writable();
210  complex<T> *pout = out.wr(), *pend = pout + n;
211  while (pout < pend)
212  {
213  // TAOCP
214  float x, y, r2;
215  do
216  {
217  x = 2 * drand48() - 1;
218  y = 2 * drand48() - 1;
219  r2 = x * x + y * y;
220  } while (r2 == 0 || r2 >= 1);
221  float k = sqrtf(-logf(r2) / r2) * stddev;
222  pout->re = k * x;
223  pout->im = k * y;
224  ++pout;
225  }
226  out.written(n);
227  }
pipewriter< complex< T > > out
Definition: dsp.h:231
float stddev
Definition: dsp.h:228

Member Data Documentation

◆ out

template<typename T >
pipewriter<complex<T> > leansdr::wgn_c< T >::out
private

Definition at line 231 of file dsp.h.

◆ stddev

template<typename T >
float leansdr::wgn_c< T >::stddev

Definition at line 228 of file dsp.h.


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