-
Notifications
You must be signed in to change notification settings - Fork 0
/
Constant.cpp
executable file
·78 lines (63 loc) · 1.42 KB
/
Constant.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "Constant.h"
#include <math.h>
namespace model {
// Constructor and destructor
Constant::Constant(double inD) {
d[0] = inD;
d[1] = inD * inD;
}
Constant::~Constant() {
}
// Get statistics functions
double Constant::getEX() {
return d[0];
}
double Constant::getELnX() {
return log(d[0]);
}
double Constant::getEX2() {
return d[1];
}
double* Constant::getMoments() {
return d;
}
// Set statistics function
void Constant::setVal(double newValue) {
d[0] = newValue;
d[1] = newValue * newValue;
}
// Functions inherited from Node
void Constant::IO(string description, istream& file, bool loadPriors,
bool debug) {
int stringSize = 100;
string input(stringSize, '\0');
char * pos;
// Get the description line and ignore it
file.getline(&input[0], stringSize - 1);
if (debug) {
cerr << "Read: " << input << " and ignored\n";
}
// Get the value line and use its value
input.assign(stringSize, '\0');
file.getline(&input[0], stringSize - 1);
pos = &input[0];
if (loadPriors) {
setVal(strtod(pos, &pos));
}
// Output debug info if appropriate.
if (debug) {
cerr << "Read: " << input << "\n and value is " << getEX() << "\n";
}
}
void Constant::IO(string description, ostream& file, bool loadPriors,
bool debug) {
file << description << "\n";
file << getEX() << "\n";
}
double Constant::getBound() {
return 0.0;
}
void Constant::update(int index1, int index2, int index3, double message[]) {
return;
}
}