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