| 1 | /* Prototype declarations for complex math functions; |
|---|
| 2 | helper file for <complex.h>. |
|---|
| 3 | Copyright (C) 1997, 1998, 2001 Free Software Foundation, Inc. |
|---|
| 4 | This file is part of the GNU C Library. |
|---|
| 5 | |
|---|
| 6 | The GNU C Library is free software; you can redistribute it and/or |
|---|
| 7 | modify it under the terms of the GNU Lesser General Public |
|---|
| 8 | License as published by the Free Software Foundation; either |
|---|
| 9 | version 2.1 of the License, or (at your option) any later version. |
|---|
| 10 | |
|---|
| 11 | The GNU C Library is distributed in the hope that it will be useful, |
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 14 | Lesser General Public License for more details. |
|---|
| 15 | |
|---|
| 16 | You should have received a copy of the GNU Lesser General Public |
|---|
| 17 | License along with the GNU C Library; if not, write to the Free |
|---|
| 18 | Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|---|
| 19 | 02111-1307 USA. */ |
|---|
| 20 | |
|---|
| 21 | /* NOTE: Because of the special way this file is used by <complex.h>, this |
|---|
| 22 | file must NOT be protected from multiple inclusion as header files |
|---|
| 23 | usually are. |
|---|
| 24 | |
|---|
| 25 | This file provides prototype declarations for the math functions. |
|---|
| 26 | Most functions are declared using the macro: |
|---|
| 27 | |
|---|
| 28 | __MATHCALL (NAME, (ARGS...)); |
|---|
| 29 | |
|---|
| 30 | This means there is a function `NAME' returning `double' and a function |
|---|
| 31 | `NAMEf' returning `float'. Each place `_Mdouble_' appears in the |
|---|
| 32 | prototype, that is actually `double' in the prototype for `NAME' and |
|---|
| 33 | `float' in the prototype for `NAMEf'. Reentrant variant functions are |
|---|
| 34 | called `NAME_r' and `NAMEf_r'. |
|---|
| 35 | |
|---|
| 36 | Functions returning other types like `int' are declared using the macro: |
|---|
| 37 | |
|---|
| 38 | __MATHDECL (TYPE, NAME, (ARGS...)); |
|---|
| 39 | |
|---|
| 40 | This is just like __MATHCALL but for a function returning `TYPE' |
|---|
| 41 | instead of `_Mdouble_'. In all of these cases, there is still |
|---|
| 42 | both a `NAME' and a `NAMEf' that takes `float' arguments. */ |
|---|
| 43 | |
|---|
| 44 | #ifndef _COMPLEX_H |
|---|
| 45 | #error "Never use <bits/cmathcalls.h> directly; include <complex.h> instead." |
|---|
| 46 | #endif |
|---|
| 47 | |
|---|
| 48 | #define _Mdouble_complex_ _Mdouble_ _Complex |
|---|
| 49 | |
|---|
| 50 | |
|---|
| 51 | /* Trigonometric functions. */ |
|---|
| 52 | |
|---|
| 53 | /* Arc cosine of Z. */ |
|---|
| 54 | __MATHCALL (cacos, (_Mdouble_complex_ __z)); |
|---|
| 55 | /* Arc sine of Z. */ |
|---|
| 56 | __MATHCALL (casin, (_Mdouble_complex_ __z)); |
|---|
| 57 | /* Arc tangent of Z. */ |
|---|
| 58 | __MATHCALL (catan, (_Mdouble_complex_ __z)); |
|---|
| 59 | |
|---|
| 60 | /* Cosine of Z. */ |
|---|
| 61 | __MATHCALL (ccos, (_Mdouble_complex_ __z)); |
|---|
| 62 | /* Sine of Z. */ |
|---|
| 63 | __MATHCALL (csin, (_Mdouble_complex_ __z)); |
|---|
| 64 | /* Tangent of Z. */ |
|---|
| 65 | __MATHCALL (ctan, (_Mdouble_complex_ __z)); |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | /* Hyperbolic functions. */ |
|---|
| 69 | |
|---|
| 70 | /* Hyperbolic arc cosine of Z. */ |
|---|
| 71 | __MATHCALL (cacosh, (_Mdouble_complex_ __z)); |
|---|
| 72 | /* Hyperbolic arc sine of Z. */ |
|---|
| 73 | __MATHCALL (casinh, (_Mdouble_complex_ __z)); |
|---|
| 74 | /* Hyperbolic arc tangent of Z. */ |
|---|
| 75 | __MATHCALL (catanh, (_Mdouble_complex_ __z)); |
|---|
| 76 | |
|---|
| 77 | /* Hyperbolic cosine of Z. */ |
|---|
| 78 | __MATHCALL (ccosh, (_Mdouble_complex_ __z)); |
|---|
| 79 | /* Hyperbolic sine of Z. */ |
|---|
| 80 | __MATHCALL (csinh, (_Mdouble_complex_ __z)); |
|---|
| 81 | /* Hyperbolic tangent of Z. */ |
|---|
| 82 | __MATHCALL (ctanh, (_Mdouble_complex_ __z)); |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | /* Exponential and logarithmic functions. */ |
|---|
| 86 | |
|---|
| 87 | /* Exponential function of Z. */ |
|---|
| 88 | __MATHCALL (cexp, (_Mdouble_complex_ __z)); |
|---|
| 89 | |
|---|
| 90 | /* Natural logarithm of Z. */ |
|---|
| 91 | __MATHCALL (clog, (_Mdouble_complex_ __z)); |
|---|
| 92 | |
|---|
| 93 | #ifdef __USE_GNU |
|---|
| 94 | /* The base 10 logarithm is not defined by the standard but to implement |
|---|
| 95 | the standard C++ library it is handy. */ |
|---|
| 96 | __MATHCALL (clog10, (_Mdouble_complex_ __z)); |
|---|
| 97 | #endif |
|---|
| 98 | |
|---|
| 99 | /* Power functions. */ |
|---|
| 100 | |
|---|
| 101 | /* Return X to the Y power. */ |
|---|
| 102 | __MATHCALL (cpow, (_Mdouble_complex_ __x, _Mdouble_complex_ __y)); |
|---|
| 103 | |
|---|
| 104 | /* Return the square root of Z. */ |
|---|
| 105 | __MATHCALL (csqrt, (_Mdouble_complex_ __z)); |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | /* Absolute value, conjugates, and projection. */ |
|---|
| 109 | |
|---|
| 110 | /* Absolute value of Z. */ |
|---|
| 111 | __MATHDECL (_Mdouble_,cabs, (_Mdouble_complex_ __z)); |
|---|
| 112 | |
|---|
| 113 | /* Argument value of Z. */ |
|---|
| 114 | __MATHDECL (_Mdouble_,carg, (_Mdouble_complex_ __z)); |
|---|
| 115 | |
|---|
| 116 | /* Complex conjugate of Z. */ |
|---|
| 117 | __MATHCALL (conj, (_Mdouble_complex_ __z)); |
|---|
| 118 | |
|---|
| 119 | /* Projection of Z onto the Riemann sphere. */ |
|---|
| 120 | __MATHCALL (cproj, (_Mdouble_complex_ __z)); |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | /* Decomposing complex values. */ |
|---|
| 124 | |
|---|
| 125 | /* Imaginary part of Z. */ |
|---|
| 126 | __MATHDECL (_Mdouble_,cimag, (_Mdouble_complex_ __z)); |
|---|
| 127 | |
|---|
| 128 | /* Real part of Z. */ |
|---|
| 129 | __MATHDECL (_Mdouble_,creal, (_Mdouble_complex_ __z)); |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | /* Now some optimized versions. GCC has handy notations for these |
|---|
| 133 | functions. Recent GCC handles these as builtin functions so does |
|---|
| 134 | not need inlines. */ |
|---|
| 135 | #if defined __GNUC__ && !__GNUC_PREREQ (2, 97) && defined __OPTIMIZE__ |
|---|
| 136 | |
|---|
| 137 | /* Imaginary part of Z. */ |
|---|
| 138 | extern __inline _Mdouble_ |
|---|
| 139 | __MATH_PRECNAME(cimag) (_Mdouble_complex_ __z) __THROW |
|---|
| 140 | { |
|---|
| 141 | return __imag__ __z; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | /* Real part of Z. */ |
|---|
| 145 | extern __inline _Mdouble_ |
|---|
| 146 | __MATH_PRECNAME(creal) (_Mdouble_complex_ __z) __THROW |
|---|
| 147 | { |
|---|
| 148 | return __real__ __z; |
|---|
| 149 | } |
|---|
| 150 | |
|---|
| 151 | /* Complex conjugate of Z. */ |
|---|
| 152 | extern __inline _Mdouble_complex_ |
|---|
| 153 | __MATH_PRECNAME(conj) (_Mdouble_complex_ __z) __THROW |
|---|
| 154 | { |
|---|
| 155 | return __extension__ ~__z; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | #endif |
|---|