Alexandria
2.14.1
Please provide a description of the project.
SOM
SOM
InitFunc.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2012-2020 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 <vector>
28
#include <functional>
29
#include <random>
30
31
namespace
Euclid
{
32
namespace
SOM {
33
34
namespace
InitFunc {
35
36
using
Signature
=
std::function
<double()>;
37
38
Signature
zero
= [](){
39
return
0;
40
};
41
42
Signature
normalDistribution
(
double
sigma,
double
mu) {
43
std::random_device
rd;
44
std::mt19937
gen(rd());
45
std::normal_distribution<>
d(mu,sigma);
46
return
[gen, d]()
mutable
{
47
return
d(gen);
48
};
49
}
50
51
Signature
uniformRandom
(
double
min,
double
max) {
52
std::uniform_real_distribution<double>
unif(min, max);
53
std::default_random_engine
re;
54
return
[unif, re]()
mutable
{
55
return
unif(re);
56
};
57
}
58
59
}
60
61
}
62
}
63
64
#endif
/* SOM_INITFUNC_H */
65
Euclid::SOM::InitFunc::normalDistribution
Signature normalDistribution(double sigma, double mu)
Definition:
InitFunc.h:42
std::default_random_engine
std::function
std::uniform_real_distribution
std::mt19937
std::random_device
std::normal_distribution
Euclid::SOM::InitFunc::zero
Signature zero
Definition:
InitFunc.h:38
Euclid
Definition:
InstOrRefHolder.h:29
Euclid::SOM::InitFunc::uniformRandom
Signature uniformRandom(double min, double max)
Definition:
InitFunc.h:51
Generated by
1.8.17