Photon Engine
2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TMt19937.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Math/Random/TUniformRandomBitGenerator.h
"
4
5
#include <Common/primitive_type.h>
6
7
#include <random>
8
#include <type_traits>
9
10
namespace
ph::math
11
{
12
15
template
<
typename
Bits>
16
class
TMt19937
final :
public
TUniformRandomBitGenerator
<TMt19937<Bits>, Bits>
17
{
18
static_assert
(std::is_same_v<Bits, uint32> || std::is_same_v<Bits, uint64>,
19
"Supports only `uint32` and `uint64` bits types."
);
20
21
public
:
22
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS
(
TMt19937
);
23
24
explicit
TMt19937
(Bits seed);
25
26
Bits
impl_generate
();
27
void
impl_jumpAhead
(uint64 distance);
28
29
private
:
30
// There are 32 & 64 bit versions, select the one based on `BitsT`
31
using
StdGeneratorType = std::conditional_t<std::is_same_v<Bits, uint32>,
32
std::mt19937, std::mt19937_64>;
33
34
StdGeneratorType m_generator;
35
};
36
37
template
<
typename
Bits>
38
inline
TMt19937<Bits>::TMt19937
(
const
Bits seed)
39
: m_generator(seed)
40
{}
41
42
template
<
typename
Bits>
43
inline
Bits
TMt19937<Bits>::impl_generate
()
44
{
45
return
static_cast<
Bits
>
(m_generator());
46
}
47
48
template
<
typename
Bits>
49
inline
void
TMt19937<Bits>::impl_jumpAhead
(
const
uint64 distance)
50
{
51
m_generator.discard(distance);
52
}
53
54
}
// end namespace ph::math
TUniformRandomBitGenerator.h
ph::math::TMt19937
Standard Mersenne Twister generator.
Definition
TMt19937.h:17
ph::math::TMt19937::impl_jumpAhead
void impl_jumpAhead(uint64 distance)
Definition
TMt19937.h:49
ph::math::TMt19937::impl_generate
Bits impl_generate()
Definition
TMt19937.h:43
ph::math::TMt19937::PH_DEFINE_INLINE_RULE_OF_5_MEMBERS
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS(TMt19937)
ph::math::TMt19937::TMt19937
TMt19937(Bits seed)
Definition
TMt19937.h:38
ph::math::TUniformRandomBitGenerator
Definition
TUniformRandomBitGenerator.h:30
ph::math
Math functions and utilities.
Definition
TransformInfo.h:10
Source
Math
Random
TMt19937.h
Generated by
1.11.0