-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
112 lines (88 loc) · 2.57 KB
/
main.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
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "code/utility/arrfunc.h"
#include "code/utility/Vector.h"
#include "code/solver/RaySolver.h"
#include "code/goodness/goodness.h"
#include "code/solver/tracing.h"
using std::cin, std::cout;
int poly(){
int N;
cin >> N;
std::vector<float> poly;
poly.reserve(N);
for (int i = 0; i < N; ++i) {
float temp;
cin >> temp;
poly.push_back(temp);
}
auto n_raw = coef_func(poly);
auto dn_raw = coef_func(poly_der(poly));
auto n = [n_raw](Vector2f r){
return n_raw(r[1]);
};
auto dn = [dn_raw](Vector2f r){
return Vector2f{0,dn_raw(r[1])};
};
// Получаем начальные данные
float H, alpha, dt; int M;
cin >> H >> alpha >> dt >> M;
int T;
cin >> T; // пока пофиг на T
auto solve = solver_full(n, dn, H, alpha, M, dt, INT32_MAX);
auto optical_data = get_data(solve, n);
switch (T)
{
case 1:
case 2:{
std::string name;
cin >> name;
std::string PATH = "../data/points/data/" + name + '_';
std::ofstream fout;
for(int j = 0 ; j < solve.size(); ++j){
std::string temp = PATH + std::to_string(j) + ".csv";
fout.open(temp);
fout << "";
if(T == 2) {
fout << solve[j].get_data(n) << '\n';
continue;
}
auto values = solve[j].get_values();
for(int i = 0; i < values.size(); ++i){
auto r = Vector2f{values[i][0], values[i][1]};
auto v0 = Vector2f{values[i][2], values[i][3]};
auto t = dt * i;
// First integrals of the system:
// |v| ~ (v,v)/n(r)/n(r) const
// n*[v - (v,dn)/(dn,dn)*dn] ~ const
fout << t << ' ' << values[i] << '\n';
}
fout << std::endl;
fout.close();
}
}
default: {
float good = goodness(optical_data, H, 1.0f, alpha, M);
cout << good;
break;
}
}
return 0;
}
void testing(){
}
int main(int argc, char** argv) {
// tracing();
std::string type;
cin >> type;
// std::ofstream fout;
// fout.open("test1.txt");
// fout.close();
if( type == "poly" ) poly();
else
if( type == "testing") testing();
else
cout << "No appropriate type given";
}