Rudiments

math.h
1 // Copyright (c) 1999-2018 David Muse
2 // See the COPYING file for more information.
3
4 #ifndef RUDIMENTS_MATH_H
5 #define RUDIMENTS_MATH_H
6
7 #include <rudiments/private/mathincludes.h>
8
9 class RUDIMENTS_DLLSPEC math {
10 public:
11 static int32_t absoluteValue(int32_t j);
12 static div_t divide(int32_t numer, int32_t denom);
13
14 static int64_t absoluteValue(int64_t j);
15 static lldiv_t divide(int64_t numer, int64_t denom);
16
17 static bool isFinite(float x);
18 static bool isInfinite(float x);
19
20 static bool isNaN(float x);
21 static bool areNaN(float x, float y);
22
23 static bool isNormal(float x);
24 static bool isSubNormal(float x);
25
26 static bool isGreater(float x, float y);
27 static bool isGreaterOrEqual(float x, float y);
28 static bool isLess(float x, float y);
29 static bool isLessOrEqual(float x, float y);
30 static bool isLessOrGreater(float x, float y);
31
32 static bool isSignBitSet(float x);
33 static float copySignBit(float x, float y);
34
35 static float arcCosine(float x);
36 static float arcSine(float x);
37 static float arcTangent(float x);
38 static float arcTangent(float y, float x);
39
40 static float cosine(float x);
41 static float sine(float x);
42 static float tangent(float x);
43
44 static float hyperbolicArcCosine(float x);
45 static float hyperbolicArcSine(float x);
46 static float hyperbolicArcTangent(float x);
47
48 static float hyperbolicCosine(float x);
49 static float hyperbolicSine(float x);
50 static float hyperbolicTangent(float x);
51
52 static float naturalExponent(float x);
53 static float naturalLog(float x);
54 static float naturalExponentMinusOne(float x);
55 static float naturalLogPlusOne(float x);
56
57 static float exponent(float x);
58
59 static float normalize(float x, int32_t *exp);
60
61 static float logBase10(float x);
62
63 static float exponentBase2(float x);
64 static float logBase2(float x);
65
66 static float power(float x, float y);
67
68 static float squareRoot(float x);
69 static float cubeRoot(float x);
70
71 static float hypotenuse(float x, float y);
72
73 static float computeExponent(float x);
74 static int32_t integralExponent(float x);
75 static float loadExponent(float x, int32_t exp);
76
77 static float ceiling(float x);
78 static float floor(float x);
79 static float absoluteValue(float x);
80
81 static float remainder(float x, float y);
82 static float remainder(float x, float y, int32_t *quo);
83
84 static float truncate(float x);
85 static float nearbyInteger(float x);
86 static float round(float x);
87 static float roundInexact(float x);
88 static long roundToLong(float x);
89 static int64_t roundToLongLong(float x);
90 static long roundAwayFromZeroToLong(float x);
91 static int64_t roundAwayFromZeroToLongLong(float x);
92 static float nextAfter(float x, float y);
93 static float nextToward(float x, float y);
94
95 static float errorFunction(float x);
96 static float complementaryErrorFunction(float x);
97
98 static float trueGamma(float x);
99 static float naturalLogGamma(float x);
100
101 static float scaleByRadixToPower(float x, float n);
102 static float scaleByRadixToPower(float x, int32_t n);
103 static float scaleByRadixToPower(float x, long n);
104
105 static float larger(float x, float y);
106 static float smaller(float x, float y);
107
108 static float multiplyAndAdd(float x, float y, float z);
109 static float positiveDifference(float x, float y);
110
111 static float argument(float complex z);
112 static float complex conjugate(float complex z);
113 static float complex project(float complex z);
114 static float imaginary(float complex z);
115 static float real(float complex z);
116
117
118
119
120 // double methods
121 static bool isFinite(double x);
122 static bool isInfinite(double x);
123
124 static bool isNaN(double x);
125 static bool areNaN(double x, double y);
126
127 static bool isNormal(double x);
128 static bool isSubNormal(double x);
129
130 static bool isGreater(double x, double y);
131 static bool isGreaterOrEqual(double x, double y);
132 static bool isLess(double x, double y);
133 static bool isLessOrEqual(double x, double y);
134 static bool isLessOrGreater(double x, double y);
135
136 static bool isSignBitSet(double x);
137 static double copySignBit(double x, double y);
138
139 static double arcCosine(double x);
140 static double arcSine(double x);
141 static double arcTangent(double x);
142 static double arcTangent(double y, double x);
143
144 static double cosine(double x);
145 static double sine(double x);
146 static double tangent(double x);
147
148 static double hyperbolicArcCosine(double x);
149 static double hyperbolicArcSine(double x);
150 static double hyperbolicArcTangent(double x);
151
152 static double hyperbolicCosine(double x);
153 static double hyperbolicSine(double x);
154 static double hyperbolicTangent(double x);
155
156 static double naturalExponent(double x);
157 static double naturalLog(double x);
158 static double naturalExponentMinusOne(double x);
159 static double naturalLogPlusOne(double x);
160
161 static double exponent(double x);
162
163 static double normalize(double x, int32_t *exp);
164
165 static double logBase10(double x);
166
167 static double exponentBase2(double x);
168 static double logBase2(double x);
169
170 static double power(double x, double y);
171
172 static double squareRoot(double x);
173 static double cubeRoot(double x);
174
175 static double hypotenuse(double x, double y);
176
177 static double computeExponent(double x);
178 static int32_t integralExponent(double x);
179 static double loadExponent(double x, int32_t exp);
180
181 static double ceiling(double x);
182 static double floor(double x);
183 static double absoluteValue(double x);
184
185 static double remainder(double x, double y);
186 static double remainder(double x, double y, int32_t *quo);
187
188 static double truncate(double x);
189 static double nearbyInteger(double x);
190 static double round(double x);
191 static double roundInexact(double x);
192 static long roundToLong(double x);
193 static int64_t roundToLongLong(double x);
194 static long roundAwayFromZeroToLong(double x);
195 static int64_t roundAwayFromZeroToLongLong(double x);
196 static double nextAfter(double x, double y);
197 static double nextToward(double x, double y);
198
199 static double errorFunction(double x);
200 static double complementaryErrorFunction(double x);
201
202 static double trueGamma(double x);
203 static double naturalLogGamma(double x);
204
205 static double scaleByRadixToPower(double x, double n);
206 static double scaleByRadixToPower(double x, int32_t n);
207 static double scaleByRadixToPower(double x, long n);
208
209 static double larger(double x, double y);
210 static double smaller(double x, double y);
211
212 static double multiplyAndAdd(double x, double y, double z);
213 static double positiveDifference(double x, double y);
214
215 static double argument(double complex z);
216 static double complex conjugate(double complex z);
217 static double complex project(double complex z);
218 static double imaginary(double complex z);
219 static double real(double complex z);
220
221
222 // long double methods
223 static bool isFinite(long double x);
224 static bool isInfinite(long double x);
225
226 static bool isNaN(long double x);
227 static bool areNaN(long double x, long double y);
228
229 static bool isNormal(long double x);
230 static bool isSubNormal(long double x);
231
232 static bool isGreater(long double x, long double y);
233 static bool isGreaterOrEqual(long double x, long double y);
234 static bool isLess(long double x, long double y);
235 static bool isLessOrEqual(long double x, long double y);
236 static bool isLessOrGreater(long double x, long double y);
237
238 static bool isSignBitSet(long double x);
239 static long double copySignBit(long double x,
240 long double y);
241
242 static long double arcCosine(long double x);
243 static long double arcSine(long double x);
244 static long double arcTangent(long double x);
245 static long double arcTangent(long double y,
246 long double x);
247
248 static long double cosine(long double x);
249 static long double sine(long double x);
250 static long double tangent(long double x);
251
252 static long double hyperbolicArcCosine(long double x);
253 static long double hyperbolicArcSine(long double x);
254 static long double hyperbolicArcTangent(long double x);
255
256 static long double hyperbolicCosine(long double x);
257 static long double hyperbolicSine(long double x);
258 static long double hyperbolicTangent(long double x);
259
260 static long double naturalExponent(long double x);
261 static long double naturalLog(long double x);
262 static long double naturalExponentMinusOne(long double x);
263 static long double naturalLogPlusOne(long double x);
264
265 static long double exponent(long double x);
266
267 static long double normalize(long double x, int32_t *exp);
268
269 static long double logBase10(long double x);
270
271 static long double exponentBase2(long double x);
272 static long double logBase2(long double x);
273
274 static long double power(long double x, long double y);
275
276 static long double squareRoot(long double x);
277 static long double cubeRoot(long double x);
278
279 static long double hypotenuse(long double x,
280 long double y);
281
282 static long double computeExponent(long double x);
283 static int32_t integralExponent(long double x);
284 static long double loadExponent(long double x,
285 int32_t exp);
286
287 static long double ceiling(long double x);
288 static long double floor(long double x);
289 static long double absoluteValue(long double x);
290
291 static long double remainder(long double x,
292 long double y);
293 static long double remainder(long double x,
294 long double y,
295 int32_t *quo);
296
297 static long double truncate(long double x);
298 static long double nearbyInteger(long double x);
299 static long double round(long double x);
300 static long double roundInexact(long double x);
301 static long roundToLong(long double x);
302 static int64_t roundToLongLong(long double x);
303 static long roundAwayFromZeroToLong(long double x);
304 static int64_t roundAwayFromZeroToLongLong(
305 long double x);
306 static long double nextAfter(long double x,
307 long double y);
308 static long double nextToward(long double x,
309 long double y);
310
311 static long double errorFunction(long double x);
312 static long double complementaryErrorFunction(
313 long double x);
314
315 static long double trueGamma(long double x);
316 static long double naturalLogGamma(long double x);
317
318
319 static long double scaleByRadixToPower(long double x,
320 long double n);
321 static long double scaleByRadixToPower(long double x,
322 int32_t n);
323 static long double scaleByRadixToPower(long double x,
324 long n);
325
326 static long double larger(long double x, long double y);
327 static long double smaller(long double x, long double y);
328
329 static long double multiplyAndAdd(long double x,
330 long double y,
331 long double z);
332 static long double positiveDifference(long double x,
333 long double y);
334
335 static long double argument(long double complex z);
336 static long double complex conjugate(long double complex z);
337 static long double complex project(long double complex z);
338 static long double imaginary(long double complex z);
339 static long double real(long double complex z);
340
341
342 // may not be in solaris -
343 // inttypes.h - some integer math functions
344 // imaxabs(),imaxdiv()
345 // strtoimax(),strtoumax(),wcstoimax(),wcstoumax()
346 // not in solaris -
347 // sys/param.h - howmany(),roundup(),powerof2(),MIN(),MAX()
348
349 };
350
351 #ifdef ENABLE_RUDIMENTS_INLINES
352 #include <rudiments/private/mathinlines.h>
353 #endif
354
355 #endif
math
Definition: math.h:9