rename MAIN_,MAIN to MAIN,main in test
[liba.git] / include / a / fuzzy.h
blob656310b182308330780b56f9e304ca93f54489e2
1 /*!
2 @file fuzzy.h
3 @brief fuzzy operator
4 */
6 #ifndef LIBA_FUZZY_H
7 #define LIBA_FUZZY_H
9 #include "a.h"
11 /*!
12 @ingroup A
13 @addtogroup A_FUZZY fuzzy operator
17 #if defined(__cplusplus)
18 extern "C" {
19 #endif /* __cplusplus */
20 #if defined(LIBA_FUZZY_C)
21 #undef A_INTERN
22 #define A_INTERN A_INLINE
23 #endif /* LIBA_FUZZY_C */
25 /*!
26 @brief complementary operator
27 @param[in] x membership
28 @return = \f$ 1-x \f$
30 #if !defined A_HAVE_INLINE || defined(LIBA_FUZZY_C)
31 A_EXTERN a_float a_fuzzy_not(a_float x);
32 #endif /* A_HAVE_INLINE */
33 #if defined(A_HAVE_INLINE) || defined(LIBA_FUZZY_C)
34 A_INTERN a_float a_fuzzy_not(a_float x) { return 1 - x; }
35 #endif /* A_HAVE_INLINE */
37 /*!
38 @brief fuzzy intersection operator
39 @param[in] a left-hand operand
40 @param[in] b right-hand operand
41 @return = \f$ \min(a,b) \f$
43 #if !defined A_HAVE_INLINE || defined(LIBA_FUZZY_C)
44 A_EXTERN a_float a_fuzzy_cap(a_float a, a_float b);
45 #endif /* A_HAVE_INLINE */
46 #if defined(A_HAVE_INLINE) || defined(LIBA_FUZZY_C)
47 A_INTERN a_float a_fuzzy_cap(a_float a, a_float b) { return A_MIN(a, b); }
48 #endif /* A_HAVE_INLINE */
50 /*!
51 @brief algebraic product operator
52 @param[in] a left-hand operand
53 @param[in] b right-hand operand
54 @return = \f$ ab \f$
56 #if !defined A_HAVE_INLINE || defined(LIBA_FUZZY_C)
57 A_EXTERN a_float a_fuzzy_cap_algebra(a_float a, a_float b);
58 #endif /* A_HAVE_INLINE */
59 #if defined(A_HAVE_INLINE) || defined(LIBA_FUZZY_C)
60 A_INTERN a_float a_fuzzy_cap_algebra(a_float a, a_float b) { return a * b; }
61 #endif /* A_HAVE_INLINE */
63 /*!
64 @brief bounded product operator
65 @param[in] a left-hand operand
66 @param[in] b right-hand operand
67 @return = \f$ \max(a+b-1,0) \f$
69 #if !defined A_HAVE_INLINE || defined(LIBA_FUZZY_C)
70 A_EXTERN a_float a_fuzzy_cap_bounded(a_float a, a_float b);
71 #endif /* A_HAVE_INLINE */
72 #if defined(A_HAVE_INLINE) || defined(LIBA_FUZZY_C)
73 A_INTERN a_float a_fuzzy_cap_bounded(a_float a, a_float b)
75 a_float const c = a + b - 1;
76 return A_MAX(c, 0);
78 #endif /* A_HAVE_INLINE */
80 /*!
81 @brief fuzzy union operator
82 @param[in] a left-hand operand
83 @param[in] b right-hand operand
84 @return = \f$ \max(a,b) \f$
86 #if !defined A_HAVE_INLINE || defined(LIBA_FUZZY_C)
87 A_EXTERN a_float a_fuzzy_cup(a_float a, a_float b);
88 #endif /* A_HAVE_INLINE */
89 #if defined(A_HAVE_INLINE) || defined(LIBA_FUZZY_C)
90 A_INTERN a_float a_fuzzy_cup(a_float a, a_float b) { return A_MAX(a, b); }
91 #endif /* A_HAVE_INLINE */
93 /*!
94 @brief algebraic sum operator
95 @param[in] a left-hand operand
96 @param[in] b right-hand operand
97 @return = \f$ a+b-ab \f$
99 #if !defined A_HAVE_INLINE || defined(LIBA_FUZZY_C)
100 A_EXTERN a_float a_fuzzy_cup_algebra(a_float a, a_float b);
101 #endif /* A_HAVE_INLINE */
102 #if defined(A_HAVE_INLINE) || defined(LIBA_FUZZY_C)
103 A_INTERN a_float a_fuzzy_cup_algebra(a_float a, a_float b) { return a + b - a * b; }
104 #endif /* A_HAVE_INLINE */
107 @brief bounded sum operator
108 @param[in] a left-hand operand
109 @param[in] b right-hand operand
110 @return = \f$ \min(a+b,1) \f$
112 #if !defined A_HAVE_INLINE || defined(LIBA_FUZZY_C)
113 A_EXTERN a_float a_fuzzy_cup_bounded(a_float a, a_float b);
114 #endif /* A_HAVE_INLINE */
115 #if defined(A_HAVE_INLINE) || defined(LIBA_FUZZY_C)
116 A_INTERN a_float a_fuzzy_cup_bounded(a_float a, a_float b)
118 a_float const c = a + b;
119 return A_MIN(c, 1);
121 #endif /* A_HAVE_INLINE */
124 @brief equilibrium operator
125 @param[in] a left-hand operand
126 @param[in] b right-hand operand
127 @return = \f$ \sqrt{ab}\sqrt{1-(1-a)(1-b)} \f$
129 A_EXTERN a_float a_fuzzy_equ(a_float a, a_float b);
132 @brief equilibrium operator
133 @param[in] gamma gamma operator
134 @param[in] a left-hand operand
135 @param[in] b right-hand operand
136 @return = \f$ (ab)^{1-\gamma}(1-(1-a)(1-b))^{\gamma} \f$
138 A_EXTERN a_float a_fuzzy_equ_(a_float gamma, a_float a, a_float b);
140 #if defined(LIBA_FUZZY_C)
141 #undef A_INTERN
142 #define A_INTERN static A_INLINE
143 #endif /* LIBA_FUZZY_C */
144 #if defined(__cplusplus)
145 } /* extern "C" */
146 #endif /* __cplusplus */
148 /*! @} A_FUZZY */
150 #endif /* a/fuzzy.h */