-
Notifications
You must be signed in to change notification settings - Fork 2
/
filler.h
48 lines (36 loc) · 903 Bytes
/
filler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include <algorithm>
#include "util.h"
namespace con {
class Filler {
public:
Filler() {}
virtual void fill(Vec *a) = 0;
};
class GaussianFiller : public Filler {
public:
GaussianFiller(const Real &mean, const Real &std): Filler(), mean(mean), std(std) {}
void fill(Vec *a) {
gaussianRng(mean, std, a);
}
const Real mean;
const Real std;
};
class UniformFiller : public Filler {
public:
UniformFiller(const Real &min, const Real &max): Filler(), min(min), max(max) {}
void fill(Vec *a) {
randomizeVec(min, max, a);
}
const Real min;
const Real max;
};
class ConstantFiller: public Filler {
public:
ConstantFiller(const Real &c): Filler(), c(c) {}
void fill(Vec *a) {
std::fill(a->begin(), a->end(), c);
}
const Real c;
};
}