-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmymath.cpp
More file actions
43 lines (43 loc) · 742 Bytes
/
mymath.cpp
File metadata and controls
43 lines (43 loc) · 742 Bytes
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
#include <iostream>
#include "mymath.hpp"
using namespace std;
//三角隶属度函数
double trimf(double x, double a, double b, double c)
{
double u;
if (x >= a && x <= b)
{
u = (x - a) / (b - a);
}
else if (x > b && x <= c)
{
u = (c - x) / (c - b);
}
else
u = 0.0;
return u;
}
//正态隶属度函数
double gaussmf(double x, double ave, double sigma)
{
double u;
if (sigma < 0)
{
cout << "In gaussmf, sigma must larger than 0" << endl;
}
u = exp(-pow(((x - ave) / sigma), 2));
return u;
}
double trapmf(double x, double a, double b, double c, double d)
{
double u;
if (x >= a && x < b)
u = (x - a) / (b - a);
else if (x >= b && x < c)
u = 1;
else if (x >= c && x <= d)
u = (d - x) / (d - c);
else
u = 0;
return u;
}