fd8ed86e81bbc8554f28399864fe769750613373
[platform/upstream/glibc.git] / math / mathcalls.h
1 /* Prototype declarations for math functions; helper file for <math.h>.
2    Copyright (C) 1996, 1997 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Library General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Library General Public License for more details.
14
15    You should have received a copy of the GNU Library General Public
16    License along with the GNU C Library; see the file COPYING.LIB.  If not,
17    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18    Boston, MA 02111-1307, USA.  */
19
20 /* NOTE: Because of the special way this file is used by <math.h>, this
21    file must NOT be protected from multiple inclusion as header files
22    usually are.
23
24    This file provides prototype declarations for the math functions.
25    Most functions are declared using the macro:
26
27    __MATHCALL (NAME,[_r], (ARGS...));
28
29    This means there is a function `NAME' returning `double' and a function
30    `NAMEf' returning `float'.  Each place `_Mdouble_' appears in the
31    prototype, that is actually `double' in the prototype for `NAME' and
32    `float' in the prototype for `NAMEf'.  Reentrant variant functions are
33    called `NAME_r' and `NAMEf_r'.
34
35    Functions returning other types like `int' are declared using the macro:
36
37    __MATHDECL (TYPE, NAME,[_r], (ARGS...));
38
39    This is just like __MATHCALL but for a function returning `TYPE'
40    instead of `_Mdouble_'.  In all of these cases, there is still
41    both a `NAME' and a `NAMEf' that takes `float' arguments.  */
42
43 #ifndef _MATH_H
44  #error "Never include mathcalls.h directly; include <math.h> instead."
45 #endif
46
47
48 /* Trigonometric functions.  */
49
50 /* Arc cosine of X.  */
51 __MATHCALL (acos,, (_Mdouble_ __x));
52 /* Arc sine of X.  */
53 __MATHCALL (asin,, (_Mdouble_ __x));
54 /* Arc tangent of X.  */
55 __MATHCALL (atan,, (_Mdouble_ __x));
56 /* Arc tangent of Y/X.  */
57 __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
58
59 /* Cosine of X.  */
60 __MATHCALL (cos,, (_Mdouble_ __x));
61 /* Sine of X.  */
62 __MATHCALL (sin,, (_Mdouble_ __x));
63 /* Tangent of X.  */
64 __MATHCALL (tan,, (_Mdouble_ __x));
65
66
67 /* Hyperbolic functions.  */
68
69 /* Hyperbolic cosine of X.  */
70 __MATHCALL (cosh,, (_Mdouble_ __x));
71 /* Hyperbolic sine of X.  */
72 __MATHCALL (sinh,, (_Mdouble_ __x));
73 /* Hyperbolic tangent of X.  */
74 __MATHCALL (tanh,, (_Mdouble_ __x));
75
76 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
77 /* Hyperbolic arc cosine of X.  */
78 __MATHCALL (acosh,, (_Mdouble_ __x));
79 /* Hyperbolic arc sine of X.  */
80 __MATHCALL (asinh,, (_Mdouble_ __x));
81 /* Hyperbolic arc tangent of X.  */
82 __MATHCALL (atanh,, (_Mdouble_ __x));
83 #endif
84
85 /* Exponential and logarithmic functions.  */
86
87 /* Exponential function of X.  */
88 __MATHCALL (exp,, (_Mdouble_ __x));
89
90 /* Break VALUE into a normalized fraction and an integral power of 2.  */
91 __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
92
93 /* X times (two to the EXP power).  */
94 __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
95
96 /* Natural logarithm of X.  */
97 __MATHCALL (log,, (_Mdouble_ __x));
98
99 /* Base-ten logarithm of X.  */
100 __MATHCALL (log10,, (_Mdouble_ __x));
101
102 /* Break VALUE into integral and fractional parts.  */
103 __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
104
105 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
106 /* Return exp(X) - 1.  */
107 __MATHCALL (expm1,, (_Mdouble_ __x));
108
109 /* Return log(1 + X).  */
110 __MATHCALL (log1p,, (_Mdouble_ __x));
111
112 /* Return the base 2 signed integral exponent of X.  */
113 __MATHCALL (logb,, (_Mdouble_ __x));
114 #endif
115
116 #ifdef __USE_ISOC9X
117 /* Compute base-2 exponential of X.  */
118 __MATHCALL (exp2,, (_Mdouble_ __x));
119
120 /* Compute base-2 logarithm of X.  */
121 __MATHCALL (log2,, (_Mdouble_ __x));
122 #endif
123
124
125 /* Power functions.  */
126
127 /* Return X to the Y power.  */
128 __MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
129
130 /* Return the square root of X.  */
131 __MATHCALL (sqrt,, (_Mdouble_ __x));
132
133 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
134 /* Return `sqrt(X*X + Y*Y)'.  */
135 __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
136 #endif
137
138 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
139 /* Return the cube root of X.  */
140 __MATHCALL (cbrt,, (_Mdouble_ __x));
141 #endif
142
143
144 /* Nearest integer, absolute value, and remainder functions.  */
145
146 /* Smallest integral value not less than X.  */
147 __MATHCALL (ceil,, (_Mdouble_ __x));
148
149 /* Absolute value of X.  */
150 __MATHCALL (fabs,, (_Mdouble_ __x));
151
152 /* Largest integer not greater than X.  */
153 __MATHCALL (floor,, (_Mdouble_ __x));
154
155 /* Floating-point modulo remainder of X/Y.  */
156 __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
157
158
159 #ifdef __USE_MISC
160 /* Return 0 if VALUE is finite or NaN, +1 if it
161    is +Infinity, -1 if it is -Infinity.  */
162 __MATHDECL (int,isinf,, (_Mdouble_ __value));
163
164 /* Return nonzero if VALUE is finite and not NaN.  */
165 __MATHDECL (int,finite,, (_Mdouble_ __value));
166
167 /* Deal with an infinite or NaN result.
168    If ERROR is ERANGE, result is +Inf;
169    if ERROR is - ERANGE, result is -Inf;
170    otherwise result is NaN.
171    This will set `errno' to either ERANGE or EDOM,
172    and may return an infinity or NaN, or may do something else.  */
173 __MATHCALL (infnan,, (int __error));
174
175 /* Return X times (2 to the Nth power).  */
176 __MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
177
178 /* Return the remainder of X/Y.  */
179 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
180
181 struct __MATH_PRECNAME(__cabs_complex,)
182 {
183   _Mdouble_ x, y;
184 };
185
186 /* Return `sqrt(X*X + Y*Y)'.  */
187 __MATHCALL (cabs,, (struct __MATH_PRECNAME(__cabs_complex,)));
188
189
190 /* Return the fractional part of X after dividing out `ilogb (X)'.  */
191 __MATHCALL (significand,, (_Mdouble_ __x));
192 #endif /* Use misc.  */
193
194 #if defined __USE_MISC || defined __USE_ISOC9X
195 /* Return X with its signed changed to Y's.  */
196 __MATHCALL (copysign,, (_Mdouble_ __x, _Mdouble_ __y));
197 #endif
198
199 #ifdef __USE_ISOC9X
200 /* Return representation of NaN for double type.  */
201 __MATHCALL (nan,, (__const char *__tagb));
202 #endif
203
204
205 #if defined __USE_MISC || defined __USE_XOPEN
206 /* Return nonzero if VALUE is not a number.  */
207 __MATHDECL (int,isnan,, (_Mdouble_ __value));
208
209 /* Return the binary exponent of X, which must be nonzero.  */
210 __MATHDECL (int,ilogb,, (_Mdouble_ __x));
211
212 /* Bessel functions.  */
213 __MATHCALL (j0,, (_Mdouble_));
214 __MATHCALL (j1,, (_Mdouble_));
215 __MATHCALL (jn,, (int, _Mdouble_));
216 __MATHCALL (y0,, (_Mdouble_));
217 __MATHCALL (y1,, (_Mdouble_));
218 __MATHCALL (yn,, (int, _Mdouble_));
219 #endif
220
221
222 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC9X
223 /* Error, gamma, and Bessel functions.  */
224 __MATHCALL (erf,, (_Mdouble_));
225 __MATHCALL (erfc,, (_Mdouble_));
226 __MATHCALL (gamma,, (_Mdouble_));
227 __MATHCALL (lgamma,, (_Mdouble_));
228
229 /* This variable is used by `gamma' and `lgamma'.  */
230 extern int signgam;
231
232 #ifdef __USE_MISC
233 /* Reentrant versions of gamma and lgamma.  Those functions use the global
234    variable `signgam'.  The reentrant versions instead take a pointer and
235    store the value through it.  */
236 __MATHCALL (gamma,_r, (_Mdouble_, int *));
237 __MATHCALL (lgamma,_r, (_Mdouble_, int *));
238 #endif
239
240 #endif /* Use misc or X/Open.  */
241
242
243 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC9X
244 /* Return the integer nearest X in the direction of the
245    prevailing rounding mode.  */
246 __MATHCALL (rint,, (_Mdouble_ __x));
247
248 /* Return X + epsilon if X < Y, X - epsilon if X > Y.  */
249 __MATHCALL (nextafter,, (_Mdouble_ __x, _Mdouble_ __y));
250
251 /* Return the remainder of integer divison X / Y with infinite precision.  */
252 __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
253 #endif
254
255 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
256 /* Return X times (2 to the Nth power).  */
257 __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
258 #endif
259
260 #ifdef __USE_ISOC9X
261 /* Round X to integral valuein floating-point format using current
262    rounding direction, but do not raise inexact exception.  */
263 __MATHCALL (nearbyint,, (_Mdouble_ __x));
264
265 /* Round X to nearest integral value, rounding halfway cases away from
266    zero.  */
267 __MATHCALL (round,, (_Mdouble_ __x));
268
269 /* Round X to the integral value in floating-point format nearest but
270    not larger in magnitude.  */
271 __MATHCALL (trunc,, (_Mdouble_ __x));
272
273 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
274    and magnitude congruent `mod 2^n' to the magnitude of the integral
275    quotient x/y, with n >= 3.  */
276 __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
277
278
279 /* Return positive difference between X and Y.  */
280 __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
281
282 /* Return minimum numeric value from X and Y.  */
283 __MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y));
284
285 /* Return maximum numeric value from X and Y.  */
286 __MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
287
288
289 /* Classify given number.  */
290 __MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value));
291
292 /* Test for negative number.  */
293 __MATHDECL_1 (int, __signbit,, (_Mdouble_ __value));
294 #endif /* Use ISO C 9X.  */