source: src/libcfa/math @ 38ef0de

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 38ef0de was a603f06, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

add comments

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