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