home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FZNUM.ZIP / fuzzy / fznum / fznum.h < prev    next >
C/C++ Source or Header  |  1994-10-03  |  6KB  |  296 lines

  1. //---------------------------------------------------------------------------
  2. //
  3. // FZNUM.H
  4. //
  5. //    Fuzzy number type declarations.
  6. //
  7. //    Based on A. Kaufmann, M. Gupta, "Introduction to Fuzzy Arithmetic",
  8. //    Van Nostrand Reinhold, New York, 1991.
  9. //
  10. // Contents:
  11. //
  12. //    define NPLEV
  13. //
  14. //    class FzNum
  15. //
  16. //    inline ConfInt FzNum::GetBase()
  17. //    inline double FzNum::GetBaseSize()
  18. //
  19. //    inline FzNum FzNum::operator+()
  20. //
  21. //    inline FzNum operator+( double opnd1, FzNum opnd2)
  22. //    inline FzNum operator-( double opnd1, FzNum opnd2)
  23. //    inline FzNum operator*( double opnd1, FzNum opnd2)
  24. //
  25. // Author: S. Deodato ( 03.03.94)
  26. //
  27. //---------------------------------------------------------------------------
  28.  
  29. #ifndef ___FZNUM_H
  30. #define ___FZNUM_H
  31.  
  32. #include "confint.h"
  33.  
  34. #define NPLEV 10 // number of used presumption levels
  35.  
  36.  
  37. //---------------------------------------------------------------------------
  38. //
  39. // class FzNum
  40. //
  41. //    Fuzzy number representation.
  42. //
  43. // Members:
  44. //
  45. //    ConfInt ciPLev[ NPLEV + 1]
  46. //       presumption levels used as internal representation of the fuzzy
  47. //       number
  48. //
  49. // Author: S. Deodato ( 03.03.94)
  50. //
  51. //---------------------------------------------------------------------------
  52.  
  53.  
  54. class FzNum
  55.  
  56. {
  57.  
  58.    protected:
  59.  
  60.       ConfInt ciPLev[ NPLEV + 1];
  61.  
  62.    public:
  63.  
  64.       FzNum() {}
  65.  
  66.       FzNum( double value);
  67.       FzNum( double left, double middle, double right);
  68.       FzNum( double lBase, double lTop, double rTop, double rBase);
  69.  
  70.       ConfInt GetBase();
  71.       double GetBaseSize();
  72.  
  73.       double operator[]( double value);
  74.  
  75.       FzNum operator+();
  76.       FzNum operator-();
  77.  
  78.       FzNum operator+( double opnd2);
  79.       FzNum operator+( FzNum opnd2);
  80.       FzNum operator-( double opnd2);
  81.       FzNum operator-( FzNum opnd2);
  82.       FzNum operator*( double opnd2);
  83.       FzNum operator*( FzNum opnd2);
  84.       FzNum operator/( double opnd2);
  85.       FzNum operator/( FzNum opnd2);
  86.  
  87.       FzNum operator+=( double opnd2);
  88.       FzNum operator+=( FzNum opnd2);
  89.       FzNum operator-=( double opnd2);
  90.       FzNum operator-=( FzNum opnd2);
  91.       FzNum operator*=( double opnd2);
  92.       FzNum operator*=( FzNum opnd2);
  93.       FzNum operator/=( double opnd2);
  94.       FzNum operator/=( FzNum opnd2);
  95.  
  96.       friend FzNum operator+( double opnd1, FzNum opnd2);
  97.       friend FzNum operator-( double opnd1, FzNum opnd2);
  98.       friend FzNum operator*( double opnd1, FzNum opnd2);
  99.       friend FzNum operator/( double opnd1, FzNum opnd2);
  100.  
  101.       friend ostream& operator<<( ostream& smStream, FzNum item);
  102.  
  103.       void print();
  104.  
  105.       friend FzNum min( FzNum opnd1, FzNum opnd2);
  106.       friend FzNum max( FzNum opnd1, FzNum opnd2);
  107.  
  108.       friend FzNum sin( FzNum opnd);
  109.       friend FzNum cos( FzNum opnd);
  110.  
  111.       friend double fzSM( FzNum opnd1, FzNum opnd2, double lambda = 0.5);
  112. };
  113.  
  114.  
  115. //---------------------------------------------------------------------------
  116. //
  117. // inline ConfInt FzNum::GetBase()
  118. //
  119. //    Return the confidence interval at presumption level 0.
  120. //
  121. // Argumets:
  122. //
  123. //    none
  124. //
  125. // Return value:
  126. //
  127. //    the requested confidence interval
  128. //
  129. // Side effects:
  130. //
  131. //    none
  132. //
  133. // Author: S. Deodato ( 26.08.94)
  134. //
  135. //---------------------------------------------------------------------------
  136.  
  137. inline ConfInt FzNum::GetBase()
  138.  
  139. {
  140.   return ciPLev[ 0];
  141. }
  142.  
  143.  
  144. //---------------------------------------------------------------------------
  145. //
  146. // inline double FzNum::GetBaseSize()
  147. //
  148. //    Return the size of the confidence interval at presumption level 0.
  149. //
  150. // Argumets:
  151. //
  152. //    none
  153. //
  154. // Return value:
  155. //
  156. //    the requested size
  157. //
  158. // Side effects:
  159. //
  160. //    none
  161. //
  162. // Author: S. Deodato ( 26.08.94)
  163. //
  164. //---------------------------------------------------------------------------
  165.  
  166. inline double FzNum::GetBaseSize()
  167.  
  168. {
  169.   return ciPLev[ 0].GetSize();
  170. }
  171.  
  172.  
  173. //---------------------------------------------------------------------------
  174. //
  175. // inline FzNum FzNum::operator+()
  176. //
  177. //    Apply the unary plus operator to a fuzzy number.
  178. //
  179. // Arguments:
  180. //
  181. //    none
  182. //
  183. // Return value:
  184. //
  185. //    the resulting fuzzy number
  186. //
  187. // Side effects:
  188. //
  189. //    none
  190. //
  191. // Author: S. Deodato ( 03.03.94)
  192. //
  193. //---------------------------------------------------------------------------
  194.  
  195. inline FzNum FzNum::operator+()
  196.  
  197. {
  198.    return *this;
  199. }
  200.  
  201.  
  202. //---------------------------------------------------------------------------
  203. //
  204. // inline FzNum operator+( double opnd1, FzNum opnd2)
  205. //
  206. //    Addiction between a singleton and a fuzzy number.
  207. //
  208. // Arguments:
  209. //
  210. //    double opnd1
  211. //    FzNum opnd2
  212. //       addiction operands
  213. //
  214. // Return value:
  215. //
  216. //    the resulting fuzzy number
  217. //
  218. // Side effects:
  219. //
  220. //    none
  221. //
  222. // Author: S. Deodato ( 03.03.94)
  223. //
  224. //---------------------------------------------------------------------------
  225.  
  226. inline FzNum operator+( double opnd1, FzNum opnd2)
  227.  
  228. {
  229.    return opnd2 + opnd1;
  230. }
  231.  
  232.  
  233. //---------------------------------------------------------------------------
  234. //
  235. // inline FzNum operator-( double opnd1, FzNum opnd2)
  236. //
  237. //    Subtraction between a singleton and a fuzzy number.
  238. //
  239. // Arguments:
  240. //
  241. //    double opnd1
  242. //    FzNum opnd2
  243. //       subtraction operands
  244. //
  245. // Return value:
  246. //
  247. //    the resulting fuzzy number
  248. //
  249. // Side effects:
  250. //
  251. //    none
  252. //
  253. // Author: S. Deodato ( 03.03.94)
  254. //
  255. //---------------------------------------------------------------------------
  256.  
  257. inline FzNum operator-( double opnd1, FzNum opnd2)
  258.  
  259. {
  260.    return -opnd2 + opnd1;
  261. }
  262.  
  263.  
  264. //---------------------------------------------------------------------------
  265. //
  266. // inline FzNum operator*( double opnd1, FzNum opnd2)
  267. //
  268. //    Multiplication between a singleton and a fuzzy number.
  269. //
  270. // Arguments:
  271. //
  272. //    double opnd1
  273. //    FzNum opnd2
  274. //       multiplication operands
  275. //
  276. // Return value:
  277. //
  278. //    the resulting fuzzy number
  279. //
  280. // Side effects:
  281. //
  282. //    none
  283. //
  284. // Author: S. Deodato ( 03.03.94)
  285. //
  286. //---------------------------------------------------------------------------
  287.  
  288. inline FzNum operator*( double opnd1, FzNum opnd2)
  289.  
  290. {
  291.    return opnd2 * opnd1;
  292. }
  293.  
  294.  
  295. #  endif // ___FZNUM_H
  296.