Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Simox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Leander Singer
Simox
Commits
4f7d69f7
Commit
4f7d69f7
authored
6 years ago
by
Raphael Grimm
Browse files
Options
Downloads
Patches
Plain Diff
Add missing files
parent
e24ec0f8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
VirtualRobot/Random.cpp
+12
-0
12 additions, 0 deletions
VirtualRobot/Random.cpp
VirtualRobot/Random.h
+45
-0
45 additions, 0 deletions
VirtualRobot/Random.h
with
57 additions
and
0 deletions
VirtualRobot/Random.cpp
0 → 100644
+
12
−
0
View file @
4f7d69f7
#include
"Random.h"
namespace
VirtualRobot
{
std
::
mt19937_64
&
PRNG64Bit
()
{
static
thread_local
std
::
mt19937_64
gen
{
std
::
random_device
{}()};
return
gen
;
}
}
// namespace
This diff is collapsed.
Click to expand it.
VirtualRobot/Random.h
0 → 100644
+
45
−
0
View file @
4f7d69f7
/**
* This file is part of Simox.
*
* Simox is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Simox is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package VirtualRobot
* @author Raphael Grimm
* @copyright 2018 Nikolaus Vahrenkamp
* GNU Lesser General Public License
*
*/
#pragma once
#include
<random>
namespace
VirtualRobot
{
std
::
mt19937_64
&
PRNG64Bit
();
inline
typename
std
::
mt19937_64
::
result_type
RandomNumber
()
{
return
PRNG64Bit
()();
}
inline
float
RandomFloat
()
{
static
thread_local
std
::
uniform_real_distribution
<
float
>
d
{
0.
f
,
std
::
nextafter
(
1.
f
,
2.
f
)};
return
d
(
PRNG64Bit
());
}
inline
float
RandomFloat
(
float
min
,
float
max
)
{
return
std
::
uniform_real_distribution
<
float
>
{
min
,
max
}(
PRNG64Bit
());
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment