rename MAIN_,MAIN to MAIN,main in test
[liba.git] / include / a / mf.h
blob041a6b35c9e3719cc16adbf6c0b10f5d5e5fa18e
1 /*!
2 @file mf.h
3 @brief membership function
4 */
6 #ifndef LIBA_MF_H
7 #define LIBA_MF_H
9 #include "a.h"
11 /*!
12 @ingroup A
13 @addtogroup A_MF membership function
17 /*!
18 @brief enumeration for membership function
20 enum
22 A_MF_NUL, //!< none
23 A_MF_GAUSS, //!< gaussian membership function
24 A_MF_GAUSS2, //!< gaussian combination membership function
25 A_MF_GBELL, //!< generalized bell-shaped membership function
26 A_MF_SIG, //!< sigmoidal membership function
27 A_MF_DSIG, //!< difference between two sigmoidal membership functions
28 A_MF_PSIG, //!< product of two sigmoidal membership functions
29 A_MF_TRAP, //!< trapezoidal membership function
30 A_MF_TRI, //!< triangular membership function
31 A_MF_LINS, //!< linear s-shaped saturation membership function
32 A_MF_LINZ, //!< linear z-shaped saturation membership function
33 A_MF_S, //!< s-shaped membership function
34 A_MF_Z, //!< z-shaped membership function
35 A_MF_PI //!< pi-shaped membership function
38 #if defined(__cplusplus)
39 extern "C" {
40 #endif /* __cplusplus */
42 /*!
43 @brief gaussian membership function
44 \f[
45 f(x,\sigma,c)=e^{-\frac{(x-c)^2}{2\sigma^2}}
46 \f]
47 @param[in] x input value for which to compute membership value.
48 @param[in] sigma is the standard deviation.
49 @param[in] c is the mean.
50 @return membership value.
52 A_EXTERN a_float a_mf_gauss(a_float x, a_float sigma, a_float c);
54 /*!
55 @brief gaussian combination membership function
56 \f[
57 f(x,\sigma_1,c_1,\sigma_2,c_2)=\begin{cases}
58 e^{-\frac{(x-c_1)^2}{2\sigma_1^2}} & x \lt c_1 \\
59 1 & c_1 \le x \le c_2 \\
60 e^{-\frac{(x-c_2)^2}{2\sigma_2^2}} & x \gt c_2 \\
61 \end{cases}
62 \f]
63 @param[in] x input value for which to compute membership value.
64 @param[in] sigma1 is the standard deviation of the left gaussian function.
65 @param[in] c1 is the mean of the left gaussian function.
66 @param[in] sigma2 is the standard deviation of the right gaussian function.
67 @param[in] c2 is the mean of the right gaussian function.
68 @return membership value.
70 A_EXTERN a_float a_mf_gauss2(a_float x, a_float sigma1, a_float c1, a_float sigma2, a_float c2);
72 /*!
73 @brief generalized bell-shaped membership function
74 \f[
75 f(x,a,b,c)=\frac{1}{1+\left|\frac{x-c}{a}\right|^{2b}}
76 \f]
77 @param[in] x input value for which to compute membership value.
78 @param[in] a defines the width of the membership function, where a larger value creates a wider membership function.
79 @param[in] b defines the shape of the curve on either side of the central plateau, where a larger value creates a more steep transition.
80 @param[in] c defines the center of the membership function.
81 @return membership value.
83 A_EXTERN a_float a_mf_gbell(a_float x, a_float a, a_float b, a_float c);
85 /*!
86 @brief sigmoidal membership function
87 \f[
88 f(x,a,c)=\frac{1}{1+e^{-a(x-c)}}
89 \f]
90 @param[in] x input value for which to compute membership value.
91 @param[in] a defines the width of the transition area.
92 @param[in] c defines the center of the transition area.
93 @return membership value.
95 A_EXTERN a_float a_mf_sig(a_float x, a_float a, a_float c);
97 /*!
98 @brief difference between two sigmoidal membership functions
99 \f[
100 f(x,a_1,c_1,a_2,c_2)=\frac{1}{1+e^{-a_1(x-c_1)}}-\frac{1}{1+e^{-a_2(x-c_2)}}
102 @param[in] x input value for which to compute membership value.
103 @param[in] a1 defines the width of the first transition area.
104 @param[in] c1 defines the center of the first transition area.
105 @param[in] a2 defines the width of the second transition area.
106 @param[in] c2 defines the center of the second transition area.
107 @return membership value.
109 A_EXTERN a_float a_mf_dsig(a_float x, a_float a1, a_float c1, a_float a2, a_float c2);
112 @brief product of two sigmoidal membership functions
114 f(x,a_1,c_1,a_2,c_2)=\frac{1}{1+e^{-a_1(x-c_1)}}\times\frac{1}{1+e^{-a_2(x-c_2)}}
116 @param[in] x input value for which to compute membership value.
117 @param[in] a1 defines the width of the first transition area.
118 @param[in] c1 defines the center of the first transition area.
119 @param[in] a2 defines the width of the second transition area.
120 @param[in] c2 defines the center of the second transition area.
121 @return membership value.
123 A_EXTERN a_float a_mf_psig(a_float x, a_float a1, a_float c1, a_float a2, a_float c2);
126 @brief trapezoidal membership function
128 f(x,a,b,c,d)=\begin{cases}
129 0 & x \le a \\
130 \frac{x-a}{b-a} & a \le x \le b \\
131 1 & b \le x \le c \\
132 \frac{d-x}{d-c} & c \le x \le d \\
133 0 & x \ge d \\
134 \end{cases}
136 @param[in] x input value for which to compute membership value.
137 @param[in] a defines its left foot.
138 @param[in] b defines its left shoulder.
139 @param[in] c defines its right shoulder.
140 @param[in] d defines its right foot.
141 @return membership value.
143 A_EXTERN a_float a_mf_trap(a_float x, a_float a, a_float b, a_float c, a_float d);
146 @brief triangular membership function
148 f(x,a,b)=\begin{cases}
149 0 & x \le a \\
150 \frac{x-a}{b-a} & a \le x \le b \\
151 \frac{c-x}{c-b} & b \le x \le c \\
152 0 & x \ge c \\
153 \end{cases}
155 @param[in] x input value for which to compute membership value.
156 @param[in] a defines its left foot.
157 @param[in] b defines its peak.
158 @param[in] c defines its right foot.
159 @return membership value.
161 A_EXTERN a_float a_mf_tri(a_float x, a_float a, a_float b, a_float c);
164 @brief linear s-shaped saturation membership function
166 f(x,a,b)=\begin{cases}
167 0 & x \lt a \\
168 \frac{x-a}{b-a} & a \le x \le b \\
169 1 & x \gt b \\
170 \end{cases}
172 @param[in] x input value for which to compute membership value.
173 @param[in] a defines its foot.
174 @param[in] b defines its shoulder.
175 @return membership value.
177 A_EXTERN a_float a_mf_lins(a_float x, a_float a, a_float b);
180 @brief linear z-shaped saturation membership function
182 f(x,a,b)=\begin{cases}
183 1 & x \lt a \\
184 \frac{b-x}{b-a} & a \le x \le b \\
185 0 & x \gt b \\
186 \end{cases}
188 @param[in] x input value for which to compute membership value.
189 @param[in] a defines its shoulder.
190 @param[in] b defines its foot.
191 @return membership value.
193 A_EXTERN a_float a_mf_linz(a_float x, a_float a, a_float b);
196 @brief s-shaped membership function
198 f(x,a,b)=\begin{cases}
199 0 & x \le a \\
200 2(\frac{x-a}{b-a})^2 & a \le x \le \frac{a+b}{2} \\
201 1-2(\frac{b-x}{b-a})^2 & \frac{a+b}{2} \le x \le b \\
202 1 & x \ge b \\
203 \end{cases}
205 @param[in] x input value for which to compute membership value.
206 @param[in] a defines its foot.
207 @param[in] b defines its shoulder.
208 @return membership value.
210 A_EXTERN a_float a_mf_s(a_float x, a_float a, a_float b);
213 @brief z-shaped membership function
215 f(x,a,b)=\begin{cases}
216 1 & x \le a \\
217 1-2(\frac{x-a}{b-a})^2 & a \le x \le \frac{a+b}{2} \\
218 2(\frac{b-x}{b-a})^2 & \frac{a+b}{2} \le x \le b \\
219 0 & x \ge b \\
220 \end{cases}
222 @param[in] x input value for which to compute membership value.
223 @param[in] a defines its shoulder.
224 @param[in] b defines its foot.
225 @return membership value.
227 A_EXTERN a_float a_mf_z(a_float x, a_float a, a_float b);
230 @brief pi-shaped membership function
232 f(x,a,b,c,d)=\begin{cases}
233 0 & x \le a \\
234 2(\frac{x-a}{b-a})^2 & a \le x \le \frac{a+b}{2} \\
235 1-2(\frac{b-x}{b-a})^2 & \frac{a+b}{2} \le x \le b \\
236 1 & b \le x \le c \\
237 1-2(\frac{x-c}{d-c})^2 & c \le x \le \frac{c+d}{2} \\
238 2(\frac{d-x}{d-c})^2 & \frac{c+d}{2} \le x \le d \\
239 1 & x \ge d \\
240 \end{cases}
242 @param[in] x input value for which to compute membership value.
243 @param[in] a defines its left foot.
244 @param[in] b defines its left shoulder.
245 @param[in] c defines its right shoulder.
246 @param[in] d defines its right foot.
247 @return membership value.
249 A_EXTERN a_float a_mf_pi(a_float x, a_float a, a_float b, a_float c, a_float d);
252 @brief membership function
253 @param[in] e enumeration for membership function
254 | | |
255 | :---------------- | -------------------------------------- |
256 | \ref A_MF_GAUSS | a_mf_gauss(x, sigma, c) |
257 | \ref A_MF_GAUSS2 | a_mf_gauss2(x, sigma1, c1, sigma2, c2) |
258 | \ref A_MF_GBELL | a_mf_gbell(x, a, b, c) |
259 | \ref A_MF_SIG | a_mf_sig(x, a, c) |
260 | \ref A_MF_DSIG | a_mf_dsig(x, a1, c1, a2, c2) |
261 | \ref A_MF_PSIG | a_mf_psig(x, a1, c1, a2, c2) |
262 | \ref A_MF_TRAP | a_mf_trap(x, a, b, c, d) |
263 | \ref A_MF_TRI | a_mf_tri(x, a, b, c) |
264 | \ref A_MF_LINS | a_mf_lins(x, a, b) |
265 | \ref A_MF_LINZ | a_mf_linz(x, a, b) |
266 | \ref A_MF_S | a_mf_s(x, a, b) |
267 | \ref A_MF_Z | a_mf_z(x, a, b) |
268 | \ref A_MF_PI | a_mf_pi(x, a, b, c, d) |
269 @param[in] x input value for which to compute membership value.
270 @param[in] a is an array that stores parameters.
271 @arg \b a[2] \ref a_mf_gauss \ref a_mf_sig \ref a_mf_lins \ref a_mf_linz \ref a_mf_s \ref a_mf_z
272 @arg \b a[3] \ref a_mf_gbell \ref a_mf_tri
273 @arg \b a[4] \ref a_mf_gauss2 \ref a_mf_dsig \ref a_mf_psig \ref a_mf_trap \ref a_mf_pi
274 @return membership value.
276 A_EXTERN a_float a_mf(unsigned int e, a_float x, a_float const *a);
278 #if defined(__cplusplus)
279 } /* extern "C" */
280 #endif /* __cplusplus */
282 /*! @} A_MF */
284 #endif /* a/mf.h */