Alexandria
2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
SOM
src
lib
InitFunc.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2012-2021 Euclid Science Ground Segment
3
*
4
* This library is free software; you can redistribute it and/or modify it under
5
* the terms of the GNU Lesser General Public License as published by the Free
6
* Software Foundation; either version 3.0 of the License, or (at your option)
7
* any later version.
8
*
9
* This library is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12
* details.
13
*
14
* You should have received a copy of the GNU Lesser General Public License
15
* along with this library; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
*/
18
19
#include "
SOM/InitFunc.h
"
20
#include <random>
21
22
namespace
Euclid
{
23
namespace
SOM {
24
namespace
InitFunc {
25
26
double
zeroImpl
(
void
) {
27
return
0;
28
}
29
30
Signature
zero
=
zeroImpl
;
31
32
Signature
normalDistribution
(
double
sigma,
double
mu) {
33
std::random_device
rd;
34
std::mt19937
gen(rd());
35
std::normal_distribution<>
d(mu, sigma);
36
return
[gen, d]()
mutable
{
return
d(gen); };
37
}
38
39
Signature
uniformRandom
(
double
min,
double
max) {
40
std::uniform_real_distribution<double>
unif(min, max);
41
std::default_random_engine
re;
42
return
[unif, re]()
mutable
{
return
unif(re); };
43
}
44
45
}
// namespace InitFunc
46
}
// namespace SOM
47
}
// namespace Euclid
InitFunc.h
std::function
std::mt19937
Euclid::SOM::InitFunc::zero
Signature zero
Definition
InitFunc.cpp:30
Euclid::SOM::InitFunc::zeroImpl
double zeroImpl(void)
Definition
InitFunc.cpp:26
Euclid::SOM::InitFunc::normalDistribution
ELEMENTS_API Signature normalDistribution(double sigma, double mu)
Definition
InitFunc.cpp:32
Euclid::SOM::InitFunc::uniformRandom
ELEMENTS_API Signature uniformRandom(double min, double max)
Definition
InitFunc.cpp:39
Euclid
Definition
index_sequence.h:27
std::normal_distribution
std::random_device
std::default_random_engine
std::uniform_real_distribution
Generated by
1.9.8