-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c++
91 lines (68 loc) · 3.18 KB
/
main.c++
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
// Начало файла main.c++
#include <cstdlib>
#include <cstring>
#include "gsl_func.h"
#include "lab_01.h"
#include "fparser.h"
int main(int argc, char** argv){
double a, b;
int n;
Integrands f;
ManualComputeIntegrall c_i;
GSLComputeIntegrall gsl_i;
c_i.set_lo_lim(0);
cout << "ManualComputeIntegrall. Method Compute (w/о param) \n";
cout << "deafult A = 0 \n";
cout << "deafult B = 1 \n";
cout << "deafult N = 100 \n";
cout << "=> Variant №2, integrall №1: " << c_i.calculation(f.v2_1) << "\n";
cout << "=> Variant №2, integrall №2: " << c_i.calculation(f.v2_2) << "\n";
cout << "=> Variant №3, integrall №1: " << c_i.calculation(f.v3_1) << "\n";
cout << "\n ==>> GSL Library <<== \n\n";
cout << "=> Variant №2, integrall №1: " << gsl_i.calculation(Convert::convert(&f.v2_1)) << "\n";
cout << "=> Variant №2, integrall №2: " << gsl_i.calculation(Convert::convert(&f.v2_2)) << "\n";
cout << "=> Variant №3, integrall №1: " << gsl_i.calculation(Convert::convert(&f.v3_1)) << "\n";
cout << "\n ==>> Введите границы интегрирования <<== \n\n";
cout << "> Нижняя граница интегрирования (a): ";
cin >> a;
cout << "> Верхняя граница интегрирования (b): ";
cin >> b;
cout << "> Число разбиений отрезка (N): ";
cin >> n;
c_i.set_lo_lim(a);
c_i.set_hi_lim(b);
c_i.set_n(n);
gsl_i.set_lo_lim(a);
gsl_i.set_hi_lim(b);
gsl_i.set_n(n);
cout << "\n=> Variant №2, integrall №1: " << c_i.calculation(f.v2_1) << "\n";
cout << "=> Variant №2, integrall №2: " << c_i.calculation(f.v2_2) << "\n";
cout << "=> Variant №3, integrall №1: " << c_i.calculation(f.v3_1) << "\n";
cout << "\n ==>> GSL Library <<== \n\n";
cout << "=> Variant №2, integrall №1: " << gsl_i.calculation(Convert::convert(&f.v2_1)) << "\n";
cout << "=> Variant №2, integrall №2: " << gsl_i.calculation(Convert::convert(&f.v2_2)) << "\n";
cout << "=> Variant №3, integrall №1: " << gsl_i.calculation(Convert::convert(&f.v3_1)) << "\n";
std::string f_input;
std::cout << "\n ==>> Ручной ввод подинтегрального выражения <x> <<== \n\n";
std::cout << " f(x) = ";
cin.ignore();
getline(cin, f_input);
cout << "\n> Нижняя граница интегрирования (a): ";
cin >> a;
cout << "> Верхняя граница интегрирования (b): ";
cin >> b;
cout << "> Число разбиений отрезка (N): ";
cin >> n;
c_i.set_lo_lim(a);
c_i.set_hi_lim(b);
c_i.set_n(n);
gsl_i.set_lo_lim(a);
gsl_i.set_hi_lim(b);
gsl_i.set_n(n);
f.set_manual(f_input);
cout << "\n ==>> Manual calculation <<== \n\n";
cout << " => " << "Int(" << f_input << ") = " << c_i.calculation(f.manual) << "\n";
cout << "\n ==>> GSL Library <<== \n\n";
cout << " => " << "Int(" << f_input << ") = "<< gsl_i.calculation(Convert::convert(&f.manual)) << "\n\n [CALCULATION END]\n\n";
return 0;
}