-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlntegralThreads.cpp
154 lines (118 loc) · 2.95 KB
/
lntegralThreads.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
147
148
149
150
151
152
153
154
#include "IntegralThreads.h"
// IntConstStepThread
IntConstStepThread::IntConstStepThread(QString func, double a, double b, int n, ModeInt mode)
{
this->setObjectName("IntConstStepThread");
this->func = func;
this->a = a;
this->b = b;
this->n = n;
this->mode = mode;
}
void IntConstStepThread::run()
{
BaseCalcThread::run();
double ans;
switch(mode)
{
case ModeIntLeftRect:
ans = IntLeftRect(QStrToCStr(func), a, b, n);
break;
case ModeIntRightRect:
ans = IntRightRect(QStrToCStr(func), a, b, n);
break;
case ModeIntMedianRect:
ans = IntMedianRect(QStrToCStr(func), a, b, n);
break;
case ModeIntTrapeze:
ans = IntTrapeze(QStrToCStr(func), a, b, n);
break;
case ModeIntSimpson:
ans = IntSimpson(QStrToCStr(func), a, b, n);
break;
default:
ans = NAN;
}
if(IsErrorCalc())
{
sendError(GetResultCode());
return;
}
if(IsCancel())
return;
sendResult(ans);
}
// IntFloatingStepThread
IntFloatingStepThread::IntFloatingStepThread(QString func, double a, double b, double e, ModeInt mode)
{
this->setObjectName("IntFloatingStepThread");
this->func = func;
this->a = a;
this->b = b;
this->e = e;
this->mode = mode;
}
void IntFloatingStepThread::sendResult(double value, int iterations)
{ emit sendResultSignal(value, iterations); }
void IntFloatingStepThread::run()
{
double ans;
int iterations;
IntFuncRef funcRef;
BaseCalcThread::run();
switch(mode)
{
case ModeIntLeftRect:
funcRef = IntLeftRect;
break;
case ModeIntRightRect:
funcRef = IntRightRect;
break;
case ModeIntMedianRect:
funcRef = IntMedianRect;
break;
case ModeIntTrapeze:
funcRef = IntTrapeze;
break;
case ModeIntSimpson:
funcRef = IntSimpson;
break;
default:
return;
}
ans = IntDoubleCalc(funcRef, QStrToCStr(func), a, b, e, &iterations);
if(IsErrorCalc())
{
sendError(GetResultCode());
return;
}
if(IsCancel())
return;
sendResult(ans, iterations);
}
// IntMultipleThread
IntMultipleThread::IntMultipleThread(QString func, double a, double b, double c, double d, int xn, int yn)
{
this->setObjectName("IntMultipleThread");
this->func = func;
this->a = a;
this->b = b;
this->c = c;
this->d = d;
this->xn = xn;
this->yn = yn;
}
void IntMultipleThread::run()
{
BaseCalcThread::run();
double ans;
ans = CalcDoubleInt(QStrToCStr(func), a, b, c, d, xn, yn);
if(IsErrorCalc())
{
sendError(GetResultCode());
return;
}
if(IsCancel())
return;
sendResult(ans);
}