/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72X src/bos/usr/include/complex.h 1.4.1.6                           */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2002,2021              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)75  1.4.1.6  src/bos/usr/include/complex.h, libm, bos72X, x2021_25A9 6/4/21 03:15:52 */ 

/*
 * COMPONENT_NAME: (INCSTD) Standard Include Files
 *
 * FUNCTIONS:
 *
 * ORIGINS: 27
 *
 * (C) COPYRIGHT International Business Machines Corp. 2002
 * All Rights Reserved
 * Licensed Materials - Property of IBM
 *
 * US Government Users Restricted Rights - Use, duplication or
 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
 */


#ifndef _H_COMPLEX
#define _H_COMPLEX	1

#include <standards.h>
#include <comp_macros.h>

#ifdef __cplusplus
extern "C" {
#endif


#define complex		_Complex

/* 
 * a constant expression of type const float _Complex with the
 * value of the imaginary unit. (a number i such that i**2 =-1).
 */
#if defined(__xlC__) && !defined(__clang__)
/* __I is provided by the AIX xlc C99 compiler.
 * WARNING: DO NOT USE __I DIRECTLY in an application. Always
 * use _Complex_I .
 */
#define _Complex_I	__I
#else
#define _Complex_I	(__extension__ 1.0iF)
#endif

/*
 * _Imaginary_I should be a constant expression of type
 * const float _Imaginary with the value of the imaginary unit.
 * This is optional in C99.
 * This is not supported in the AIX xlc C99 compiler.
 */

/* 
 * C99 requires this definition of the
 * very common variable "I", to use as a simpler way
 * to say _Complex_I. Mathematicians who would say
 * "3i" will now say in C "3 * I".
 */
#undef I
#define I _Complex_I

/* ISO C standard from 2011 onward */
#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201000L)) && !defined(__NO_XLC_COMPLEX_INIT) || defined(_ALL_SOURCE)
#define CMPLX(x,y)	((double)(x)+__I_ImaginaryOnly*(double)(y))
#define CMPLXF(x,y)	((float)(x)+__I_ImaginaryOnly*(float)(y))
#define CMPLXL(x,y)	((long double)(x)+__I_ImaginaryOnly*(long double)(y))
#endif


extern  double              _NOTHROW(cabs, (double complex));
extern  float               _NOTHROW(cabsf, (float complex));
extern  double complex      _NOTHROW(cacos, (double complex));
extern  float complex       _NOTHROW(cacosf, (float complex));
extern  double complex      _NOTHROW(cacosh, (double complex));
extern  float complex       _NOTHROW(cacoshf, (float complex));
extern  double              _NOTHROW(carg, (double complex));
extern  float               _NOTHROW(cargf, (float complex));
extern  double complex      _NOTHROW(casin, (double complex));
extern  float complex       _NOTHROW(casinf, (float complex));
extern  double complex      _NOTHROW(casinh, (double complex));
extern  float complex       _NOTHROW(casinhf, (float complex));
extern  double complex      _NOTHROW(catan, (double complex));
extern  float complex       _NOTHROW(catanf, (float complex));
extern  double complex      _NOTHROW(catanh, (double complex));
extern  float complex       _NOTHROW(catanhf, (float complex));
extern  double complex      _NOTHROW(ccos, (double complex));
extern  float complex       _NOTHROW(ccosf, (float complex));
extern  double complex      _NOTHROW(ccosh, (double complex));
extern  float complex       _NOTHROW(ccoshf, (float complex));
extern  double complex      _NOTHROW(cexp, (double complex));
extern  float complex       _NOTHROW(cexpf, (float complex));
extern  double              _NOTHROW(cimag, (double complex));
extern  float               _NOTHROW(cimagf, (float complex));
extern  double complex      _NOTHROW(__clog, (double complex));
extern  float complex       _NOTHROW(clogf, (float complex));
extern  double complex      _NOTHROW(conj, (double complex));
extern  float complex       _NOTHROW(conjf, (float complex));
extern  double complex      _NOTHROW(cpow, (double complex, double complex));
extern  float complex       _NOTHROW(cpowf, (float complex, float complex));
extern  double complex      _NOTHROW(cproj, (double complex));
extern  float complex       _NOTHROW(cprojf, (float complex));
extern  double              _NOTHROW(creal, (double complex));
extern  float               _NOTHROW(crealf, (float complex));
extern  double complex      _NOTHROW(csin, (double complex));
extern  float complex       _NOTHROW(csinf, (float complex));
extern  double complex      _NOTHROW(csinh, (double complex));
extern  float complex       _NOTHROW(csinhf, (float complex));
extern  double complex      _NOTHROW(csqrt, (double complex));
extern  float complex       _NOTHROW(csqrtf, (float complex));
extern  double complex      _NOTHROW(ctan, (double complex));
extern  float complex       _NOTHROW(ctanf, (float complex));
extern  double complex      _NOTHROW(ctanh, (double complex));
extern  float complex       _NOTHROW(ctanhf, (float complex));

/*
 * There are two forms of long double on AIX.  The default
 * form of long double is the same as a double - 64 bits.  There
 * is a 128-bit form available with some compilers.  If that compiler
 * defines __LONGDOUBLE128, then long doubles are 128-bit instead of
 * 64-bit.  Since the same library routine cannot be used for 128-bit
 * and 64-bit values, the 128-bit routines are renamed and macros are
 * used to manage the name spaces.  It is not necessarily the case that
 * all of the 128-bit versions are available, but the macros are defined
 * intentionally since the 64-bit versions can provide incorrect results
 * when long double values were expected.  If 64-bit versions are required
 * in 128-bit mode, then the code needs to invoke the double routines a
 * rather than the long double routines.
 */

#ifdef __LONGDOUBLE128
/* 64-bit long double routines */
extern  double         _NOTHROW(cabsl, (double complex));
extern  double complex _NOTHROW(cacoshl, (double complex));
extern  double complex _NOTHROW(cacosl, (double complex));
extern  double         _NOTHROW(cargl, (double complex));
extern  double complex _NOTHROW(casinhl, (double complex));
extern  double complex _NOTHROW(casinl, (double complex));
extern  double complex _NOTHROW(catanhl, (double complex));
extern  double complex _NOTHROW(catanl, (double complex));
extern  double complex _NOTHROW(ccoshl, (double complex));
extern  double complex _NOTHROW(ccosl, (double complex));
extern  double complex _NOTHROW(cexpl, (double complex));
extern  double         _NOTHROW(cimagl, (double complex));
extern  double complex _NOTHROW(clogl, (double complex));
extern  double complex _NOTHROW(conjl, (double complex));
extern  double complex _NOTHROW(cpowl, (double complex, double complex));
extern  double complex _NOTHROW(cprojl, (double complex));
extern  double         _NOTHROW(creall, (double complex));
extern  double complex _NOTHROW(csinhl, (double complex));
extern  double complex _NOTHROW(csinl, (double complex));
extern  double complex _NOTHROW(csqrtl, (double complex));
extern  double complex _NOTHROW(ctanhl, (double complex));
extern  double complex _NOTHROW(ctanl, (double complex));

/* 128-bit routines */
#define cabsl(__ldc1) __cabsl128(__ldc1)
#define cacoshl(__ldc1) __cacoshl128(__ldc1)
#define cacosl(__ldc1) __cacosl128(__ldc1)
#define cargl(__ldc1) __cargl128(__ldc1)
#define casinhl(__ldc1) __casinhl128(__ldc1)
#define casinl(__ldc1) __casinl128(__ldc1)
#define catanhl(__ldc1) __catanhl128(__ldc1)
#define catanl(__ldc1) __catanl128(__ldc1)
#define ccoshl(__ldc1) __ccoshl128(__ldc1)
#define ccosl(__ldc1) __ccosl128(__ldc1)
#define cexpl(__ldc1) __cexpl128(__ldc1)
#define cimagl(__ldc1) __cimagl128(__ldc1)
#define clogl(__ldc1) __clogl128(__ldc1)
#define conjl(__ldc1) __conjl128(__ldc1)
#define cpowl(__ldc1, __ldc2) __cpowl128(__ldc1, __ldc2)
#define cprojl(__ldc1) __cprojl128(__ldc1)
#define creall(__ldc1) __creall128(__ldc1)
#define csinhl(__ldc1) __csinhl128(__ldc1)
#define csinl(__ldc1) __csinl128(__ldc1)
#define csqrtl(__ldc1) __csqrtl128(__ldc1)
#define ctanhl(__ldc1) __ctanhl128(__ldc1)
#define ctanl(__ldc1) __ctanl128(__ldc1)


extern  long double         _NOTHROW(__cabsl128, (long double complex));
extern  long double complex _NOTHROW(__cacoshl128, (long double complex));
extern  long double complex _NOTHROW(__cacosl128, (long double complex));
extern  long double         _NOTHROW(__cargl128, (long double complex));
extern  long double complex _NOTHROW(__casinhl128, (long double complex));
extern  long double complex _NOTHROW(__casinl128, (long double complex));
extern  long double complex _NOTHROW(__catanhl128, (long double complex));
extern  long double complex _NOTHROW(__catanl128, (long double complex));
extern  long double complex _NOTHROW(__ccoshl128, (long double complex));
extern  long double complex _NOTHROW(__ccosl128, (long double complex));
extern  long double complex _NOTHROW(__cexpl128, (long double complex));
extern  long double         _NOTHROW(__cimagl128, (long double complex));
extern  long double complex _NOTHROW(__clogl128, (long double complex));
extern  long double complex _NOTHROW(__conjl128, (long double complex));
extern  long double complex _NOTHROW(__cpowl128, (long double complex, long double complex));
extern  long double complex _NOTHROW(__cprojl128, (long double complex));
extern  long double         _NOTHROW(__creall128, (long double complex));
extern  long double complex _NOTHROW(__csinhl128, (long double complex));
extern  long double complex _NOTHROW(__csinl128, (long double complex));
extern  long double complex _NOTHROW(__csqrtl128, (long double complex));
extern  long double complex _NOTHROW(__ctanhl128, (long double complex));
extern  long double complex _NOTHROW(__ctanl128, (long double complex));
#else
extern  long double         _NOTHROW(cabsl, (long double complex));
extern  long double complex _NOTHROW(cacoshl, (long double complex));
extern  long double complex _NOTHROW(cacosl, (long double complex));
extern  long double         _NOTHROW(cargl, (long double complex));
extern  long double complex _NOTHROW(casinhl, (long double complex));
extern  long double complex _NOTHROW(casinl, (long double complex));
extern  long double complex _NOTHROW(catanhl, (long double complex));
extern  long double complex _NOTHROW(catanl, (long double complex));
extern  long double complex _NOTHROW(ccoshl, (long double complex));
extern  long double complex _NOTHROW(ccosl, (long double complex));
extern  long double complex _NOTHROW(cexpl, (long double complex));
extern  long double         _NOTHROW(cimagl, (long double complex));
extern  long double complex _NOTHROW(clogl, (long double complex));
extern  long double complex _NOTHROW(conjl, (long double complex));
extern  long double complex _NOTHROW(cpowl, (long double complex, long double complex));
extern  long double complex _NOTHROW(cprojl, (long double complex));
extern  long double         _NOTHROW(creall, (long double complex));
extern  long double complex _NOTHROW(csinhl, (long double complex));
extern  long double complex _NOTHROW(csinl, (long double complex));
extern  long double complex _NOTHROW(csqrtl, (long double complex));
extern  long double complex _NOTHROW(ctanhl, (long double complex));
extern  long double complex _NOTHROW(ctanl, (long double complex));
#endif

#if (__xlC__ >= 0x800) && !defined(__clang__)

#ifdef __LONGDOUBLE128
   __extension__ extern long double _NOTHROW(__cabsl128, (long double _Complex)) __attribute__((__IBMBuiltin__));
#else
   __extension__ extern long double   _NOTHROW(cabsl, (long double _Complex))    __attribute__((__IBMBuiltin__));
#endif
   __extension__ extern float         _NOTHROW(cabsf, (float _Complex))          __attribute__((__IBMBuiltin__));
   __extension__ extern double        _NOTHROW(cabs, (double _Complex))          __attribute__((__IBMBuiltin__));
#endif 

#if (__IBMC__ || __IBMCPP__) && !defined(__ibmxl__)

    extern double complex _NOTHROW(clog, (double complex));
    #pragma map(clog, "__clog")             /* maps clog to __clog */

#elif defined(_LIBCALLNAME)
    extern double complex _NOTHROW(clog, (double complex)) _LIBCALLNAME("__clog");
#else
    static double complex _NOTHROW(clog, (double complex z))
    {
        return (__clog(z));
    }
#endif

#ifdef __cplusplus
}
#endif

#endif /* complex.h */