Main Page | Modules | Files | Functions | Code Elements | Data Structures | Deprecated

eq.h

Go to the documentation of this file.
00001 /*HEAD EQ HHH UGMATH */
00002 /*
00003 *===============================================================================
00004 *
00005 *             Copyright (c) 1993-2001 Unigraphics Solutions Inc.
00006 *                        Unpublished - All rights reserved
00007 *
00008 *===============================================================================
00009 *
00010 *   Header file defining macros used to detected equality between scalars
00011 *   of double or FREAL data type. NOTE: there is a fortran insert file eq.ins
00012 *   if you make changes here, check eq.ins to see if changes are required there.
00013 *
00014 *===============================================================================
00015 *   Date       Name
00016 * 17-Aug-1993  Dennis Lavarini
00017 * 06-Jan-1994  Dennis Lavarini    Add hooks to part/system specific tolerances
00018 * 09-Mar-1994  Keith Hafen    Add EQ_MAX_DBL and EQ_MIN_DBL tolerances
00019 * 15-Mar-1996  William Vittitow   Add EQ_is_finite
00020 * 13-Feb-1997  Jack Marr          Allow EQ_is_equal to work with tol=0.0
00021 * 17-Sep-1998  Reger              Enforce macro signatures under QAZ
00022 * 17-Feb-1999  Reger              Decorate UGMATH prototypes with UGEXPORT;
00023 *                                 include 'unidefs.h' for 'UGEXPORT'
00024 * 18-Aug-1999  Lavarini           Replace UGEXPORT with UGMATHEXPORT
00025 *                                 Move to UGMATH
00026 * 18-Oct-1999  Lavarini           Allow EQ_is_zero to work with tol=0.0
00027 * 08-Dec-2000  Jim Lyles          Added EQ_is_eq, EQ_is_ne, EQ_is_2tol_eq, and
00028 *                                 EQ_is_2tol_ne.
00029 $HISTORY$
00030 *
00031 *===============================================================================
00032 *
00033 *   In the following macro definitions, these conventions are used:
00034 *      Inputs:
00035 *            s, t, and tol are scalars of data type double
00036 *            pos_tol and neg_tol are also scalars of data type double
00037 *
00038 *      Outputs:
00039 *            There is no data type output
00040 *
00041 *      Macro                   Action             Description
00042 *  EQ_TOL_NUMBER           (function call)   Return the part's numerical tol
00043 *  EQ_TOL_LENGTH           (function call)   Return the part's length tol
00044 *  EQ_TOL_LENGTH_SQ        (function call)   Return the part's length squared
00045 *                                            tol
00046 *  EQ_ask_systol           (1.0e-10)         Return system tolerance
00047 *  EQ_is_equal(s, t, tol)  (abs(s-t) <= tol) Return true if scalars are equal
00048 *  EQ_is_eq(s, t, tol)     (abs(s-t) <= tol) Same as EQ_is_equal
00049 *  EQ_is_ge(s, t, tol)     (s > t - tol)     Return true if s is greater than
00050 *                                            or equal to t
00051 *  EQ_is_gt(s, t, tol)     (s > t + tol)     Return true if s is greater than t
00052 *  EQ_is_le(s, t, tol)     (s < t + tol)     Return true if s is less than or
00053 *                                            equal to t
00054 *  EQ_is_lt(s, t, tol)     (s < t - tol)     Return true if s is less than t
00055 *  EQ_is_ne(s, t, tol)     (abs(s-t) > tol)  Return true if scalars are not
00056 *                                            equal
00057 *  EQ_is_2tol_eq(s, t, pos_tol, neg_tol)            Return true if s is inside
00058 *                          ((s >= t - neg_tol) &&   the range (t - neg_tol)
00059 *                           (s <= t + pos_tol))     through (t + pos_tol)
00060 *  EQ_is_2tol_ne(s, t, pos_tol, neg_tol)            Return true if s is outside
00061 *                          ((s < t - neg_tol) ||    the range (t - neg_tol)
00062 *                           (s > t + pos_tol))      through (t + pos_tol)
00063 *  EQ_is_zero(s, tol)      (abs(s) <= tol)   Return true if scalar is zero
00064 *  EQ_MAX_DBL              (1.0e19)          Maximum number valid for distance
00065 *                        operations.  EQ_MAX_DBL**2 is a 
00066 *                        valid value on all platforms.
00067 *  EQ_MIN_DBL              (1.0e-19)         Minimum number that can be used
00068 *                        as a divisor, EQ_MAX_DBL/EQ_MIN_DBL
00069 *                        is still a valid number on all
00070 *                        platforms.
00071 *  EQ_is_finite(s)         (abs(s) < EQ_MAX_DBL)  Return true if scalar is
00072 *                                            finite on all platforms.
00073 */
00074 
00075 #ifndef EQ_H_INCLUDED
00076 #define EQ_H_INCLUDED
00077 
00078 #include <math.h>
00079 #include <libugmath_exports.h>
00080 
00081 #define EQ_TOL_NUMBER           (EQ_ask_number_tolerance())
00082 #define EQ_TOL_LENGTH           (EQ_ask_length_tolerance())
00083 #define EQ_TOL_LENGTH_SQ        (EQ_ask_length_squared_tolerance())
00084 #define EQ_MAX_DBL              (1.0e19)
00085 #define EQ_MIN_DBL              (1.0e-19)
00086 
00087 #define EQ_ask_systol           (1.0e-10)
00088 
00089 #ifdef __lint
00090 
00091 extern logical EQ_is_equal ( double s , double t , double tol );
00092 extern logical EQ_is_eq ( double s, double t, double tol );
00093 extern logical EQ_is_ge ( double s , double t , double tol );
00094 extern logical EQ_is_gt ( double s , double t , double tol );
00095 extern logical EQ_is_le ( double s , double t , double tol );
00096 extern logical EQ_is_lt ( double s , double t , double tol );
00097 extern logical EQ_is_ne ( double s, double t, double tol );
00098 extern logical EQ_is_2tol_eq ( double s, double t,
00099                                double pos_tol, double neg_tol );
00100 extern logical EQ_is_2tol_ne ( double s, double t,
00101                                double pos_tol, double neg_tol );
00102 extern logical EQ_is_zero ( double s , double tol );
00103 extern logical EQ_is_finite ( double s );
00104 
00105 #else
00106 
00107 #define EQ_is_equal(s, t, tol)  (fabs ((s) - (t)) <= (tol))
00108 #define EQ_is_eq(s, t, tol)     (EQ_is_equal( s, t, tol ))
00109 #define EQ_is_ge(s, t, tol)     ((s) > ((t) - (tol)))
00110 #define EQ_is_gt(s, t, tol)     ((s) > ((t) + (tol)))
00111 #define EQ_is_le(s, t, tol)     ((s) < ((t) + (tol)))
00112 #define EQ_is_lt(s, t, tol)     ((s) < ((t) - (tol)))
00113 #define EQ_is_ne(s, t, tol)     (! EQ_is_equal(s, t, tol))
00114 #define EQ_is_2tol_eq(s, t, pos_tol, neg_tol)               \
00115                                 (EQ_is_ge(s, t, neg_tol) && \
00116                                  EQ_is_le(s, t, pos_tol))
00117 #define EQ_is_2tol_ne(s, t, pos_tol, neg_tol)                             \
00118                                 (! EQ_is_2tol_eq(s, t, pos_tol, neg_tol))
00119 #define EQ_is_zero(s, tol)      (fabs ((s)) <= (tol))
00120 #define EQ_is_finite(s)         (fabs ((s)) < EQ_MAX_DBL)
00121 
00122 #endif
00123 
00124 /*
00125 *   Proto-types for the part specific tolerance values
00126 */
00127 extern UGMATHEXPORT double EQ_ask_number_tolerance (void);
00128 extern UGMATHEXPORT double EQ_ask_length_tolerance (void);
00129 extern UGMATHEXPORT double EQ_ask_length_squared_tolerance (void);
00130 
00131 #undef EXPORTLIBRARY
00132 
00133 #endif  /* EQ_H_INCLUDED */