UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
ldgm
matrix-gen
rand_pmms.h
Go to the documentation of this file.
1
/*
2
* =====================================================================================
3
*
4
* Filename: rand_pmms.h
5
*
6
* Description:
7
*
8
* Version: 1.0
9
* Created: 05/31/2012 02:23:23 PM
10
* Revision: none
11
* Compiler: gcc
12
*
13
* Author: Milan Kabat (), kabat@ics.muni.cz
14
* Organization:
15
*
16
* =====================================================================================
17
*/
18
19
20
#include <cmath>
21
#include <assert.h>
22
23
class
Rand_pmms
24
{
25
public
:
26
Rand_pmms
() =
default
;
27
28
void
seedi
(
unsigned
long
int
s )
29
{
30
assert(s > 0ul && s < 0x7FFFFFFFul);
31
seed
= s;
32
val
= s;
33
}
34
35
unsigned
long
int
pmms_rand
(
unsigned
long
int
maxv )
36
{
37
unsigned
long
int
raw_value =
nextrand
();
38
39
return
(
unsigned
long
) ((double)maxv * (double)raw_value / (double)0x7FFFFFFF);
40
}
41
private
:
42
43
unsigned
long
int
nextrand
()
44
{
45
unsigned
long
long
int
const
a = 16807ull;
46
unsigned
long
long
int
const
m = 0x7FFFFFFFull;
47
48
val
= (a *
val
) % m;
49
50
return
val
;
51
}
52
53
unsigned
long
int
seed
;
54
unsigned
long
int
val
;
55
};
Rand_pmms
Definition
rand_pmms.h:24
Rand_pmms::val
unsigned long int val
Definition
rand_pmms.h:54
Rand_pmms::nextrand
unsigned long int nextrand()
Definition
rand_pmms.h:43
Rand_pmms::Rand_pmms
Rand_pmms()=default
Rand_pmms::seed
unsigned long int seed
Definition
rand_pmms.h:53
Rand_pmms::seedi
void seedi(unsigned long int s)
Definition
rand_pmms.h:28
Rand_pmms::pmms_rand
unsigned long int pmms_rand(unsigned long int maxv)
Definition
rand_pmms.h:35
Generated on Wed Sep 25 2024 14:27:13 for UltraGrid by
1.12.0