forked from jacyara/GenESyS-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntegratorDiogoImpl.cpp
67 lines (56 loc) · 1.9 KB
/
IntegratorDiogoImpl.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: IntegratorDiogoImpl.cpp
* Author: cancian
*
* Created on 23 de Agosto de 2018, 17:28
*/
#include "IntegratorDiogoImpl.h"
IntegratorDiogoImpl::IntegratorDiogoImpl() {
}
IntegratorDiogoImpl::IntegratorDiogoImpl(const IntegratorDiogoImpl& orig) {
}
IntegratorDiogoImpl::~IntegratorDiogoImpl() {
}
void IntegratorDiogoImpl::setPrecision(double e) {
_precision = e;
}
double IntegratorDiogoImpl::getPrecision() {
return _precision;
}
double IntegratorDiogoImpl::integrate(double min, double max, double (*f)(double, double), double p2) {
double fa = f(min, p2);
double m = (min+max)/2;
double fm = f(m, p2);
double fb = f(max, p2);
double result = (max-min)*(fa+4*fm+fb)/6;
return result;
}
double IntegratorDiogoImpl::integrate(double min, double max, double (*f)(double, double, double), double p2, double p3) {
double fa = f(min, p2, p3);
double m = (min+max)/2;
double fm = f(m, p2, p3);
double fb = f(max, p2, p3);
double result = (max-min)*(fa+4*fm+fb)/6;
return result;
}
double IntegratorDiogoImpl::integrate(double min, double max, double (*f)(double, double, double, double), double p2, double p3, double p4) {
double fa = f(min, p2, p3, p4);
double m = (min+max)/2;
double fm = f(m, p2, p3, p4);
double fb = f(max, p2, p3, p4);
double result = (max-min)*(fa+4*fm+fb)/6;
return result;
}
double IntegratorDiogoImpl::integrate(double min, double max, double (*f)(double, double, double, double, double), double p2, double p3, double p4, double p5) {
double fa = f(min, p2, p3, p4, p5);
double m = (min+max)/2;
double fm = f(m, p2, p3, p4, p5);
double fb = f(max, p2, p3, p4, p5);
double result = (max-min)*(fa+4*fm+fb)/6;
return result;
}