NeoPZ
Random
TPZUniformRandom.h
Go to the documentation of this file.
1
/*
2
* File: TPZUniformRandom.h
3
* Author: quinelato
4
*
5
* Created on 5 de Dezembro de 2017, 13:31
6
*/
7
8
#ifndef TPZUNIFORMRANDOM_H
9
#define TPZUNIFORMRANDOM_H
10
11
#include <random>
12
#include <functional>
13
#include <ctime>
14
15
#include "
TPZConstrainedRandom.h
"
16
17
template
<
typename
TVar>
18
class
TPZUniformRandom
:
public
TPZConstrainedRandom
<TVar> {
19
public
:
20
TPZUniformRandom
(TVar begin, TVar end) :
TPZConstrainedRandom
<TVar>(begin, end),
generator
(
std
::bind(
std
::uniform_real_distribution<TVar>(begin, end),
std
::default_random_engine(clock()))) {
21
}
22
TPZUniformRandom
(
const
TPZUniformRandom<TVar>
& orig):
TPZConstrainedRandom
<TVar>(orig),
generator
(orig.
generator
){
23
24
}
25
26
virtual
TPZRandom<TVar>
*
clone
(){
27
return
new
TPZUniformRandom<TVar>
(*this);
28
}
29
30
TVar
next
(){
31
return
generator
();
32
}
33
34
TVar
pdf
(TVar x);
35
36
virtual
~TPZUniformRandom
(){
37
38
}
39
protected
:
40
std::function<TVar()>
generator
;
41
};
42
43
template
<
typename
TVar>
44
TVar
TPZUniformRandom<TVar>::pdf
(TVar x) {
45
return
1./(this->
fend
- this->
fbegin
);
46
}
47
48
#endif
/* TPZUNIFORMRANDOM_H */
49
TPZRandom
Definition:
TPZRandom.h:14
TPZUniformRandom::pdf
TVar pdf(TVar x)
Definition:
TPZUniformRandom.h:44
TPZUniformRandom::TPZUniformRandom
TPZUniformRandom(TVar begin, TVar end)
Definition:
TPZUniformRandom.h:20
std
TPZUniformRandom::generator
std::function< TVar()> generator
Definition:
TPZUniformRandom.h:40
TPZConstrainedRandom
Definition:
TPZConstrainedRandom.h:14
TPZUniformRandom::next
TVar next()
Definition:
TPZUniformRandom.h:30
TPZConstrainedRandom::fbegin
TVar fbegin
Definition:
TPZConstrainedRandom.h:33
TPZUniformRandom::clone
virtual TPZRandom< TVar > * clone()
Definition:
TPZUniformRandom.h:26
TPZConstrainedRandom.h
TPZUniformRandom::TPZUniformRandom
TPZUniformRandom(const TPZUniformRandom< TVar > &orig)
Definition:
TPZUniformRandom.h:22
TPZUniformRandom::~TPZUniformRandom
virtual ~TPZUniformRandom()
Definition:
TPZUniformRandom.h:36
TPZUniformRandom
Definition:
TPZUniformRandom.h:18
TPZConstrainedRandom::fend
TVar fend
Definition:
TPZConstrainedRandom.h:33
Generated on Sun Aug 16 2020 11:17:09 for NeoPZ by
1.8.13