Alexandria
2.18
Please provide a description of the project.
SOM
SOM
InitFunc.h
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
/*
20
* @file InitFunc.h
21
* @author nikoapos
22
*/
23
24
#ifndef SOM_INITFUNC_H
25
#define SOM_INITFUNC_H
26
27
#include <functional>
28
#include <random>
29
#include <vector>
30
31
namespace
Euclid
{
32
namespace
SOM {
33
34
namespace
InitFunc {
35
36
using
Signature
=
std::function
<double()>;
37
38
Signature
zero
= []() {
return
0; };
39
40
Signature
normalDistribution
(
double
sigma,
double
mu) {
41
std::random_device
rd;
42
std::mt19937
gen(rd());
43
std::normal_distribution<>
d(mu, sigma);
44
return
[gen, d]()
mutable
{
return
d(gen); };
45
}
46
47
Signature
uniformRandom
(
double
min,
double
max) {
48
std::uniform_real_distribution<double>
unif(min, max);
49
std::default_random_engine
re;
50
return
[unif, re]()
mutable
{
return
unif(re); };
51
}
52
53
}
// namespace InitFunc
54
55
}
// namespace SOM
56
}
// namespace Euclid
57
58
#endif
/* SOM_INITFUNC_H */
std::function
std::mt19937
Euclid::SOM::InitFunc::zero
Signature zero
Definition:
InitFunc.h:38
Euclid::SOM::InitFunc::normalDistribution
Signature normalDistribution(double sigma, double mu)
Definition:
InitFunc.h:40
Euclid::SOM::InitFunc::uniformRandom
Signature uniformRandom(double min, double max)
Definition:
InitFunc.h:47
Euclid
Definition:
InstOrRefHolder.h:29
std::normal_distribution
std::random_device
std::default_random_engine
std::uniform_real_distribution
Generated by
1.9.1