home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / libc / math.h < prev    next >
Text File  |  1999-03-15  |  13KB  |  330 lines

  1. #if __IBMC__ || __IBMCPP__
  2. #pragma info( none )
  3. #ifndef __CHKHDR__
  4.    #pragma info( none )
  5. #endif
  6. #pragma info( restore )
  7. #endif
  8.  
  9. #ifndef __math_h
  10.    #define __math_h
  11.  
  12.    #ifdef __cplusplus
  13.       extern "C" {
  14.    #endif
  15.  
  16.    #ifndef  _LNK_CONV
  17.       #if __IBMC__ || __IBMCPP__ || defined(_OPTLINK_SUPPORTED)
  18.          #define _LNK_CONV   _Optlink
  19.       #else
  20.          #define _LNK_CONV
  21.       #endif
  22.    #endif
  23.  
  24.    #ifndef _IMPORT
  25.       #ifdef __IMPORTLIB__
  26.          #define _IMPORT _Import
  27.       #else
  28.          #define _IMPORT
  29.       #endif
  30.    #endif
  31.  
  32.    /********************************************************************/
  33.    /*  <math.h> header file                                            */
  34.    /*                                                                  */
  35.    /*  (C) Copyright IBM Corp. 1991, 1995.                             */
  36.    /*  - Licensed Material - Program-Property of IBM                   */
  37.    /*  - All rights reserved                                           */
  38.    /*                                                                  */
  39.    /********************************************************************/
  40.  
  41.    extern const double _infinity;
  42.    #define HUGE_VAL    _infinity
  43.  
  44.    /* function prototypes */
  45.  
  46.    #if __IBMC__ || __IBMCPP__
  47.       #ifdef __cplusplus
  48.          extern "builtin" double __fabs( double );
  49.          inline double _LNK_CONV fabs( double x ) { return __fabs( x ); }
  50.       #else
  51.          double _Builtin __fabs( double );
  52.          double _IMPORT _LNK_CONV fabs( double );
  53.          #define fabs( x ) __fabs( (x) )
  54.       #endif
  55.    #else
  56.       extern double _IMPORT _LNK_CONV fabs( double );
  57.    #endif
  58.  
  59.    extern double _IMPORT _LNK_CONV ceil( double );
  60.    extern double _IMPORT _LNK_CONV cosh( double );
  61.    extern double _IMPORT _LNK_CONV floor( double );
  62.    extern double _IMPORT _LNK_CONV fmod( double, double );
  63.    extern double _IMPORT _LNK_CONV frexp( double, int * );
  64.    extern double _IMPORT _LNK_CONV ldexp( double, int );
  65.    extern double _IMPORT _LNK_CONV modf( double, double * );
  66.    extern double _IMPORT _LNK_CONV pow( double, double );
  67.    extern double _IMPORT _LNK_CONV sinh( double );
  68.    extern double _IMPORT _LNK_CONV tanh( double );
  69.  
  70.    #if __THW_PPC__
  71.  
  72.       #if (__IBMC__ || __IBMCPP__) && __MATH__
  73.          #ifdef __cplusplus
  74.             extern "builtin" double __sin(double);
  75.             extern "builtin" double __cos(double);
  76.             extern "builtin" double __tan(double);
  77.             extern "builtin" double __atan(double);
  78.             extern "builtin" double __acos(double);
  79.             extern "builtin" double __asin(double);
  80.             extern "builtin" double __sqrt(double);
  81.  
  82.             extern "builtin" double __exp(double);
  83.             extern "builtin" double __log(double);
  84.             extern "builtin" double __log10(double);
  85.             extern "builtin" double __atan2(double, double);
  86.  
  87.             inline double acos(double __x) {return __acos(__x);}
  88.             inline double asin(double __x) {return __asin(__x);}
  89.             inline double atan(double __x) {return __atan(__x);}
  90.             inline double atan2(double __x, double __y) {return __atan2(__x,__y);}
  91.             inline double cos(double __x) {return __cos(__x);}
  92.             inline double exp(double __x) {return __exp(__x);}
  93.             inline double log(double __x) {return __log(__x);}
  94.             inline double log10(double __x) {return __log10(__x);}
  95.             inline double sin(double __x) {return __sin(__x);}
  96.             inline double sqrt(double __x) {return __sqrt(__x);}
  97.             inline double tan(double __x) {return __tan(__x);}
  98.          #else
  99.             extern double _Builtin __sin(double);
  100.             extern double _Builtin __cos(double);
  101.             extern double _Builtin __tan(double);
  102.             extern double _Builtin __atan(double);
  103.             extern double _Builtin __acos(double);
  104.             extern double _Builtin __asin(double);
  105.             extern double _Builtin __sqrt(double);
  106.  
  107.             extern double _Builtin __exp(double);
  108.             extern double _Builtin __log(double);
  109.             extern double _Builtin __log10(double);
  110.             extern double _Builtin __atan2(double, double);
  111.  
  112.             #define acos(__x)         __acos(__x)
  113.             #define asin(__x)         __asin(__x)
  114.             #define atan(__x)         __atan(__x)
  115.             #define atan2(__x,__y)    __atan2(__x,__y)
  116.             #define cos(__x)          __cos(__x)
  117.             #define exp(__x)          __exp(__x)
  118.             #define log(__x)          __log(__x)
  119.             #define log10(__x)        __log10(__x)
  120.             #define sin(__x)          __sin(__x)
  121.             #define sqrt(__x)         __sqrt(__x)
  122.             #define tan(__x)          __tan(__x)
  123.          #endif
  124.       #else
  125.          extern double _IMPORT sin(double);
  126.          extern double _IMPORT cos(double);
  127.          extern double _IMPORT tan(double);
  128.          extern double _IMPORT atan(double);
  129.          extern double _IMPORT acos(double);
  130.          extern double _IMPORT asin(double);
  131.          extern double _IMPORT sqrt(double);
  132.  
  133.          extern double _IMPORT exp(double);
  134.          extern double _IMPORT log(double);
  135.          extern double _IMPORT log10(double);
  136.          extern double _IMPORT atan2(double, double);
  137.       #endif
  138.  
  139.    #else /* __THW_INTEL__ */
  140.  
  141.       double _IMPORT _LNK_CONV atan2( double, double );
  142.       double _IMPORT _LNK_CONV exp( double );
  143.       double _IMPORT _LNK_CONV log( double );
  144.       double _IMPORT _LNK_CONV log10( double );
  145.  
  146.       #if (__IBMC__ || __IBMCPP__) && defined( _FP_INLINE )
  147.          #ifdef __cplusplus
  148.             extern "builtin" double __fsin ( double );
  149.             extern "builtin" double __fcos ( double );
  150.             extern "builtin" double __fptan ( double );
  151.             extern "builtin" double __fpatan ( double );
  152.             extern "builtin" double __facos ( double );
  153.             extern "builtin" double __fasin ( double );
  154.             extern "builtin" double __fsqrt ( double );
  155.  
  156.             inline double _LNK_CONV sin ( double x ) { return __fsin  ( x ); }
  157.             inline double _LNK_CONV cos ( double x ) { return __fcos  ( x ); }
  158.             inline double _LNK_CONV tan ( double x ) { return __fptan ( x ); }
  159.             inline double _LNK_CONV atan( double x ) { return __fpatan( x ); }
  160.             inline double _LNK_CONV acos( double x ) { return __facos ( x ); }
  161.             inline double _LNK_CONV asin( double x ) { return __fasin ( x ); }
  162.             inline double _LNK_CONV sqrt( double x ) { return __fsqrt ( x ); }
  163.          #else
  164.             extern double _Builtin __fsin ( double );
  165.             extern double _Builtin __fcos ( double );
  166.             extern double _Builtin __fptan ( double );
  167.             extern double _Builtin __fpatan ( double );
  168.             extern double _Builtin __facos ( double );
  169.             extern double _Builtin __fasin ( double );
  170.             extern double _Builtin __fsqrt ( double );
  171.  
  172.             #define sin( x )       __fsin( (x) )
  173.             #define cos( x )       __fcos( (x) )
  174.             #define tan( x )       __fptan( (x) )
  175.             #define atan( x )      __fpatan( (x) )
  176.             #define acos( x )      __facos( (x) )
  177.             #define asin( x )      __fasin( (x) )
  178.             #define sqrt( x )      __fsqrt( (x) )
  179.          #endif
  180.       #else
  181.          extern double _IMPORT _LNK_CONV asin( double );
  182.          extern double _IMPORT _LNK_CONV acos( double );
  183.          extern double _IMPORT _LNK_CONV atan( double );
  184.          extern double _IMPORT _LNK_CONV sin( double );
  185.          extern double _IMPORT _LNK_CONV cos( double );
  186.          extern double _IMPORT _LNK_CONV tan( double );
  187.          extern double _IMPORT _LNK_CONV sqrt( double );
  188.       #endif
  189.  
  190.    #endif
  191.  
  192.    #ifndef __ANSI__
  193.       extern double _IMPORT _LNK_CONV _erf( double );
  194.       extern double _IMPORT _LNK_CONV _erfc( double );
  195.       extern double _IMPORT _LNK_CONV _gamma( double );
  196.       extern double _IMPORT _LNK_CONV _hypot( double, double );
  197.       extern double _IMPORT _LNK_CONV _j0( double );
  198.       extern double _IMPORT _LNK_CONV _j1( double );
  199.       extern double _IMPORT _LNK_CONV _jn( int, double );
  200.       extern double _IMPORT _LNK_CONV _y0( double );
  201.       extern double _IMPORT _LNK_CONV _y1( double );
  202.       extern double _IMPORT _LNK_CONV _yn( int, double );
  203.       extern double _IMPORT _LNK_CONV erf( double );
  204.       extern double _IMPORT _LNK_CONV erfc( double );
  205.       extern double _IMPORT _LNK_CONV gamma( double );
  206.       extern double _IMPORT _LNK_CONV hypot( double, double );
  207.       extern double _IMPORT _LNK_CONV j0( double );
  208.       extern double _IMPORT _LNK_CONV j1( double );
  209.       extern double _IMPORT _LNK_CONV jn( int, double );
  210.       extern double _IMPORT _LNK_CONV y0( double );
  211.       extern double _IMPORT _LNK_CONV y1( double );
  212.       extern double _IMPORT _LNK_CONV yn( int, double );
  213.       #if __THW_PPC__
  214.          extern int _ExtendedtoLD( __unaligned long double *ldptr );
  215.          extern int _LDtoExtended( __unaligned long double *ldptr );
  216.       #endif
  217.  
  218.       #if __IBMC__ || __IBMCPP__
  219.          #if __WINDOWS__ && __THW_INTEL__
  220.             #pragma map( erf, "?_erf" )
  221.             #pragma map( erfc, "?_erfc" )
  222.             #pragma map( gamma, "?_gamma" )
  223.             #pragma map( hypot, "?_hypot" )
  224.             #pragma map( j0, "?_j0" )
  225.             #pragma map( j1, "?_j1" )
  226.             #pragma map( jn, "?_jn" )
  227.             #pragma map( y0, "?_y0" )
  228.             #pragma map( y1, "?_y1" )
  229.             #pragma map( yn, "?_yn" )
  230.          #else
  231.             #pragma map( erf, "_erf" )
  232.             #pragma map( erfc, "_erfc" )
  233.             #pragma map( gamma, "_gamma" )
  234.             #pragma map( hypot, "_hypot" )
  235.             #pragma map( j0, "_j0" )
  236.             #pragma map( j1, "_j1" )
  237.             #pragma map( jn, "_jn" )
  238.             #pragma map( y0, "_y0" )
  239.             #pragma map( y1, "_y1" )
  240.             #pragma map( yn, "_yn" )
  241.          #endif
  242.       #else
  243.          #define erf _erf
  244.          #define erfc _erfc
  245.          #define gamma _gamma
  246.          #define hypot _hypot
  247.          #define j0 _j0
  248.          #define j1 _j1
  249.          #define jn _jn
  250.          #define y0 _y0
  251.          #define y1 _y1
  252.          #define yn _yn
  253.       #endif
  254.  
  255.       #ifndef __SAA_L2__
  256.          extern const long double _LHUGE_VAL;
  257.          #define _LHUGE _LHUGE_VAL
  258.       #endif
  259.  
  260.       #if defined(__EXTENDED__)
  261.  
  262.          #define HUGE   HUGE_VAL
  263.  
  264.          #define DOMAIN           1       /* argument domain error */
  265.          #define SING             2       /* argument singularity */
  266.          #define OVERFLOW         3       /* overflow range error */
  267.          #define UNDERFLOW        4       /* underflow range error */
  268.          #define TLOSS            5       /* total loss of precision */
  269.          #define PLOSS            6       /* partial loss of precision */
  270.          #define UNKNOWN          7       /* unknown error probably caused by */
  271.                                           /* changing the 80387 control word */
  272.  
  273.          #if (!defined(__cplusplus) || defined(__C_complex))
  274.             struct complex
  275.                {
  276.                double x,y;             /* real and imaginary parts */
  277.                };
  278.  
  279.             double      _IMPORT _LNK_CONV _cabs( struct complex );
  280.          #endif
  281.  
  282.          #define _cabs( z ) _hypot( (z).x, (z).y )
  283.          #define cabs( a ) _cabs( a )
  284.  
  285.          struct exception
  286.             {
  287.             int type;               /* exception type - see below */
  288.             char *name;             /* name of function where error occured */
  289.             double arg1;            /* first argument to function */
  290.             double arg2;            /* second argument (if any) to function */
  291.             double retval;          /* value to be returned by function */
  292.             };
  293.  
  294.          /* _matherr is defined by the user */
  295.  
  296.          int _matherr( struct exception * );
  297.          int  matherr( struct exception * );
  298.  
  299.          #if __IBMC__ || __IBMCPP__
  300.             #if __WINDOWS__ && __THW_INTEL__
  301.                #pragma map( matherr, "?_matherr" )
  302.             #else
  303.                #pragma map( matherr, "_matherr" )
  304.             #endif
  305.          #else
  306.             #define matherr _matherr
  307.          #endif
  308.  
  309.          long double _LNK_CONV _atold( const char * );
  310.  
  311.       #endif
  312.  
  313.    #endif
  314.  
  315.    #ifdef __cplusplus
  316.       }
  317.    #endif
  318.  
  319. #endif
  320.  
  321. #if __IBMC__ || __IBMCPP__
  322. #pragma info( none )
  323. #ifndef __CHKHDR__
  324.    #pragma info( restore )
  325. #endif
  326. #pragma info( restore )
  327. #endif
  328.  
  329. 
  330.