-
Notifications
You must be signed in to change notification settings - Fork 0
/
mySimpson.cpp
60 lines (53 loc) · 1.99 KB
/
mySimpson.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
#include "mySimpson.h"
#include<cmath>
mySimpson::mySimpson(const double& a, const double& b, const double& eps)
{
Initial.a = a;
Initial.b = b;
Initial.eps = eps;
Initial.Ivalue = (b - a) / 6 * (this->SimpsonFunction(a) + 4 * this->SimpsonFunction((a + b) / 2) + this->SimpsonFunction(b));
}
inline bool mySimpson::operator < (const mySimpson& rightValue) const {
return Initial.Ivalue < rightValue.getIvalue() ? true : false;
}
inline bool mySimpson::operator < (const double& rightValue) const {
return Initial.Ivalue < rightValue ? true : false;
}
inline bool mySimpson::operator > (const mySimpson& rightValue) const {
return Initial.Ivalue > rightValue.getIvalue() ? true : false;
}
inline bool mySimpson::operator > (const double& rightValue) const {
return Initial.Ivalue > rightValue ? true : false;
}
double mySimpson::operator + (const mySimpson& rightValue) {
return Initial.Ivalue+rightValue.getIvalue();
}
double mySimpson::operator - (const mySimpson& rightValue) {
return Initial.Ivalue - rightValue.getIvalue();
}
double mySimpson::operator - (const double& rightValue) {
return Initial.Ivalue - rightValue;
}
inline mySimpson& mySimpson::operator +=(const mySimpson& rightValue) {
Initial.a += rightValue.getValue_1();
Initial.b += rightValue.getValue_2();
Initial.eps += rightValue.getEps();
Initial.Ivalue += rightValue.getIvalue();
return *this;
}
mySimpson mySimpson::LeftChild() const
{
double Ivalue = this->BaseSimpson(Initial.a, (Initial.a + Initial.b) / 2);
return mySimpson({Initial.a, (Initial.a + Initial.b) / 2, Initial.eps/2, Ivalue});
}
mySimpson mySimpson::RightChild() const
{
double Ivalue = this->BaseSimpson((Initial.a + Initial.b) / 2, Initial.b);
return mySimpson({ (Initial.a + Initial.b) / 2, Initial.b, Initial.eps / 2, Ivalue });
}
double operator - (const double& temp, const mySimpson& rightValue) {
return temp - rightValue.getIvalue();
}
std::ostream& operator <<(std::ostream& os, const Range& range) {
return os << "[" << range.a << "," << range.b << "] ";
}