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.
qrtplib
rtprandomrand48.cpp
Go to the documentation of this file.
1
/*
2
3
This file is a part of JRTPLIB
4
Copyright (c) 1999-2017 Jori Liesenborgs
5
6
Contact: jori.liesenborgs@gmail.com
7
8
This library was developed at the Expertise Centre for Digital Media
9
(http://www.edm.uhasselt.be), a research center of the Hasselt University
10
(http://www.uhasselt.be). The library is based upon work done for
11
my thesis at the School for Knowledge Technology (Belgium/The Netherlands).
12
13
Permission is hereby granted, free of charge, to any person obtaining a
14
copy of this software and associated documentation files (the "Software"),
15
to deal in the Software without restriction, including without limitation
16
the rights to use, copy, modify, merge, publish, distribute, sublicense,
17
and/or sell copies of the Software, and to permit persons to whom the
18
Software is furnished to do so, subject to the following conditions:
19
20
The above copyright notice and this permission notice shall be included
21
in all copies or substantial portions of the Software.
22
23
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
29
IN THE SOFTWARE.
30
31
*/
32
33
#include "
rtprandomrand48.h
"
34
#include <Qt>
35
36
namespace
qrtplib
37
{
38
39
RTPRandomRand48::RTPRandomRand48
()
40
{
41
SetSeed
(
PickSeed
());
42
}
43
44
RTPRandomRand48::RTPRandomRand48
(
uint32_t
seed)
45
{
46
SetSeed
(seed);
47
}
48
49
RTPRandomRand48::~RTPRandomRand48
()
50
{
51
}
52
53
void
RTPRandomRand48::SetSeed
(
uint32_t
seed)
54
{
55
state
= ((
uint64_t
) seed) << 16 | 0x330EULL;
56
}
57
58
uint8_t
RTPRandomRand48::GetRandom8
()
59
{
60
uint32_t
x = ((
GetRandom32
() >> 24) & 0xff);
61
62
return
(
uint8_t
) x;
63
}
64
65
uint16_t
RTPRandomRand48::GetRandom16
()
66
{
67
uint32_t
x = ((
GetRandom32
() >> 16) & 0xffff);
68
69
return
(
uint16_t
) x;
70
}
71
72
uint32_t
RTPRandomRand48::GetRandom32
()
73
{
74
state
= ((0x5DEECE66DULL *
state
) + 0xBULL) & 0x0000ffffffffffffULL;
75
uint32_t
x = (
uint32_t
) ((
state
>> 16) & 0xffffffffULL);
76
qDebug(
"RTPRandomRand48::GetRandom32: %u"
, x);
77
78
return
x;
79
}
80
81
double
RTPRandomRand48::GetRandomDouble
()
82
{
83
84
state
= ((0x5DEECE66DULL *
state
) + 0xBULL) & 0x0000ffffffffffffULL;
85
int64_t
x = (
int64_t
)
state
;
86
87
double
y = 3.552713678800500929355621337890625e-15 * (double) x;
88
return
y;
89
}
90
91
}
// end namespace
92
qrtplib::RTPRandomRand48::SetSeed
void SetSeed(uint32_t seed)
Definition:
rtprandomrand48.cpp:53
qrtplib::RTPRandomRand48::GetRandom16
uint16_t GetRandom16()
Definition:
rtprandomrand48.cpp:65
qrtplib::RTPRandomRand48::~RTPRandomRand48
~RTPRandomRand48()
Definition:
rtprandomrand48.cpp:49
qrtplib::RTPRandomRand48::state
uint64_t state
Definition:
rtprandomrand48.h:65
int64_t
__int64 int64_t
Definition:
rtptypes_win.h:47
uint32_t
unsigned int uint32_t
Definition:
rtptypes_win.h:46
uint8_t
unsigned char uint8_t
Definition:
rtptypes_win.h:42
uint16_t
unsigned short uint16_t
Definition:
rtptypes_win.h:44
qrtplib::RTPRandomRand48::GetRandom8
uint8_t GetRandom8()
Definition:
rtprandomrand48.cpp:58
rtprandomrand48.h
qrtplib
Definition:
rtcpapppacket.cpp:35
qrtplib::RTPRandomRand48::RTPRandomRand48
RTPRandomRand48()
Definition:
rtprandomrand48.cpp:39
qrtplib::RTPRandomRand48::GetRandom32
uint32_t GetRandom32()
Definition:
rtprandomrand48.cpp:72
qrtplib::RTPRandomRand48::GetRandomDouble
double GetRandomDouble()
Definition:
rtprandomrand48.cpp:81
qrtplib::RTPRandom::PickSeed
uint32_t PickSeed()
Definition:
rtprandom.cpp:54
uint64_t
unsigned __int64 uint64_t
Definition:
rtptypes_win.h:48
Generated on Fri Aug 2 2019 17:56:32 for SDRAngel by
1.8.13