~ubuntu-branches/ubuntu/gutsy/avr-libc/gutsy

« back to all changes in this revision

Viewing changes to include/math.h

  • Committer: Bazaar Package Importer
  • Author(s): Hakan Ardo
  • Date: 2005-03-19 11:16:14 UTC
  • mfrom: (1.1.1 upstream) (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050319111614-4g01s2ftv5x5nxf3
Tags: 1:1.2.3-3
* Added build depends on netpbm
* Added build depends on tetex-extra

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2002, Michael Stumpf
 
2
 
 
3
   Portions of documentation Copyright (c) 1990 - 1994
 
4
   The Regents of the University of California.
 
5
 
 
6
   All rights reserved.
 
7
 
 
8
   Redistribution and use in source and binary forms, with or without
 
9
   modification, are permitted provided that the following conditions are met:
 
10
 
 
11
   * Redistributions of source code must retain the above copyright
 
12
     notice, this list of conditions and the following disclaimer.
 
13
 
 
14
   * Redistributions in binary form must reproduce the above copyright
 
15
     notice, this list of conditions and the following disclaimer in
 
16
     the documentation and/or other materials provided with the
 
17
     distribution.
 
18
 
 
19
   * Neither the name of the copyright holders nor the names of
 
20
     contributors may be used to endorse or promote products derived
 
21
     from this software without specific prior written permission.
 
22
 
 
23
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 
24
  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
25
  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
26
  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 
27
  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
28
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
29
  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
30
  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
31
  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
32
  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
33
  POSSIBILITY OF SUCH DAMAGE. */
 
34
 
 
35
/* $Id: math.h,v 1.5 2004/11/10 20:07:12 arcanum Exp $ */
 
36
 
1
37
/*
2
38
   math.h - mathematical functions
3
39
 
12
48
#ifndef __MATH_H
13
49
#define __MATH_H
14
50
 
 
51
/** \defgroup avr_math Mathematics
 
52
    \code #include <math.h> \endcode
 
53
 
 
54
    This header file declares basic mathematics constants and
 
55
    functions.
 
56
 
 
57
    \note
 
58
    In order to access the functions delcared herein, it is usually
 
59
    also required to additionally link against the library \c libm.a.
 
60
    See also the related \ref faq_libm "FAQ entry".
 
61
*/
 
62
 
 
63
/**
 
64
   \ingroup avr_math
 
65
 
 
66
   The constant \c pi. */
15
67
#define M_PI 3.141592653589793238462643
 
68
 
 
69
/**
 
70
   \ingroup avr_math
 
71
 
 
72
   The square root of 2. */
16
73
#define M_SQRT2 1.4142135623730950488016887
17
74
 
 
75
#ifndef DOXYGEN
 
76
 
18
77
#ifndef __ATTR_CONST__
19
78
#define __ATTR_CONST__ __attribute__((__const__))
20
79
#endif
21
80
 
 
81
#endif /* !DOXYGEN */
 
82
 
22
83
#ifdef __cplusplus
23
84
extern "C" {
24
85
#endif
25
 
        
26
 
extern double cos(double) __ATTR_CONST__;
27
 
extern double fabs(double) __ATTR_CONST__;
 
86
 
 
87
  /**
 
88
     \ingroup avr_math
 
89
 
 
90
     The cos() function returns the cosine of \c x, measured in
 
91
     radians.
 
92
  */
 
93
extern double cos(double __x) __ATTR_CONST__;
 
94
 
 
95
  /**
 
96
     \ingroup avr_math
 
97
 
 
98
     The fabs() function computes the absolute value of a
 
99
     floating-point number \c x.
 
100
  */
 
101
extern double fabs(double __x) __ATTR_CONST__;
28
102
#if 0
29
103
/* fabs seems to be built in already */
30
104
extern inline double fabs( double __x )
34
108
    return __res;
35
109
  }
36
110
#endif
37
 
extern double fmod(double, double) __ATTR_CONST__;
38
 
extern double modf(double, double *);
39
 
extern double sin(double) __ATTR_CONST__;
40
 
extern double sqrt(double) __ATTR_CONST__;
41
 
extern double tan(double) __ATTR_CONST__;
42
 
extern double floor(double) __ATTR_CONST__;
43
 
extern double ceil(double) __ATTR_CONST__;
44
 
extern double frexp(double, int *);
45
 
extern double ldexp(double,int) __ATTR_CONST__;
46
 
extern double exp(double) __ATTR_CONST__;
47
 
extern double cosh(double) __ATTR_CONST__;
48
 
extern double sinh(double) __ATTR_CONST__;
49
 
extern double tanh(double) __ATTR_CONST__;
50
 
extern double acos(double) __ATTR_CONST__;
51
 
extern double asin(double) __ATTR_CONST__;
52
 
extern double atan(double) __ATTR_CONST__;
53
 
extern double atan2(double, double) __ATTR_CONST__;
54
 
extern double log(double) __ATTR_CONST__;
55
 
extern double log10(double) __ATTR_CONST__;
56
 
extern double pow(double, double) __ATTR_CONST__;
57
 
extern double strtod(const char *s, char **endptr);
58
 
 
59
 
/* non-standard functions */
60
 
extern double square(double) __ATTR_CONST__;
 
111
 
 
112
  /**
 
113
     \ingroup avr_math
 
114
 
 
115
     The function fmod() returns the floating-point
 
116
     remainder of <tt>x / y</tt>.
 
117
  */
 
118
extern double fmod(double __x, double __y) __ATTR_CONST__;
 
119
 
 
120
  /**
 
121
     \ingroup avr_math
 
122
 
 
123
     The modf() function breaks the argument \c value into integral and
 
124
     fractional parts, each of which has the same sign as the
 
125
     argument.  It stores the integral part as a double in the object
 
126
     pointed to by \c iptr.
 
127
 
 
128
     The modf() function returns the signed fractional part of \c value.
 
129
  */
 
130
extern double modf(double __value, double *__iptr);
 
131
 
 
132
  /**
 
133
     \ingroup avr_math
 
134
 
 
135
     The sin() function returns the sine of \c x, measured in
 
136
     radians.
 
137
  */
 
138
extern double sin(double __x) __ATTR_CONST__;
 
139
 
 
140
  /**
 
141
     \ingroup avr_math
 
142
 
 
143
     The sqrt() function returns the non-negative square root of \c x.
 
144
  */
 
145
extern double sqrt(double __x) __ATTR_CONST__;
 
146
 
 
147
  /**
 
148
     \ingroup avr_math
 
149
 
 
150
     The tan() function returns the tangent of \c x, measured in
 
151
     radians.
 
152
  */
 
153
extern double tan(double __x) __ATTR_CONST__;
 
154
 
 
155
  /**
 
156
     \ingroup avr_math
 
157
 
 
158
     The floor() function returns the largest integral value
 
159
     less than or equal to \c x, expressed as a floating-point number.
 
160
  */
 
161
extern double floor(double __x) __ATTR_CONST__;
 
162
 
 
163
  /**
 
164
     \ingroup avr_math
 
165
 
 
166
     The ceil() function returns the smallest integral value
 
167
     greater than or equal to \c x, expressed as a floating-point number.
 
168
  */
 
169
extern double ceil(double __x) __ATTR_CONST__;
 
170
 
 
171
  /**
 
172
     \ingroup avr_math
 
173
 
 
174
     The frexp() function breaks a floating-point number into a normalized
 
175
     fraction and an integral power of 2.  It stores the integer in the \c int
 
176
     object pointed to by \c exp.
 
177
 
 
178
     The frexp() function returns the value \c x, such that \c x is a double with
 
179
     magnitude in the interval [1/2, 1) or zero, and \c value equals \c x times 2
 
180
     raised to the power \c *exp.  If value is zero, both parts of the result are
 
181
     zero.
 
182
  */
 
183
extern double frexp(double __value, int *__exp);
 
184
 
 
185
  /**
 
186
     \ingroup avr_math
 
187
 
 
188
     The ldexp() function multiplies a floating-point number by an integral
 
189
     power of 2.
 
190
 
 
191
     The ldexp() function returns the value of \c x times 2 raised to the power
 
192
     \c exp.
 
193
 
 
194
     If the resultant value would cause an overflow, the global variable errno
 
195
     is set to ERANGE, and the value NaN is returned.
 
196
  */
 
197
extern double ldexp(double __x, int __exp) __ATTR_CONST__;
 
198
 
 
199
  /**
 
200
     \ingroup avr_math
 
201
 
 
202
     The exp() function returns the exponential value of \c x.
 
203
  */
 
204
extern double exp(double _x) __ATTR_CONST__;
 
205
 
 
206
  /**
 
207
     \ingroup avr_math
 
208
 
 
209
     The cosh() function returns the hyperbolic cosine of \c x.
 
210
  */
 
211
extern double cosh(double __x) __ATTR_CONST__;
 
212
 
 
213
  /**
 
214
     \ingroup avr_math
 
215
 
 
216
     The sinh() function returns the hyperbolic sine of \c x.
 
217
  */
 
218
extern double sinh(double __x) __ATTR_CONST__;
 
219
 
 
220
  /**
 
221
     \ingroup avr_math
 
222
 
 
223
     The tanh() function returns the hyperbolic tangent of \c x.
 
224
  */
 
225
extern double tanh(double __x) __ATTR_CONST__;
 
226
 
 
227
  /**
 
228
     \ingroup avr_math
 
229
 
 
230
     The acos() function computes the principal value of the
 
231
     arc cosine of \c x.  The returned value is in the range
 
232
     [0, pi] radians.
 
233
     A domain error occurs for arguments not in the range
 
234
     [-1, +1].
 
235
  */
 
236
extern double acos(double __x) __ATTR_CONST__;
 
237
 
 
238
  /**
 
239
     \ingroup avr_math
 
240
 
 
241
     The asin() function computes the principal value of the
 
242
     arc sine of \c x.  The returned value is in the range
 
243
     [0, pi] radians.
 
244
     A domain error occurs for arguments not in the range
 
245
     [-1, +1].
 
246
  */
 
247
extern double asin(double __x) __ATTR_CONST__;
 
248
 
 
249
  /**
 
250
     \ingroup avr_math
 
251
 
 
252
     The atan() function computes the principal value of the
 
253
     arc tangent of \c x.  The returned value is in the range
 
254
     [0, pi] radians.
 
255
     A domain error occurs for arguments not in the range
 
256
     [-1, +1].
 
257
  */
 
258
extern double atan(double __x) __ATTR_CONST__;
 
259
 
 
260
  /**
 
261
     \ingroup avr_math
 
262
     The atan2() function computes the principal value of the
 
263
     arc tangent of <tt>y / x</tt>, using the signs of both arguments
 
264
     to determine the quadrant of the return value.  The returned
 
265
     value is in the range [-pi, +pi] radians.
 
266
     If both \c x and \c y are zero, the global variable \c errno
 
267
     is set to \c EDOM.
 
268
  */
 
269
extern double atan2(double __y, double __x) __ATTR_CONST__;
 
270
 
 
271
  /**
 
272
     \ingroup avr_math
 
273
 
 
274
     The log() function returns the natural logarithm of argument \c x.
 
275
 
 
276
     If the argument is less than or equal 0, a domain error will occur.
 
277
   */
 
278
extern double log(double __x) __ATTR_CONST__;
 
279
 
 
280
  /**
 
281
     \ingroup avr_math
 
282
 
 
283
     The log() function returns the logarithm of argument \c x to base 10.
 
284
 
 
285
     If the argument is less than or equal 0, a domain error will occur.
 
286
   */
 
287
extern double log10(double __x) __ATTR_CONST__;
 
288
 
 
289
  /**
 
290
     \ingroup avr_math
 
291
 
 
292
     The function pow() returns the value of \c x to the exponent \c y.
 
293
  */
 
294
extern double pow(double __x, double __y) __ATTR_CONST__;
 
295
 
 
296
  /**
 
297
     \ingroup avr_math
 
298
 
 
299
     The function isnan() returns 1 if the argument \c x represents a
 
300
     "not-a-number" (NaN) object, otherwise 0.
 
301
  */
 
302
extern int isnan(double __x) __ATTR_CONST__;
 
303
 
 
304
  /**
 
305
     \ingroup avr_math
 
306
 
 
307
     The function isinf() returns 1 if the argument \c x is either
 
308
     positive or negative infinity, otherwise 0.
 
309
  */
 
310
extern int isinf(double __x) __ATTR_CONST__;
 
311
 
 
312
  /**
 
313
     \ingroup avr_math
 
314
 
 
315
     The function square() returns <tt>x * x</tt>.
 
316
 
 
317
     \note
 
318
     This function does not belong to the C standard definition.
 
319
  */
 
320
extern double square(double __x) __ATTR_CONST__;
 
321
  /**
 
322
     \ingroup avr_math
 
323
 
 
324
     The function inverse() returns <tt>1 / x</tt>.
 
325
 
 
326
     \note
 
327
     This function does not belong to the C standard definition.
 
328
  */
61
329
extern double inverse(double) __ATTR_CONST__;
62
330
 
63
331
#ifdef __cplusplus