File: math.h

package info (click to toggle)
librudiments0 0.27-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,528 kB
  • ctags: 2,284
  • sloc: cpp: 14,657; sh: 7,547; ansic: 2,664; makefile: 945; xml: 15
file content (352 lines) | stat: -rw-r--r-- 11,021 bytes parent folder | download
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
// Copyright (c) 2004 David Muse
// See the COPYING file for more information.

#ifndef RUDIMENTS_MATH_H
#define RUDIMENTS_MATH_H

#include <rudiments/private/mathincludes.h>

class math {
	public:
		static int	absoluteValue(int j);
		static div_t	divide(int numer, int denom);

		static long	absoluteValue(long j);
		static ldiv_t	divide(long numer, long denom);

		static long long	absoluteValue(long long j);
		static lldiv_t		divide(long long numer,
						long long denom);

		static bool	isFinite(float x);
		static bool	isInfinite(float x);

		static bool	isNaN(float x);
		static bool	areNaN(float x, float y);

		static bool	isNormal(float x);
		static bool	isSubNormal(float x);

		static bool	isGreater(float x, float y);
		static bool	isGreaterOrEqual(float x, float y);
		static bool	isLess(float x, float y);
		static bool	isLessOrEqual(float x, float y);
		static bool	isLessOrGreater(float x, float y);

		static bool	isSignBitSet(float x);
		static float	copySignBit(float x, float y);

		static float	arcCosine(float x);
		static float	arcSine(float x);
		static float	arcTangent(float x);
		static float	arcTangent(float y, float x);

		static float	cosine(float x);
		static float	sine(float x);
		static float	tangent(float x);

		static float	hyperbolicArcCosine(float x);
		static float	hyperbolicArcSine(float x);
		static float	hyperbolicArcTangent(float x);

		static float	hyperbolicCosine(float x);
		static float	hyperbolicSine(float x);
		static float	hyperbolicTangent(float x);

		static float	naturalExponent(float x);
		static float	naturalLog(float x);
		static float	naturalExponentMinusOne(float x);
		static float	naturalLogOfPlusOne(float x);

		static float	normalize(float x, int *exp);

		static float	logBase10(float x);

		static float	exponentBase2(float x);
		static float	logBase2(float x);

		static float	power(float x, float y);

		static float	squareRoot(float x);
		static float	cubeRoot(float x);

		static float	hypotenuse(float x, float y);

		static float	computeExponent(float x);
		static int	integralExponent(float x);
		static float 	loadExponent(float x, int exp);

		static float	ceiling(float x);
		static float	floor(float x);
		static float	absoluteValue(float x);

		static float	remainder(float x, float y);
		static float	remainder(float x, float y, int *quo);

		static float	truncate(float x);
		static float	nearbyInteger(float x);
		static float	round(float x);
		static float	roundInexact(float x);
		static long		roundToLong(float x);
		static long long	roundToLongLong(float x);
		static long		roundAwayFromZeroToLong(float x);
		static long long	roundAwayFromZeroToLongLong(float x);
		static float	nextAfter(float x, float y);
		static float	nextToward(float x, float y);

		static float	errorFunction(float x);
		static float	complementaryErrorFunction(float x);

		static float	trueGamma(float x);
		static float	naturalLogGamma(float x);

		static float	scaleByRadixToPower(float x, float n);
		static float	scaleByRadixToPower(float x, int n);
		static float	scaleByRadixToPower(float x, long n);

		static float	larger(float x, float y);
		static float	smaller(float x, float y);

		static float	multiplyAndAdd(float x, float y, float z);
		static float	positiveDifference(float x, float y);

		static float	argument(float complex z);
		static float	conjugate(float complex z);
		static float	project(float complex z);
		static float	imaginary(float complex z);
		static float	real(float complex z);




		// double methods
		static bool	isFinite(double x);
		static bool	isInfinite(double x);

		static bool	isNaN(double x);
		static bool	areNaN(double x, double y);

		static bool	isNormal(double x);
		static bool	isSubNormal(double x);

		static bool	isGreater(double x, double y);
		static bool	isGreaterOrEqual(double x, double y);
		static bool	isLess(double x, double y);
		static bool	isLessOrEqual(double x, double y);
		static bool	isLessOrGreater(double x, double y);

		static bool	isSignBitSet(double x);
		static double	copySignBit(double x, double y);

		static double	arcCosine(double x);
		static double	arcSine(double x);
		static double	arcTangent(double x);
		static double	arcTangent(double y, double x);

		static double	cosine(double x);
		static double	sine(double x);
		static double	tangent(double x);

		static double	hyperbolicArcCosine(double x);
		static double	hyperbolicArcSine(double x);
		static double	hyperbolicArcTangent(double x);

		static double	hyperbolicCosine(double x);
		static double	hyperbolicSine(double x);
		static double	hyperbolicTangent(double x);

		static double	naturalExponent(double x);
		static double	naturalLog(double x);
		static double	naturalExponentMinusOne(double x);
		static double	naturalLogOfPlusOne(double x);

		static double	normalize(double x, int *exp);

		static double	logBase10(double x);

		static double	exponentBase2(double x);
		static double	logBase2(double x);

		static double	power(double x, double y);

		static double	squareRoot(double x);
		static double	cubeRoot(double x);

		static double	hypotenuse(double x, double y);

		static double	computeExponent(double x);
		static int	integralExponent(double x);
		static double 	loadExponent(double x, int exp);

		static double	ceiling(double x);
		static double	floor(double x);
		static double	absoluteValue(double x);

		static double	remainder(double x, double y);
		static double	remainder(double x, double y, int *quo);

		static double	truncate(double x);
		static double	nearbyInteger(double x);
		static double	round(double x);
		static double	roundInexact(double x);
		static long		roundToLong(double x);
		static long long	roundToLongLong(double x);
		static long		roundAwayFromZeroToLong(double x);
		static long long	roundAwayFromZeroToLongLong(double x);
		static double	nextAfter(double x, double y);
		static double	nextToward(double x, double y);

		static double	errorFunction(double x);
		static double	complementaryErrorFunction(double x);

		static double	trueGamma(double x);
		static double	naturalLogGamma(double x);

		static double	scaleByRadixToPower(double x, double n);
		static double	scaleByRadixToPower(double x, int n);
		static double	scaleByRadixToPower(double x, long n);

		static double	larger(double x, double y);
		static double	smaller(double x, double y);

		static double	multiplyAndAdd(double x, double y, double z);
		static double	positiveDifference(double x, double y);

		static double	argument(double complex z);
		static double	conjugate(double complex z);
		static double	project(double complex z);
		static double	imaginary(double complex z);
		static double	real(double complex z);


		// long double methods
		static bool	isFinite(long double x);
		static bool	isInfinite(long double x);

		static bool	isNaN(long double x);
		static bool	areNaN(long double x, long double y);

		static bool	isNormal(long double x);
		static bool	isSubNormal(long double x);

		static bool	isGreater(long double x, long double y);
		static bool	isGreaterOrEqual(long double x, long double y);
		static bool	isLess(long double x, long double y);
		static bool	isLessOrEqual(long double x, long double y);
		static bool	isLessOrGreater(long double x, long double y);

		static bool		isSignBitSet(long double x);
		static long double	copySignBit(long double x,
							long double y);

		static long double	arcCosine(long double x);
		static long double	arcSine(long double x);
		static long double	arcTangent(long double x);
		static long double	arcTangent(long double y,
							long double x);

		static long double	cosine(long double x);
		static long double	sine(long double x);
		static long double	tangent(long double x);

		static long double	hyperbolicArcCosine(long double x);
		static long double	hyperbolicArcSine(long double x);
		static long double	hyperbolicArcTangent(long double x);

		static long double	hyperbolicCosine(long double x);
		static long double	hyperbolicSine(long double x);
		static long double	hyperbolicTangent(long double x);

		static long double	naturalExponent(long double x);
		static long double	naturalLog(long double x);
		static long double	naturalExponentMinusOne(long double x);
		static long double	naturalLogOfPlusOne(long double x);

		static long double	normalize(long double x, int *exp);

		static long double	logBase10(long double x);

		static long double	exponentBase2(long double x);
		static long double	logBase2(long double x);

		static long double	power(long double x, long double y);

		static long double	squareRoot(long double x);
		static long double	cubeRoot(long double x);

		static long double	hypotenuse(long double x,
							long double y);

		static long double	computeExponent(long double x);
		static int		integralExponent(long double x);
		static long double 	loadExponent(long double x, int exp);

		static long double	ceiling(long double x);
		static long double	floor(long double x);
		static long double	absoluteValue(long double x);

		static long double	remainder(long double x,
							long double y);
		static long double	remainder(long double x,
							long double y,
							int *quo);

		static long double	truncate(long double x);
		static long double	nearbyInteger(long double x);
		static long double	round(long double x);
		static long double	roundInexact(long double x);
		static long		roundToLong(long double x);
		static long long	roundToLongLong(long double x);
		static long		roundAwayFromZeroToLong(long double x);
		static long long	roundAwayFromZeroToLongLong(
								long double x);
		static long double	nextAfter(long double x,
							long double y);
		static long double	nextToward(long double x,
							long double y);

		static long double	errorFunction(long double x);
		static long double	complementaryErrorFunction(
								long double x);

		static long double	trueGamma(long double x);
		static long double	naturalLogGamma(long double x);


		static long double	scaleByRadixToPower(long double x,
								long double n);
		static long double	scaleByRadixToPower(long double x,
								int n);
		static long double	scaleByRadixToPower(long double x,
								long n);

		static long double	larger(long double x, long double y);
		static long double	smaller(long double x, long double y);

		static long double	multiplyAndAdd(long double x,
								long double y,
								long double z);
		static long double	positiveDifference(long double x,
								long double y);

		static long double	argument(long double complex z);
		static long double	conjugate(long double complex z);
		static long double	project(long double complex z);
		static long double	imaginary(long double complex z);
		static long double	real(long double complex z);


//	may not be in solaris - 
//		inttypes.h - some integer math functions
//			imaxabs(),imaxdiv()
//			strtoimax(),strtoumax(),wcstoimax(),wcstoumax()
//	not in solaris - 
//		sys/param.h - howmany(),roundup(),powerof2(),MIN(),MAX()

};

#ifdef ENABLE_RUDIMENTS_INLINES
	#include <rudiments/private/mathinlines.h>
#endif

#endif