-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheigvalsp1q3_L3.cpp
146 lines (107 loc) · 3.64 KB
/
eigvalsp1q3_L3.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <armadillo>
#include "geometry.hpp"
#include "utils.hpp"
#include "params.hpp"
#include "statistics.hpp"
using namespace std;
using namespace arma;
int main(int argc, char** argv)
{
// Check arguments
if(argc < 4)
{
cerr << "Need to pass:" << endl;
cerr << "1) Name of the folder containing the data" << endl;
cerr << "2) First index of the jobs array" << endl;
cerr << "3) Number of jobs in the array" << endl;
return 1;
}
// Some declarations for later
string prefix = "GEOM";
string path = argv[1];
int fst_jarr = stoi(argv[2]);
int num_jarr = stoi(argv[3]);
//********* BEGIN PARAMETER INITIALIZATION **********//
// Read simulation parameters from file path/init.txt
string init_filename = path + "/init.txt";
struct Simul_params sm;
ifstream in_init;
in_init.open(init_filename);
if(!read_init_stream(in_init, sm))
{
cerr << "Error: couldn't read file " + init_filename << endl;
return 1;
}
cout << "File " + init_filename + " contains the following parameters:" << endl;
cout << sm.control << endl;
if(!params_validity(sm))
{
cerr << "Error: file " + init_filename + " does not contain the necessary parameters." << endl;
return 1;
}
in_init.close();
//********* END PARAMETER INITIALIZATION **********//
//********* BEGIN ANALYSIS **********//
// Cycle on g2 values
double g2 = sm.g2_i;
while(g2 < sm.g2_f)
{
// Print value of g2 being precessed
clog << "g2: " << g2 << endl;
// Cycle on jobs in the array
for(int i=0; i<num_jarr; ++i)
{
string array_path = path + "/" + to_string(i+fst_jarr);
Geom24 temp(sm.p, sm.q, 1, 1);
// Compute number of measurements
int length = n_meas(sm.iter_simul, sm.gap);
// eigenvalues matrix
mat M(sm.dim, length);
// Open output files
string out_filename = array_path + "/" + filename_from_data(sm.p, sm.q, sm.dim, g2, "L3") + ".txt";
ofstream out_obs;
out_obs.open(out_filename);
if(!out_obs)
{
cerr << "Error: file " + out_filename + " could not be opened." << endl;
return 1;
}
// Open data files
string filename = filename_from_data(sm.p, sm.q, sm.dim, g2, prefix);
ifstream in_s, in_hl;
in_s.open(array_path + "/" + filename + "_S.txt");
in_hl.open(array_path + "/" + filename + "_HL.txt");
// Cycle on measurements
for(int j=0; j<length; ++j)
{
Geom24 G(sm.p, sm.q, sm.dim, g2);
double S2, S4;
in_s >> S2 >> S4;
G.read_mat(in_hl);
// ***** COMPUTE OBSERVABLE HERE *****
vec eigval = eig_sym(G.get_mat(4));
for(int l=0; l<G.get_dim(); ++l)
{
M(l,j) = eigval(l);
}
}
in_s.close();
in_hl.close();
for(uword a=0; a<M.n_rows; ++a)
{
for(uword b=0; b<M.n_cols; ++b)
out_obs << M(a,b) << " ";
out_obs << endl;
}
out_obs.close();
}
g2 += sm.g2_step;
}
//********* END ANALYSIS **********//
return 0;
}