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