forked from devray/mbICA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpolicies.h
62 lines (54 loc) · 1.54 KB
/
policies.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* @file
* @author Pawel Zubrycki <[email protected]>
* @author Stanisław Janikowski <[email protected]>
*
* @section DESCRIPTION
*
* File with policies that can be applied to FastICA template.
**/
#ifndef POLICIES_H
#define POLICIES_H
#include <armadillo>
namespace mbica {
/**
* Empty class that doesn't provide stabilization.
**/
class NoStabilization {
public:
NoStabilization(double, double, int) {}
void operator()(int, const arma::mat &, const arma::mat &) {}
};
/**
* Class that provides stabilization.
**/
class WithStabilization {
public:
/**
* Constructor
*
* @param epsilon Reference to epsilon stored in FastICA class.
* @param mu Reference to current mu value from FastICA::operator() method.
* @param maxIterations Reference to value stored in FastICA class.
**/
WithStabilization(double &epsilon, double &mu, int &maxIterations)
: epsilon_(epsilon), mu_(mu), stroke_(0.0), maxIterations_(maxIterations), reducedStep_(false), inStroke_(false) {}
/**
* Method that stabilize calcualtions.
*
* @param iteration Current iteration number in main loop of algorithm.
* @param B Current estimation.
* @param B_old Previous estimation.
**/
void operator()(int iteration, const arma::mat &B, const arma::mat &B_old);
private:
arma::mat BOlder_;
double &epsilon_;
double &mu_;
double stroke_;
int maxIterations_;
bool reducedStep_;
bool inStroke_;
};
}
#endif // POLICIES_H