GNU Radio Manual and C++ API Reference  3.7.4.1
The Free & Open Software Radio Ecosystem
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
random.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2002 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
7  * GNU Radio is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3, or (at your option)
10  * any later version.
11  *
12  * GNU Radio is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with GNU Radio; see the file COPYING. If not, write to
19  * the Free Software Foundation, Inc., 51 Franklin Street,
20  * Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef INCLUDED_GR_RANDOM_H
24 #define INCLUDED_GR_RANDOM_H
25 
26 #include <gnuradio/api.h>
27 #include <gnuradio/gr_complex.h>
28 
29 // While rand(3) specifies RAND_MAX, random(3) says that the output
30 // ranges from 0 to 2^31-1 but does not specify a macro to denote
31 // this. We define RANDOM_MAX for cleanliness. We must omit the
32 // definition for systems that have made the same choice. (Note that
33 // random(3) is from 4.2BSD, and not specified by POSIX.)
34 
35 #ifndef RANDOM_MAX
36 static const int RANDOM_MAX = 2147483647; // 2^31-1
37 #endif /* RANDOM_MAX */
38 
39 #include <stdlib.h>
40 
41 namespace gr {
42 
43  /*!
44  * \brief pseudo random number generator
45  * \ingroup math_blk
46  */
48  {
49  protected:
50  static const int NTAB = 32;
51  long d_seed;
52  long d_iy;
53  long d_iv[NTAB];
54  int d_iset;
55  float d_gset;
56 
57  public:
58  random(long seed=3021);
59 
60  void reseed(long seed);
61 
62  /*!
63  * \brief uniform random deviate in the range [0.0, 1.0)
64  */
65  float ran1();
66 
67  /*!
68  * \brief normally distributed deviate with zero mean and variance 1
69  */
70  float gasdev();
71 
72  float laplacian();
73  float impulse(float factor);
74  float rayleigh();
75  gr_complex rayleigh_complex();
76  };
77 
78 } /* namespace gr */
79 
80 #endif /* INCLUDED_GR_RANDOM_H */
81 
static long int random(void)
Definition: gnuradio/volk/cmake/msvc/config.h:55
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
int d_iset
Definition: random.h:54
std::complex< float > gr_complex
Definition: gr_complex.h:27
float d_gset
Definition: random.h:55
long d_iy
Definition: random.h:52
long d_seed
Definition: random.h:51
static const int RANDOM_MAX
Definition: random.h:36
pseudo random number generator
Definition: random.h:47