Tizen RT Libs&Environment
v1.0 D5
Main Page
Modules
Data Structures
Files
File List
Globals
math.h
Go to the documentation of this file.
1
/****************************************************************************
2
*
3
* Copyright 2016 Samsung Electronics All Rights Reserved.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing,
12
* software distributed under the License is distributed on an
13
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14
* either express or implied. See the License for the specific
15
* language governing permissions and limitations under the License.
16
*
17
****************************************************************************/
18
/****************************************************************************
19
*
20
* Copyright (C) 2009, 2012, 2014-2015 Gregory Nutt. All rights reserved.
21
* Author: Gregory Nutt <gnutt@nuttx.org>
22
*
23
* Redistribution and use in source and binary forms, with or without
24
* modification, are permitted provided that the following conditions
25
* are met:
26
*
27
* 1. Redistributions of source code must retain the above copyright
28
* notice, this list of conditions and the following disclaimer.
29
* 2. Redistributions in binary form must reproduce the above copyright
30
* notice, this list of conditions and the following disclaimer in
31
* the documentation and/or other materials provided with the
32
* distribution.
33
* 3. Neither the name NuttX nor the names of its contributors may be
34
* used to endorse or promote products derived from this software
35
* without specific prior written permission.
36
*
37
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
40
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
41
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
42
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
44
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
45
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
47
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
48
* POSSIBILITY OF SUCH DAMAGE.
49
*
50
****************************************************************************/
58
#ifndef __INCLUDE_MATH_H
61
#define __INCLUDE_MATH_H
62
63
/****************************************************************************
64
* Included Files
65
****************************************************************************/
66
67
#include <tinyara/config.h>
68
69
/* If CONFIG_ARCH_MATH_H is defined, then the top-level Makefile will copy
70
* this header file to include/math.h where it will become the system math.h
71
* header file. In this case, the architecture specific code must provide
72
* an arch/<architecture>/include/math.h file which will be included below:
73
*/
74
75
#ifdef CONFIG_ARCH_MATH_H
76
#include <arch/math.h>
77
78
/* If CONFIG_LIBM is enabled, then the math library at lib/math will be
79
* built. This library was taken from the math library developed for the
80
* Rhombus OS by Nick Johnson (https://github.com/nickbjohnson4224/rhombus).
81
* The port or the Rhombus math library was contributed by Darcy Gong.
82
*/
83
84
#elif defined(CONFIG_LIBM)
85
86
/****************************************************************************
87
* Copyright (C) 2009-2011 Nick Johnson <nickbjohnson4224 at gmail.com>
88
*
89
* Permission to use, copy, modify, and distribute this software for any
90
* purpose with or without fee is hereby granted, provided that the above
91
* copyright notice and this permission notice appear in all copies.
92
*
93
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
94
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
95
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
96
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
97
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
98
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
99
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
100
*
101
****************************************************************************/
102
103
/****************************************************************************
104
* Included Files
105
****************************************************************************/
106
107
#include <tinyara/config.h>
108
#include <tinyara/compiler.h>
109
110
/****************************************************************************
111
* Pre-processor Definitions
112
****************************************************************************/
113
114
/* General Constants ********************************************************/
115
116
#define INFINITY (1.0/0.0)
117
#define NAN (0.0/0.0)
118
#define HUGE_VAL INFINITY
119
120
#define isnan(x) ((x) != (x))
121
#define isinf(x) (((x) == INFINITY) || ((x) == -INFINITY))
122
#define isfinite(x) (!(isinf(x)) && (x != NAN))
123
124
/* Exponential and Logarithmic constants ************************************/
125
126
#define M_E 2.7182818284590452353602874713526625
127
#define M_SQRT2 1.4142135623730950488016887242096981
128
#define M_SQRT1_2 0.7071067811865475244008443621048490
129
#define M_LOG2E 1.4426950408889634073599246810018921
130
#define M_LOG10E 0.4342944819032518276511289189166051
131
#define M_LN2 0.6931471805599453094172321214581765
132
#define M_LN10 2.3025850929940456840179914546843642
133
134
/* Trigonometric Constants **************************************************/
135
136
#define M_PI 3.1415926535897932384626433832795029
137
#define M_PI_2 1.5707963267948966192313216916397514
138
#define M_PI_4 0.7853981633974483096156608458198757
139
#define M_1_PI 0.3183098861837906715377675267450287
140
#define M_2_PI 0.6366197723675813430755350534900574
141
#define M_2_SQRTPI 1.1283791670955125738961589031215452
142
143
/****************************************************************************
144
* Public Function Prototypes
145
****************************************************************************/
146
147
#if defined(__cplusplus)
148
extern
"C"
{
149
#endif
150
151
/* General Functions ******************************************************* */
156
float
ceilf(
float
x);
160
#ifdef CONFIG_HAVE_DOUBLE
161
double
ceil(
double
x);
162
#endif
163
166
#ifdef CONFIG_HAVE_LONG_DOUBLE
167
long
double
ceill(
long
double
x);
168
#endif
169
172
float
floorf(
float
x);
173
#ifdef CONFIG_HAVE_DOUBLE
174
182
double
floor
(
double
x);
183
#endif
184
188
#ifdef CONFIG_HAVE_LONG_DOUBLE
189
long
double
floorl(
long
double
x);
190
#endif
191
194
float
roundf(
float
x);
198
#ifdef CONFIG_HAVE_DOUBLE
199
double
round(
double
x);
200
#endif
201
204
#ifdef CONFIG_HAVE_LONG_DOUBLE
205
long
double
roundl(
long
double
x);
206
#endif
207
210
float
rintf(
float
x);
/* Not implemented */
214
#ifdef CONFIG_HAVE_DOUBLE
215
double
rint(
double
x);
216
#endif
217
220
#ifdef CONFIG_HAVE_LONG_DOUBLE
221
long
double
rintl(
long
double
x);
/* Not implemented */
222
#endif
223
226
float
fabsf(
float
x);
230
#ifdef CONFIG_HAVE_DOUBLE
231
236
double
fabs
(
double
x);
237
#endif
238
242
#ifdef CONFIG_HAVE_LONG_DOUBLE
243
long
double
fabsl(
long
double
x);
244
#endif
245
248
float
modff(
float
x,
float
*iptr);
252
#ifdef CONFIG_HAVE_DOUBLE
253
double
modf(
double
x,
double
*iptr);
254
#endif
255
258
#ifdef CONFIG_HAVE_LONG_DOUBLE
259
long
double
modfl(
long
double
x,
long
double
*iptr);
260
#endif
261
264
float
fmodf(
float
x,
float
div);
268
#ifdef CONFIG_HAVE_DOUBLE
269
double
fmod(
double
x,
double
div);
270
#endif
271
274
#ifdef CONFIG_HAVE_LONG_DOUBLE
275
long
double
fmodl(
long
double
x,
long
double
div);
276
#endif
277
278
/* Exponential and Logarithmic Functions *********************************** */
282
float
powf(
float
b,
float
e);
286
#ifdef CONFIG_HAVE_DOUBLE
287
292
double
pow
(
double
b,
double
e);
293
#endif
294
298
#ifdef CONFIG_HAVE_LONG_DOUBLE
299
long
double
powl(
long
double
b,
long
double
e);
300
#endif
301
304
float
expf(
float
x);
308
#define expm1f(x) (expf(x) - 1.0)
309
312
#ifdef CONFIG_HAVE_DOUBLE
313
double
exp(
double
x);
314
#define expm1(x) (exp(x) - 1.0)
315
#endif
316
319
#ifdef CONFIG_HAVE_LONG_DOUBLE
320
long
double
expl(
long
double
x);
321
#define expm1l(x) (expl(x) - 1.0)
322
#endif
323
326
float
logf(
float
x);
330
#ifdef CONFIG_HAVE_DOUBLE
331
double
log(
double
x);
332
#endif
333
336
#ifdef CONFIG_HAVE_LONG_DOUBLE
337
long
double
logl(
long
double
x);
338
#endif
339
342
float
log10f(
float
x);
346
#if CONFIG_HAVE_DOUBLE
347
double
log10(
double
x);
348
#endif
349
352
#ifdef CONFIG_HAVE_LONG_DOUBLE
353
long
double
log10l(
long
double
x);
354
#endif
355
358
float
log2f(
float
x);
362
#ifdef CONFIG_HAVE_DOUBLE
363
double
log2(
double
x);
364
#endif
365
368
#ifdef CONFIG_HAVE_LONG_DOUBLE
369
long
double
log2l(
long
double
x);
370
#endif
371
374
float
sqrtf(
float
x);
378
#ifdef CONFIG_HAVE_DOUBLE
379
double
sqrt(
double
x);
380
#endif
381
384
#ifdef CONFIG_HAVE_LONG_DOUBLE
385
long
double
sqrtl(
long
double
x);
386
#endif
387
390
float
ldexpf(
float
x,
int
n);
394
#ifdef CONFIG_HAVE_DOUBLE
395
double
ldexp(
double
x,
int
n);
396
#endif
397
400
#ifdef CONFIG_HAVE_LONG_DOUBLE
401
long
double
ldexpl(
long
double
x,
int
n);
402
#endif
403
406
float
frexpf(
float
x,
int
*exp);
410
#ifdef CONFIG_HAVE_DOUBLE
411
double
frexp(
double
x,
int
*exp);
412
#endif
413
416
#ifdef CONFIG_HAVE_LONG_DOUBLE
417
long
double
frexpl(
long
double
x,
int
*exp);
418
#endif
419
420
/* Trigonometric Functions ************************************************* */
424
float
sinf(
float
x);
428
#ifdef CONFIG_HAVE_DOUBLE
429
double
sin(
double
x);
430
#endif
431
434
#ifdef CONFIG_HAVE_LONG_DOUBLE
435
long
double
sinl(
long
double
x);
436
#endif
437
440
float
cosf(
float
x);
444
#ifdef CONFIG_HAVE_DOUBLE
445
double
cos(
double
x);
446
#endif
447
450
#ifdef CONFIG_HAVE_LONG_DOUBLE
451
long
double
cosl(
long
double
x);
452
#endif
453
456
float
tanf(
float
x);
460
#if CONFIG_HAVE_DOUBLE
461
double
tan(
double
x);
462
#endif
463
466
#ifdef CONFIG_HAVE_LONG_DOUBLE
467
long
double
tanl(
long
double
x);
468
#endif
469
472
float
asinf(
float
x);
476
#ifdef CONFIG_HAVE_DOUBLE
477
double
asin(
double
x);
478
#endif
479
482
#ifdef CONFIG_HAVE_LONG_DOUBLE
483
long
double
asinl(
long
double
x);
484
#endif
485
488
float
acosf(
float
x);
492
#if CONFIG_HAVE_DOUBLE
493
double
acos(
double
x);
494
#endif
495
498
#ifdef CONFIG_HAVE_LONG_DOUBLE
499
long
double
acosl(
long
double
x);
500
#endif
501
504
float
atanf(
float
x);
508
#ifdef CONFIG_HAVE_DOUBLE
509
double
atan(
double
x);
510
#endif
511
514
#ifdef CONFIG_HAVE_LONG_DOUBLE
515
long
double
atanl(
long
double
x);
516
#endif
517
520
float
atan2f(
float
y,
float
x);
524
#ifdef CONFIG_HAVE_DOUBLE
525
double
atan2(
double
y,
double
x);
526
#endif
527
530
#ifdef CONFIG_HAVE_LONG_DOUBLE
531
long
double
atan2l(
long
double
y,
long
double
x);
532
#endif
533
536
float
sinhf(
float
x);
540
#ifdef CONFIG_HAVE_DOUBLE
541
double
sinh(
double
x);
542
#endif
543
546
#ifdef CONFIG_HAVE_LONG_DOUBLE
547
long
double
sinhl(
long
double
x);
548
#endif
549
552
float
coshf(
float
x);
556
#ifdef CONFIG_HAVE_DOUBLE
557
double
cosh(
double
x);
558
#endif
559
562
#ifdef CONFIG_HAVE_LONG_DOUBLE
563
long
double
coshl(
long
double
x);
564
#endif
565
568
float
tanhf(
float
x);
572
#ifdef CONFIG_HAVE_DOUBLE
573
double
tanh(
double
x);
574
#endif
575
578
#ifdef CONFIG_HAVE_LONG_DOUBLE
579
long
double
tanhl(
long
double
x);
580
#endif
581
584
float
asinhf(
float
x);
588
#ifdef CONFIG_HAVE_DOUBLE
589
double
asinh(
double
x);
590
#endif
591
594
#ifdef CONFIG_HAVE_LONG_DOUBLE
595
long
double
asinhl(
long
double
x);
596
#endif
597
600
float
acoshf(
float
x);
604
#ifdef CONFIG_HAVE_DOUBLE
605
double
acosh(
double
x);
606
#endif
607
610
#ifdef CONFIG_HAVE_LONG_DOUBLE
611
long
double
acoshl(
long
double
x);
612
#endif
613
616
float
atanhf(
float
x);
620
#ifdef CONFIG_HAVE_DOUBLE
621
double
atanh(
double
x);
622
#endif
623
626
#ifdef CONFIG_HAVE_LONG_DOUBLE
627
long
double
atanhl(
long
double
x);
628
#endif
629
632
float
erff(
float
x);
636
#define erfcf(x) (1 - erff(x))
637
640
#ifdef CONFIG_HAVE_DOUBLE
641
double
erf(
double
x);
642
#define erfc(x) (1 - erf(x))
643
#endif
644
647
#ifdef CONFIG_HAVE_LONG_DOUBLE
648
long
double
erfl(
long
double
x);
649
#define erfcl(x) (1 - erfl(x))
650
#endif
651
654
float
copysignf(
float
x,
float
y);
658
#ifdef CONFIG_HAVE_DOUBLE
659
double
copysign(
double
x,
double
y);
660
#endif
661
664
#ifdef CONFIG_HAVE_LONG_DOUBLE
665
long
double
copysignl(
long
double
x,
long
double
y);
666
#endif
667
670
float
truncf(
float
x);
674
#ifdef CONFIG_HAVE_DOUBLE
675
double
trunc(
double
x);
676
#endif
677
680
#ifdef CONFIG_HAVE_LONG_DOUBLE
681
long
double
truncl(
long
double
x);
682
#endif
683
686
#define nanf(x) ((float)(NAN))
687
690
#ifdef CONFIG_HAVE_DOUBLE
691
#define nan(x) ((double)(NAN))
692
#endif
693
#ifdef CONFIG_HAVE_LONG_DOUBLE
694
#define nanl(x) ((long double)(NAN))
695
#endif
696
700
#if defined(__cplusplus)
701
}
702
#endif
703
#endif
/* CONFIG_LIBM */
704
#endif
/* __INCLUDE_MATH_H */
705
fabs
double fabs(double x)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
pow
double pow(double b, double e)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
floor
double floor(double x)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
os
include
tinyara
math.h
Generated by
1.8.11