summaryrefslogtreecommitdiff
path: root/core/pkg/tbox.pkg/inc/tbox/libm/math.h
blob: 99ef382ca813c50f4179db2afabbf6d75d6c3aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/*!The Treasure Box Library
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * Copyright (C) 2009 - 2017, TBOOX Open Source Group.
 *
 * @author      ruki
 * @file        math.h
 * @ingroup     libm
 *
 */
#ifndef TB_LIBM_MATH_H
#define TB_LIBM_MATH_H

/* //////////////////////////////////////////////////////////////////////////////////////
 * includes
 */
#include "prefix.h"
#ifdef TB_CONFIG_TYPE_HAVE_FLOAT
#   include "nan.h"
#   include "inf.h"
#   include "maf.h"
#   include "mif.h"
#   include "pi.h"
#   include "fabs.h"
#   include "round.h"
#   include "ceil.h"
#   include "floor.h"
#endif

/* //////////////////////////////////////////////////////////////////////////////////////
 * extern
 */
__tb_extern_c_enter__

/* //////////////////////////////////////////////////////////////////////////////////////
 * interfaces
 */

#ifdef TB_CONFIG_TYPE_HAVE_FLOAT

// is infinite?
tb_long_t       tb_isinf(tb_double_t x);
tb_long_t       tb_isinff(tb_float_t x);

// is finite?
tb_long_t       tb_isfin(tb_double_t x);
tb_long_t       tb_isfinf(tb_float_t x);

// is nan?
tb_long_t       tb_isnan(tb_double_t x);
tb_long_t       tb_isnanf(tb_float_t x);

// sqrt
tb_double_t     tb_sqrt(tb_double_t x);
tb_float_t      tb_sqrtf(tb_float_t x);

// sin
tb_double_t     tb_sin(tb_double_t x);
tb_float_t      tb_sinf(tb_float_t x);

// cos
tb_double_t     tb_cos(tb_double_t x);
tb_float_t      tb_cosf(tb_float_t x);

// tan
tb_double_t     tb_tan(tb_double_t x);
tb_float_t      tb_tanf(tb_float_t x);

// atan
tb_double_t     tb_atan(tb_double_t x);
tb_float_t      tb_atanf(tb_float_t x);

// exp
tb_double_t     tb_exp(tb_double_t x);
tb_float_t      tb_expf(tb_float_t x);

// expi
tb_double_t     tb_expi(tb_long_t x);
tb_float_t      tb_expif(tb_long_t x);

// exp1
tb_double_t     tb_exp1(tb_double_t x);
tb_float_t      tb_exp1f(tb_float_t x);

// asin
tb_double_t     tb_asin(tb_double_t x);
tb_float_t      tb_asinf(tb_float_t x);

// acos
tb_double_t     tb_acos(tb_double_t x);
tb_float_t      tb_acosf(tb_float_t x);

// atan2
tb_double_t     tb_atan2(tb_double_t y, tb_double_t x);
tb_float_t      tb_atan2f(tb_float_t y, tb_float_t x);

// log2
tb_double_t     tb_log2(tb_double_t x);
tb_float_t      tb_log2f(tb_float_t x);

// sincos
tb_void_t       tb_sincos(tb_double_t x, tb_double_t* s, tb_double_t* c);
tb_void_t       tb_sincosf(tb_float_t x, tb_float_t* s, tb_float_t* c);

// pow
tb_double_t     tb_pow(tb_double_t x, tb_double_t y);
tb_float_t      tb_powf(tb_float_t x, tb_float_t y);

// fmod
tb_double_t     tb_fmod(tb_double_t x, tb_double_t y);
tb_float_t      tb_fmodf(tb_float_t x, tb_float_t y);
#endif

// ilog2i
tb_uint32_t     tb_ilog2i(tb_uint32_t x);

// isqrti
tb_uint32_t     tb_isqrti(tb_uint32_t x);
tb_uint32_t     tb_isqrti64(tb_uint64_t x);

// idivi8
tb_uint32_t     tb_idivi8(tb_uint32_t x, tb_uint8_t y);

/* //////////////////////////////////////////////////////////////////////////////////////
 * extern
 */
__tb_extern_c_leave__

#endif