1 | //
|
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
|
---|
3 | //
|
---|
4 | // The contents of this file are covered under the licence agreement in the
|
---|
5 | // file "LICENCE" distributed with Cforall.
|
---|
6 | //
|
---|
7 | // math.c --
|
---|
8 | //
|
---|
9 | // Author : Peter A. Buhr
|
---|
10 | // Created On : Tue Apr 19 22:23:08 2016
|
---|
11 | // Last Modified By : Peter A. Buhr
|
---|
12 | // Last Modified On : Sun Apr 24 08:52:31 2016
|
---|
13 | // Update Count : 75
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include "math"
|
---|
17 |
|
---|
18 | extern "C" {
|
---|
19 | #include <complex.h>
|
---|
20 | } // extern "C"
|
---|
21 |
|
---|
22 | float fabs( float x ) { return fabsf( x ); }
|
---|
23 | long double fabs( long double x ) { return fabsl( x ); }
|
---|
24 | float cabs( float _Complex x ) { return cabsf( x ); }
|
---|
25 | long double cabs( long double _Complex x ) { return cabsl( x ); }
|
---|
26 |
|
---|
27 | float ?%?( float x, float y ) { return fmodf( x, y ); }
|
---|
28 | float fmod( float x, float y ) { return fmodf( x, y ); }
|
---|
29 | double ?%?( double x, double y ) { return fmod( x, y ); }
|
---|
30 | long double ?%?( long double x, long double y ) { return fmodl( x, y ); }
|
---|
31 | long double fmod( long double x, long double y ) { return fmodl( x, y ); }
|
---|
32 |
|
---|
33 | float remainder( float x, float y ) { return remainderf( x, y ); }
|
---|
34 | long double remainder( long double x, long double y ) { return remainderl( x, y ); }
|
---|
35 |
|
---|
36 | // [ int, float ] remquo( float x, float y ) { int quo; x = remquof( x, y, &quo ); return [ quo, x ]; }
|
---|
37 | float remquo( float x, float y, int *quo ) { return remquof( x, y, quo ); }
|
---|
38 | // [ int, double ] remquo( double x, double y ) { int quo; x = remquo( x, y, &quo ); return [ quo, x ]; }
|
---|
39 | // [ int, long double ] remquo( long double x, long double y ) { int quo; x = remquol( x, y, &quo ); return [ quo, x ]; }
|
---|
40 | long double remquo( long double x, long double y, int *quo ) { return remquol( x, y, quo ); }
|
---|
41 |
|
---|
42 | // [ int, float ] div( float x, float y ) { int quo; x = remquof( x, y, &quo ); return [ quo, x ]; }
|
---|
43 | float div( float x, float y, int *quo ) { return remquof( x, y, quo ); }
|
---|
44 | // [ int, double ] div( double x, double y ) { int quo; x = remquo( x, y, &quo ); return [ quo, x ]; }
|
---|
45 | // [ int, long double ] div( long double x, long double y ) { int quo; x = remquol( x, y, &quo ); return [ quo, x ]; }
|
---|
46 | long double div( long double x, long double y, int *quo ) { return remquol( x, y, quo ); }
|
---|
47 |
|
---|
48 | float fma( float x, float y, float z ) { return fmaf( x, y, z ); }
|
---|
49 | long double fma( long double x, long double y, long double z ) { return fmal( x, y, z ); }
|
---|
50 |
|
---|
51 | float fdim( float x, float y ) { return fdimf( x, y ); }
|
---|
52 | long double fdim( long double x, long double y ) { return fdiml( x, y ); }
|
---|
53 |
|
---|
54 | float nan( const char *tag ) { return nanf( tag ); }
|
---|
55 | long double nan( const char *tag ) { return nanl( tag ); }
|
---|
56 |
|
---|
57 | //---------------------- Exponential ----------------------
|
---|
58 |
|
---|
59 | float exp( float x ) { return expf( x ); }
|
---|
60 | long double exp( long double x ) { return expl( x ); }
|
---|
61 | float _Complex exp( float _Complex x ) { return cexpf( x ); }
|
---|
62 | double _Complex exp( double _Complex x ) { return cexp( x ); }
|
---|
63 | long double _Complex exp( long double _Complex x ) { return cexpl( x ); }
|
---|
64 |
|
---|
65 | float exp2( float x ) { return exp2f( x ); }
|
---|
66 | long double exp2( long double x ) { return exp2l( x ); }
|
---|
67 | // float _Complex exp2( float _Complex x ) { return cexp2f( x ); }
|
---|
68 | // double _Complex exp2( double _Complex x ) { return cexp2( x ); }
|
---|
69 | // long double _Complex exp2( long double _Complex x ) { return cexp2l( x ); }
|
---|
70 |
|
---|
71 | float expm1( float x ) { return expm1f( x ); }
|
---|
72 | long double expm1( long double x ) { return expm1l( x ); }
|
---|
73 |
|
---|
74 | float log( float x ) { return logf( x ); }
|
---|
75 | long double log( long double x ) { return logl( x ); }
|
---|
76 | float _Complex log( float _Complex x ) { return clogf( x ); }
|
---|
77 | double _Complex log( double _Complex x ) { return clog( x ); }
|
---|
78 | long double _Complex log( long double _Complex x ) { return clogl( x ); }
|
---|
79 |
|
---|
80 | float log2( float x ) { return log2f( x ); }
|
---|
81 | long double log2( long double x ) { return log2l( x ); }
|
---|
82 | // float _Complex log2( float _Complex x ) { return clog2f( x ); }
|
---|
83 | // double _Complex log2( double _Complex x ) { return clog2( x ); }
|
---|
84 | // long double _Complex log2( long double _Complex x ) { return clog2l( x ); }
|
---|
85 |
|
---|
86 | float log10( float x ) { return log10f( x ); }
|
---|
87 | long double log10( long double x ) { return log10l( x ); }
|
---|
88 | // float _Complex log10( float _Complex x ) { return clog10f( x ); }
|
---|
89 | // double _Complex log10( double _Complex x ) { return clog10( x ); }
|
---|
90 | // long double _Complex log10( long double _Complex x ) { return clog10l( x ); }
|
---|
91 |
|
---|
92 | float log1p( float x ) { return log1pf( x ); }
|
---|
93 | long double log1p( long double x ) { return log1pl( x ); }
|
---|
94 |
|
---|
95 | int ilogb( float x ) { return ilogbf( x ); }
|
---|
96 | int ilogb( long double x ) { return ilogbl( x ); }
|
---|
97 |
|
---|
98 | float logb( float x ) { return logbf( x ); }
|
---|
99 | long double logb( long double x ) { return logbl( x ); }
|
---|
100 |
|
---|
101 | //---------------------- Power ----------------------
|
---|
102 |
|
---|
103 | float sqrt( float x ) { return sqrtf( x ); }
|
---|
104 | long double sqrt( long double x ) { return sqrtl( x ); }
|
---|
105 | float _Complex sqrt( float _Complex x ) { return csqrtf( x ); }
|
---|
106 | double _Complex sqrt( double _Complex x ) { return csqrt( x ); }
|
---|
107 | long double _Complex sqrt( long double _Complex x ) { return csqrtl( x ); }
|
---|
108 |
|
---|
109 | float cbrt( float x ) { return cbrtf( x ); }
|
---|
110 | long double cbrt( long double x ) { return cbrtl( x ); }
|
---|
111 |
|
---|
112 | float hypot( float x, float y ) { return hypotf( x, y ); }
|
---|
113 | long double hypot( long double x, long double y ) { return hypotl( x, y ); }
|
---|
114 |
|
---|
115 | float pow( float x, float y ) { return powf( x, y ); }
|
---|
116 | long double pow( long double x, long double y ) { return powl( x, y ); }
|
---|
117 | float _Complex pow( float _Complex x, float _Complex y ) { return cpowf( x, y ); }
|
---|
118 | double _Complex pow( double _Complex x, double _Complex y ) { return cpow( x, y ); }
|
---|
119 | long double _Complex pow( long double _Complex x, long double _Complex y ) { return cpowl( x, y ); }
|
---|
120 |
|
---|
121 | //---------------------- Trigonometric ----------------------
|
---|
122 |
|
---|
123 | float sin( float x ) { return sinf( x ); }
|
---|
124 | long double sin( long double x ) { return sinl( x ); }
|
---|
125 | float _Complex sin( float _Complex x ) { return csinf( x ); }
|
---|
126 | double _Complex sin( double _Complex x ) { return csin( x ); }
|
---|
127 | long double _Complex sin( long double _Complex x ) { return csinl( x ); }
|
---|
128 |
|
---|
129 | float cos( float x ) { return cosf( x ); }
|
---|
130 | long double cos( long double x ) { return cosl( x ); }
|
---|
131 | float _Complex cos( float _Complex x ) { return ccosf( x ); }
|
---|
132 | double _Complex cos( double _Complex x ) { return ccos( x ); }
|
---|
133 | long double _Complex cos( long double _Complex x ) { return ccosl( x ); }
|
---|
134 |
|
---|
135 | float tan( float x ) { return tanf( x ); }
|
---|
136 | long double tan( long double x ) { return tanl( x ); }
|
---|
137 | float _Complex tan( float _Complex x ) { return ctanf( x ); }
|
---|
138 | double _Complex tan( double _Complex x ) { return ctan( x ); }
|
---|
139 | long double _Complex tan( long double _Complex x ) { return ctanl( x ); }
|
---|
140 |
|
---|
141 | float asin( float x ) { return asinf( x ); }
|
---|
142 | long double asin( long double x ) { return asinl( x ); }
|
---|
143 | float _Complex asin( float _Complex x ) { return casinf( x ); }
|
---|
144 | double _Complex asin( double _Complex x ) { return casin( x ); }
|
---|
145 | long double _Complex asin( long double _Complex x ) { return casinl( x ); }
|
---|
146 |
|
---|
147 | float acos( float x ) { return acosf( x ); }
|
---|
148 | long double acos( long double x ) { return acosl( x ); }
|
---|
149 | float _Complex acos( float _Complex x ) { return cacosf( x ); }
|
---|
150 | double _Complex acos( double _Complex x ) { return cacos( x ); }
|
---|
151 | long double _Complex acos( long double _Complex x ) { return cacosl( x ); }
|
---|
152 |
|
---|
153 | float atan( float x ) { return atanf( x ); }
|
---|
154 | long double atan( long double x ) { return atanl( x ); }
|
---|
155 | float _Complex atan( float _Complex x ) { return catanf( x ); }
|
---|
156 | double _Complex atan( double _Complex x ) { return catan( x ); }
|
---|
157 | long double _Complex atan( long double _Complex x ) { return catanl( x ); }
|
---|
158 |
|
---|
159 | float atan2( float x, float y ) { return atan2f( x, y ); }
|
---|
160 | long double atan2( long double x, long double y ) { return atan2l( x, y ); }
|
---|
161 |
|
---|
162 | float atan( float x, float y ) { return atan2f( x, y ); }
|
---|
163 | double atan( double x, double y ) { return atan2( x, y ); }
|
---|
164 | long double atan( long double x, long double y ) { return atan2l( x, y ); }
|
---|
165 |
|
---|
166 | //---------------------- Hyperbolic ----------------------
|
---|
167 |
|
---|
168 | float sinh( float x ) { return sinhf( x ); }
|
---|
169 | long double sinh( long double x ) { return sinhl( x ); }
|
---|
170 | float _Complex sinh( float _Complex x ) { return csinhf( x ); }
|
---|
171 | double _Complex sinh( double _Complex x ) { return csinh( x ); }
|
---|
172 | long double _Complex sinh( long double _Complex x ) { return csinhl( x ); }
|
---|
173 |
|
---|
174 | float cosh( float x ) { return coshf( x ); }
|
---|
175 | long double cosh( long double x ) { return coshl( x ); }
|
---|
176 | float _Complex cosh( float _Complex x ) { return ccoshf( x ); }
|
---|
177 | double _Complex cosh( double _Complex x ) { return ccosh( x ); }
|
---|
178 | long double _Complex cosh( long double _Complex x ) { return ccoshl( x ); }
|
---|
179 |
|
---|
180 | float tanh( float x ) { return tanhf( x ); }
|
---|
181 | long double tanh( long double x ) { return tanhl( x ); }
|
---|
182 | float _Complex tanh( float _Complex x ) { return ctanhf( x ); }
|
---|
183 | double _Complex tanh( double _Complex x ) { return ctanh( x ); }
|
---|
184 | long double _Complex tanh( long double _Complex x ) { return ctanhl( x ); }
|
---|
185 |
|
---|
186 | float asinh( float x ) { return asinhf( x ); }
|
---|
187 | long double asinh( long double x ) { return asinhl( x ); }
|
---|
188 | float _Complex asinh( float _Complex x ) { return casinhf( x ); }
|
---|
189 | double _Complex asinh( double _Complex x ) { return casinh( x ); }
|
---|
190 | long double _Complex asinh( long double _Complex x ) { return casinhl( x ); }
|
---|
191 |
|
---|
192 | float acosh( float x ) { return acoshf( x ); }
|
---|
193 | long double acosh( long double x ) { return acoshl( x ); }
|
---|
194 | float _Complex acosh( float _Complex x ) { return cacoshf( x ); }
|
---|
195 | double _Complex acosh( double _Complex x ) { return cacosh( x ); }
|
---|
196 | long double _Complex acosh( long double _Complex x ) { return cacoshl( x ); }
|
---|
197 |
|
---|
198 | float atanh( float x ) { return atanhf( x ); }
|
---|
199 | long double atanh( long double x ) { return atanhl( x ); }
|
---|
200 | float _Complex atanh( float _Complex x ) { return catanhf( x ); }
|
---|
201 | double _Complex atanh( double _Complex x ) { return catanh( x ); }
|
---|
202 | long double _Complex atanh( long double _Complex x ) { return catanhl( x ); }
|
---|
203 |
|
---|
204 | //---------------------- Error / Gamma ----------------------
|
---|
205 |
|
---|
206 | float erf( float x ) { return erff( x ); }
|
---|
207 | long double erf( long double x ) { return erfl( x ); }
|
---|
208 | // float _Complex erf( float _Complex x ) { return crflf( x ); }
|
---|
209 | // double _Complex erf( double _Complex x ) { return crfl( x ); }
|
---|
210 | // long double _Complex erf( long double _Complex x ) { return crfll( x ); }
|
---|
211 |
|
---|
212 | float erfc( float x ) { return erfcf( x ); }
|
---|
213 | long double erfc( long double x ) { return erfcl( x ); }
|
---|
214 | // float _Complex erfc( float _Complex x ) { return cerfcf( x ); }
|
---|
215 | // double _Complex erfc( double _Complex x ) { return cerfc( x ); }
|
---|
216 | // long double _Complex erfc( long double _Complex x ) { return cerfcl( x ); }
|
---|
217 |
|
---|
218 | float lgamma( float x ) { return lgammaf( x ); }
|
---|
219 | long double lgamma( long double x ) { return lgammal( x ); }
|
---|
220 | float lgamma( float x, int *sign ) { return lgammaf_r( x, sign ); }
|
---|
221 | double lgamma( double x, int *sign ) { return lgamma_r( x, sign ); }
|
---|
222 | long double lgamma( long double x, int *sign ) { return lgammal_r( x, sign ); }
|
---|
223 |
|
---|
224 | float tgamma( float x ) { return tgammaf( x ); }
|
---|
225 | long double tgamma( long double x ) { return tgammal( x ); }
|
---|
226 |
|
---|
227 | //---------------------- Nearest Integer ----------------------
|
---|
228 |
|
---|
229 | float floor( float x ) { return floorf( x ); }
|
---|
230 | long double floor( long double x ) { return floorl( x ); }
|
---|
231 |
|
---|
232 | float ceil( float x ) { return ceilf( x ); }
|
---|
233 | long double ceil( long double x ) { return ceill( x ); }
|
---|
234 |
|
---|
235 | float trunc( float x ) { return truncf( x ); }
|
---|
236 | long double trunc( long double x ) { return truncl( x ); }
|
---|
237 |
|
---|
238 | float rint( float x ) { return rintf( x ); }
|
---|
239 | long double rint( long double x ) { return rintl( x ); }
|
---|
240 | long int rint( float x ) { return lrintf( x ); }
|
---|
241 | long int rint( double x ) { return lrint( x ); }
|
---|
242 | long int rint( long double x ) { return lrintl( x ); }
|
---|
243 | long long int rint( float x ) { return llrintf( x ); }
|
---|
244 | long long int rint( double x ) { return llrint( x ); }
|
---|
245 | long long int rint( long double x ) { return llrintl( x ); }
|
---|
246 |
|
---|
247 | long int lrint( float x ) { return lrintf( x ); }
|
---|
248 | long int lrint( long double x ) { return lrintl( x ); }
|
---|
249 | long long int llrint( float x ) { return llrintf( x ); }
|
---|
250 | long long int llrint( long double x ) { return llrintl( x ); }
|
---|
251 |
|
---|
252 | float nearbyint( float x ) { return nearbyintf( x ); }
|
---|
253 | long double nearbyint( long double x ) { return nearbyintl( x ); }
|
---|
254 |
|
---|
255 | float round( float x ) { return roundf( x ); }
|
---|
256 | long double round( long double x ) { return roundl( x ); }
|
---|
257 | long int round( float x ) { return lroundf( x ); }
|
---|
258 | long int round( double x ) { return lround( x ); }
|
---|
259 | long int round( long double x ) { return lroundl( x ); }
|
---|
260 | long long int round( float x ) { return llroundf( x ); }
|
---|
261 | long long int round( double x ) { return llround( x ); }
|
---|
262 | long long int round( long double x ) { return llroundl( x ); }
|
---|
263 |
|
---|
264 | long int lround( float x ) { return lroundf( x ); }
|
---|
265 | long int lround( long double x ) { return lroundl( x ); }
|
---|
266 | long long int llround( float x ) { return llroundf( x ); }
|
---|
267 | long long int llround( long double x ) { return llroundl( x ); }
|
---|
268 |
|
---|
269 | //---------------------- Manipulation ----------------------
|
---|
270 |
|
---|
271 | float copysign( float x, float y ) { return copysignf( x, y ); }
|
---|
272 | long double copysign( long double x, long double y ) { return copysignl( x, y ); }
|
---|
273 |
|
---|
274 | float frexp( float x, int *ip ) { return frexpf( x, ip ); }
|
---|
275 | long double frexp( long double x, int *ip ) { return frexpl( x, ip ); }
|
---|
276 |
|
---|
277 | float ldexp( float x, int exp2 ) { return ldexpf( x, exp2 ); }
|
---|
278 | long double ldexp( long double x, int exp2 ) { return ldexpl( x, exp2 ); }
|
---|
279 |
|
---|
280 | // [ float, float ] modf( float x ) { float i; x = modff( x, &i ); return [ i, x ]; }
|
---|
281 | float modf( float x, float *i ) { return modff( x, i ); }
|
---|
282 | // [ double, double ] modf( double x ) { double i; x = modf( x, &i ); return [ i, x ]; }
|
---|
283 | // [ long double, long double ] modf( long double x ) { long double i; x = modfl( x, &i ); return [ i, x ]; }
|
---|
284 | long double modf( long double x, long double *i ) { return modfl( x, i ); }
|
---|
285 |
|
---|
286 | float nextafter( float x, float y ) { return nextafterf( x, y ); }
|
---|
287 | long double nextafter( long double x, long double y ) { return nextafterl( x, y ); }
|
---|
288 |
|
---|
289 | float nexttoward( float x, long double y ) { return nexttowardf( x, y ); }
|
---|
290 | long double nexttoward( long double x, long double y ) { return nexttowardl( x, y ); }
|
---|
291 |
|
---|
292 | float scalbn( float x, int exp ) { return scalbnf( x, exp ); }
|
---|
293 | long double scalbn( long double x, int exp ) { return scalbnl( x, exp ); }
|
---|
294 | float scalbn( float x, long int exp ) { return scalblnf( x, exp ); }
|
---|
295 | double scalbn( double x, long int exp ) { return scalbln( x, exp ); }
|
---|
296 | long double scalbn( long double x, long int exp ) { return scalblnl( x, exp ); }
|
---|
297 |
|
---|
298 | float scalbln( float x, long int exp ) { return scalblnf( x, exp ); }
|
---|
299 | long double scalbln( long double x, long int exp ) { return scalblnl( x, exp ); }
|
---|
300 |
|
---|
301 | // Local Variables: //
|
---|
302 | // mode: c //
|
---|
303 | // tab-width: 4 //
|
---|
304 | // End: //
|
---|