Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Variables
_
a
b
c
f
g
i
k
m
n
o
p
r
s
w
Typedefs
a
b
c
d
e
f
g
h
i
l
m
o
p
q
t
v
Enumerations
Enumerator
d
h
m
n
r
s
t
Concepts
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
~
Variables
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
i
j
k
l
m
o
p
q
r
s
t
u
v
Enumerations
Enumerator
a
i
l
n
o
p
s
u
v
Related Symbols
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
v
w
Variables
a
b
c
g
h
i
m
p
s
t
u
v
w
Typedefs
Enumerations
Enumerator
Macros
c
d
f
g
h
i
k
m
n
o
p
q
r
s
t
u
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
Concepts
Loading...
Searching...
No Matches
uniform.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018-2022 The ESPResSo project
3
*
4
* ESPResSo is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* ESPResSo is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef UTILS_UNIFORM_HPP
19
#define UTILS_UNIFORM_HPP
20
21
#include <cinttypes>
22
#include <limits>
23
24
namespace
Utils
{
25
/**
26
* @brief Uniformly map unsigned integer to double.
27
*
28
* This maps a unsigned integer to the double interval
29
* (0., 1.], where 0 is mapped to the smallest representable
30
* value larger than 0., and the maximal integer value is
31
* mapped to 1.
32
*
33
* @param in Unsigned integer value
34
* @return Mapped floating point value.
35
*/
36
constexpr
inline
double
uniform
(uint64_t in) {
37
auto
constexpr
const
max = std::numeric_limits<uint64_t>::max();
38
auto
constexpr
const
fac = 1. / (
static_cast<
double
>
(max) + 1.);
39
40
return
fac *
static_cast<
double
>
(in) + 0.5 * fac;
41
}
36
constexpr
inline
double
uniform
(uint64_t in) {
…
}
42
43
}
// namespace Utils
44
45
#endif
// ESPRESSO_UNIFORM_HPP
Utils
Definition
Variant.hpp:40
Utils::uniform
constexpr double uniform(uint64_t in)
Uniformly map unsigned integer to double.
Definition
uniform.hpp:36
src
utils
include
utils
uniform.hpp
Generated on Mon Apr 21 2025 01:14:21 for ESPResSo by
1.9.8