1 : |
agomez |
1 |
#include "selectfunc.h" |
2 : |
|
|
#include "gadget.h" |
3 : |
|
|
|
4 : |
|
|
// ********************************************************
|
5 : |
|
|
// Functions for base selection function
|
6 : |
|
|
// ********************************************************
|
7 : |
|
|
void SelectFunc::readConstants(CommentStream& infile,
|
8 : |
|
|
const TimeClass* const TimeInfo, Keeper* const keeper) {
|
9 : |
|
|
|
10 : |
|
|
coeff.read(infile, TimeInfo, keeper);
|
11 : |
|
|
coeff.Update(TimeInfo);
|
12 : |
|
|
}
|
13 : |
|
|
|
14 : |
|
|
void SelectFunc::updateConstants(const TimeClass* const TimeInfo) {
|
15 : |
|
|
coeff.Update(TimeInfo);
|
16 : |
|
|
}
|
17 : |
|
|
|
18 : |
|
|
int SelectFunc::didChange(const TimeClass* const TimeInfo) {
|
19 : |
|
|
return coeff.didChange(TimeInfo);
|
20 : |
|
|
}
|
21 : |
|
|
|
22 : |
|
|
// ********************************************************
|
23 : |
|
|
// Functions for ConstSelectFunc selection function
|
24 : |
|
|
// ********************************************************
|
25 : |
|
|
ConstSelectFunc::ConstSelectFunc() : SelectFunc("ConstantSelectFunc") {
|
26 : |
|
|
coeff.setsize(1);
|
27 : |
|
|
}
|
28 : |
|
|
|
29 : |
|
|
double ConstSelectFunc::calculate(double len) {
|
30 : |
|
|
return coeff[0];
|
31 : |
|
|
}
|
32 : |
|
|
|
33 : |
|
|
// ********************************************************
|
34 : |
|
|
// Functions for ExpSelectFunc selection function
|
35 : |
|
|
// ********************************************************
|
36 : |
|
|
ExpSelectFunc::ExpSelectFunc() : SelectFunc("ExponentialSelectFunc") {
|
37 : |
|
|
coeff.setsize(2);
|
38 : |
|
|
}
|
39 : |
|
|
|
40 : |
|
|
double ExpSelectFunc::calculate(double len) {
|
41 : |
|
|
return (1.0 / (1.0 + exp(coeff[0] * (len - coeff[1]))));
|
42 : |
|
|
}
|
43 : |
|
|
|
44 : |
|
|
// ********************************************************
|
45 : |
|
|
// Functions for StraightSelectFunc selection function
|
46 : |
|
|
// ********************************************************
|
47 : |
|
|
StraightSelectFunc::StraightSelectFunc() : SelectFunc("StraightLineSelectFunc") {
|
48 : |
|
|
coeff.setsize(2);
|
49 : |
|
|
}
|
50 : |
|
|
|
51 : |
|
|
double StraightSelectFunc::calculate(double len) {
|
52 : |
|
|
return (coeff[0] * len + coeff[1]);
|
53 : |
|
|
}
|