-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.cpp
60 lines (53 loc) · 1.2 KB
/
model.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
/*
* Fengji Hou
* New York University
* Feb 22, 2013
*
*/
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#include "int2str.h"
#include "model.h"
using namespace std;
// Constructor:
// the dimension of the model's paramter space
Model::Model(size_t dimension):dim(dimension){
time_label = int2str(static_cast<long>(time(NULL)));
beta.push_back(0.);
chain_evi.push_back(0.);
}
Model::Model(void) {
time_label = int2str(static_cast<long>(time(NULL)));
beta.push_back(0.);
chain_evi.push_back(0.);
}
void Model::displayMeanCov(void) {
cout << "Mean:" << endl << endl;
for (size_t i = 0; i < m.size(); ++i) {
cout << setprecision(16) << m[i] << endl;
}
cout << endl;
cout << "Cov:" << endl << endl;
for (size_t i = 0; i < C.size(); ++i) {
for (size_t j = 0; j < C[0].size(); ++j) {
cout << setprecision(16) << C[i][j] << " ";
}
cout << endl;
}
cout << endl;
}
void Model::displayHessian(void) {
cout << "Hessian:" << endl << endl;
for (size_t i = 0; i < C.size(); ++i) {
for (size_t j = 0; j < C[0].size(); ++j) {
cout << setprecision(16) << H[i][j] << " ";
}
cout << endl;
}
cout << endl;
}