home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 41 / IOPROG_41.ISO / soft / c++ / NUMCPP11.ZIP / domain.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-09  |  2.1 KB  |  83 lines

  1. //===================================================================
  2. // domain.hpp
  3. //
  4. // Version 1.0
  5. //
  6. // Written by:
  7. //   Brent Worden
  8. //   WordenWare
  9. //   email:  Brent@Worden.org
  10. //
  11. // Copyright (c) 1999 WordenWare
  12. //
  13. // Created:  April 10, 1999
  14. // Revised:  
  15. //===================================================================
  16.  
  17. #ifndef _DOMAIN_HPP_
  18. #define _DOMAIN_HPP_
  19.  
  20. #include "numerics.h"
  21.  
  22. NUM_BEGIN
  23.  
  24. template<class X>
  25. inline bool isPositive(X x)
  26. //-------------------------------------------------------------------
  27. // Return true if x is positive, false otherwise.
  28. //-------------------------------------------------------------------
  29. {
  30.     return x > X(0);
  31. };
  32.  
  33. template<class X>
  34. inline bool isNegative(X x)
  35. //-------------------------------------------------------------------
  36. // Return true if x is negative, false otherwise.
  37. //-------------------------------------------------------------------
  38. {
  39.     static X zero(0);
  40.     return x < zero;
  41. }
  42.  
  43. template<class X>
  44. inline bool isNonNegative(X x)
  45. //-------------------------------------------------------------------
  46. // Return true if x is positive or zero, false otherwise.
  47. //-------------------------------------------------------------------
  48. {
  49.     static X zero(0);
  50.     return x >= zero;
  51. }
  52.  
  53. template<class X>
  54. inline bool isNonPositive(X x)
  55. //-------------------------------------------------------------------
  56. // Return true if x is negative or zero, false otherwise.
  57. //-------------------------------------------------------------------
  58. {
  59.     static const X zero(0);
  60.     return x <= zero;
  61. }
  62.  
  63. template<class X>
  64. inline bool isZeroOne(X x)
  65. //-------------------------------------------------------------------
  66. // Return true if x is an element of [0.0, 1.0], false otherwise.
  67. //-------------------------------------------------------------------
  68. {
  69.     static const X zero(0);
  70.     static const X one(1);
  71.     return zero <= x && x <= one;
  72. }
  73.  
  74. NUM_END
  75.  
  76. #endif
  77.  
  78. //===================================================================
  79. // Revision History
  80. //
  81. // Version 1.0 - 04/10/1999 - New.
  82. //===================================================================
  83.