Rudiments
|
00001 // Copyright (c) 2004 David Muse 00002 // See the COPYING file for more information. 00003 00004 #ifndef RUDIMENTS_MATH_H 00005 #define RUDIMENTS_MATH_H 00006 00007 #include <rudiments/private/mathincludes.h> 00008 00009 #ifdef RUDIMENTS_NAMESPACE 00010 namespace rudiments { 00011 #endif 00012 00013 class RUDIMENTS_DLLSPEC math { 00014 public: 00015 static int32_t absoluteValue(int32_t j); 00016 static div_t divide(int32_t numer, int32_t denom); 00017 00018 static long absoluteValue(long j); 00019 static ldiv_t divide(long numer, long denom); 00020 00021 static int64_t absoluteValue(int64_t j); 00022 static lldiv_t divide(int64_t numer, int64_t denom); 00023 00024 static bool isFinite(float x); 00025 static bool isInfinite(float x); 00026 00027 static bool isNaN(float x); 00028 static bool areNaN(float x, float y); 00029 00030 static bool isNormal(float x); 00031 static bool isSubNormal(float x); 00032 00033 static bool isGreater(float x, float y); 00034 static bool isGreaterOrEqual(float x, float y); 00035 static bool isLess(float x, float y); 00036 static bool isLessOrEqual(float x, float y); 00037 static bool isLessOrGreater(float x, float y); 00038 00039 static bool isSignBitSet(float x); 00040 static float copySignBit(float x, float y); 00041 00042 static float arcCosine(float x); 00043 static float arcSine(float x); 00044 static float arcTangent(float x); 00045 static float arcTangent(float y, float x); 00046 00047 static float cosine(float x); 00048 static float sine(float x); 00049 static float tangent(float x); 00050 00051 static float hyperbolicArcCosine(float x); 00052 static float hyperbolicArcSine(float x); 00053 static float hyperbolicArcTangent(float x); 00054 00055 static float hyperbolicCosine(float x); 00056 static float hyperbolicSine(float x); 00057 static float hyperbolicTangent(float x); 00058 00059 static float naturalExponent(float x); 00060 static float naturalLog(float x); 00061 static float naturalExponentMinusOne(float x); 00062 static float naturalLogPlusOne(float x); 00063 00064 static float exponent(float x); 00065 00066 static float normalize(float x, int32_t *exp); 00067 00068 static float logBase10(float x); 00069 00070 static float exponentBase2(float x); 00071 static float logBase2(float x); 00072 00073 static float power(float x, float y); 00074 00075 static float squareRoot(float x); 00076 static float cubeRoot(float x); 00077 00078 static float hypotenuse(float x, float y); 00079 00080 static float computeExponent(float x); 00081 static int32_t integralExponent(float x); 00082 static float loadExponent(float x, int32_t exp); 00083 00084 static float ceiling(float x); 00085 static float floor(float x); 00086 static float absoluteValue(float x); 00087 00088 static float remainder(float x, float y); 00089 static float remainder(float x, float y, int32_t *quo); 00090 00091 static float truncate(float x); 00092 static float nearbyInteger(float x); 00093 static float round(float x); 00094 static float roundInexact(float x); 00095 static long roundToLong(float x); 00096 static int64_t roundToLongLong(float x); 00097 static long roundAwayFromZeroToLong(float x); 00098 static int64_t roundAwayFromZeroToLongLong(float x); 00099 static float nextAfter(float x, float y); 00100 static float nextToward(float x, float y); 00101 00102 static float errorFunction(float x); 00103 static float complementaryErrorFunction(float x); 00104 00105 static float trueGamma(float x); 00106 static float naturalLogGamma(float x); 00107 00108 static float scaleByRadixToPower(float x, float n); 00109 static float scaleByRadixToPower(float x, int32_t n); 00110 static float scaleByRadixToPower(float x, long n); 00111 00112 static float larger(float x, float y); 00113 static float smaller(float x, float y); 00114 00115 static float multiplyAndAdd(float x, float y, float z); 00116 static float positiveDifference(float x, float y); 00117 00118 static float argument(float complex z); 00119 static float complex conjugate(float complex z); 00120 static float complex project(float complex z); 00121 static float imaginary(float complex z); 00122 static float real(float complex z); 00123 00124 00125 00126 00127 // double methods 00128 static bool isFinite(double x); 00129 static bool isInfinite(double x); 00130 00131 static bool isNaN(double x); 00132 static bool areNaN(double x, double y); 00133 00134 static bool isNormal(double x); 00135 static bool isSubNormal(double x); 00136 00137 static bool isGreater(double x, double y); 00138 static bool isGreaterOrEqual(double x, double y); 00139 static bool isLess(double x, double y); 00140 static bool isLessOrEqual(double x, double y); 00141 static bool isLessOrGreater(double x, double y); 00142 00143 static bool isSignBitSet(double x); 00144 static double copySignBit(double x, double y); 00145 00146 static double arcCosine(double x); 00147 static double arcSine(double x); 00148 static double arcTangent(double x); 00149 static double arcTangent(double y, double x); 00150 00151 static double cosine(double x); 00152 static double sine(double x); 00153 static double tangent(double x); 00154 00155 static double hyperbolicArcCosine(double x); 00156 static double hyperbolicArcSine(double x); 00157 static double hyperbolicArcTangent(double x); 00158 00159 static double hyperbolicCosine(double x); 00160 static double hyperbolicSine(double x); 00161 static double hyperbolicTangent(double x); 00162 00163 static double naturalExponent(double x); 00164 static double naturalLog(double x); 00165 static double naturalExponentMinusOne(double x); 00166 static double naturalLogPlusOne(double x); 00167 00168 static double exponent(double x); 00169 00170 static double normalize(double x, int32_t *exp); 00171 00172 static double logBase10(double x); 00173 00174 static double exponentBase2(double x); 00175 static double logBase2(double x); 00176 00177 static double power(double x, double y); 00178 00179 static double squareRoot(double x); 00180 static double cubeRoot(double x); 00181 00182 static double hypotenuse(double x, double y); 00183 00184 static double computeExponent(double x); 00185 static int32_t integralExponent(double x); 00186 static double loadExponent(double x, int32_t exp); 00187 00188 static double ceiling(double x); 00189 static double floor(double x); 00190 static double absoluteValue(double x); 00191 00192 static double remainder(double x, double y); 00193 static double remainder(double x, double y, int32_t *quo); 00194 00195 static double truncate(double x); 00196 static double nearbyInteger(double x); 00197 static double round(double x); 00198 static double roundInexact(double x); 00199 static long roundToLong(double x); 00200 static int64_t roundToLongLong(double x); 00201 static long roundAwayFromZeroToLong(double x); 00202 static int64_t roundAwayFromZeroToLongLong(double x); 00203 static double nextAfter(double x, double y); 00204 static double nextToward(double x, double y); 00205 00206 static double errorFunction(double x); 00207 static double complementaryErrorFunction(double x); 00208 00209 static double trueGamma(double x); 00210 static double naturalLogGamma(double x); 00211 00212 static double scaleByRadixToPower(double x, double n); 00213 static double scaleByRadixToPower(double x, int32_t n); 00214 static double scaleByRadixToPower(double x, long n); 00215 00216 static double larger(double x, double y); 00217 static double smaller(double x, double y); 00218 00219 static double multiplyAndAdd(double x, double y, double z); 00220 static double positiveDifference(double x, double y); 00221 00222 static double argument(double complex z); 00223 static double complex conjugate(double complex z); 00224 static double complex project(double complex z); 00225 static double imaginary(double complex z); 00226 static double real(double complex z); 00227 00228 00229 // long double methods 00230 static bool isFinite(long double x); 00231 static bool isInfinite(long double x); 00232 00233 static bool isNaN(long double x); 00234 static bool areNaN(long double x, long double y); 00235 00236 static bool isNormal(long double x); 00237 static bool isSubNormal(long double x); 00238 00239 static bool isGreater(long double x, long double y); 00240 static bool isGreaterOrEqual(long double x, long double y); 00241 static bool isLess(long double x, long double y); 00242 static bool isLessOrEqual(long double x, long double y); 00243 static bool isLessOrGreater(long double x, long double y); 00244 00245 static bool isSignBitSet(long double x); 00246 static long double copySignBit(long double x, 00247 long double y); 00248 00249 static long double arcCosine(long double x); 00250 static long double arcSine(long double x); 00251 static long double arcTangent(long double x); 00252 static long double arcTangent(long double y, 00253 long double x); 00254 00255 static long double cosine(long double x); 00256 static long double sine(long double x); 00257 static long double tangent(long double x); 00258 00259 static long double hyperbolicArcCosine(long double x); 00260 static long double hyperbolicArcSine(long double x); 00261 static long double hyperbolicArcTangent(long double x); 00262 00263 static long double hyperbolicCosine(long double x); 00264 static long double hyperbolicSine(long double x); 00265 static long double hyperbolicTangent(long double x); 00266 00267 static long double naturalExponent(long double x); 00268 static long double naturalLog(long double x); 00269 static long double naturalExponentMinusOne(long double x); 00270 static long double naturalLogPlusOne(long double x); 00271 00272 static long double exponent(long double x); 00273 00274 static long double normalize(long double x, int32_t *exp); 00275 00276 static long double logBase10(long double x); 00277 00278 static long double exponentBase2(long double x); 00279 static long double logBase2(long double x); 00280 00281 static long double power(long double x, long double y); 00282 00283 static long double squareRoot(long double x); 00284 static long double cubeRoot(long double x); 00285 00286 static long double hypotenuse(long double x, 00287 long double y); 00288 00289 static long double computeExponent(long double x); 00290 static int32_t integralExponent(long double x); 00291 static long double loadExponent(long double x, 00292 int32_t exp); 00293 00294 static long double ceiling(long double x); 00295 static long double floor(long double x); 00296 static long double absoluteValue(long double x); 00297 00298 static long double remainder(long double x, 00299 long double y); 00300 static long double remainder(long double x, 00301 long double y, 00302 int32_t *quo); 00303 00304 static long double truncate(long double x); 00305 static long double nearbyInteger(long double x); 00306 static long double round(long double x); 00307 static long double roundInexact(long double x); 00308 static long roundToLong(long double x); 00309 static int64_t roundToLongLong(long double x); 00310 static long roundAwayFromZeroToLong(long double x); 00311 static int64_t roundAwayFromZeroToLongLong( 00312 long double x); 00313 static long double nextAfter(long double x, 00314 long double y); 00315 static long double nextToward(long double x, 00316 long double y); 00317 00318 static long double errorFunction(long double x); 00319 static long double complementaryErrorFunction( 00320 long double x); 00321 00322 static long double trueGamma(long double x); 00323 static long double naturalLogGamma(long double x); 00324 00325 00326 static long double scaleByRadixToPower(long double x, 00327 long double n); 00328 static long double scaleByRadixToPower(long double x, 00329 int32_t n); 00330 static long double scaleByRadixToPower(long double x, 00331 long n); 00332 00333 static long double larger(long double x, long double y); 00334 static long double smaller(long double x, long double y); 00335 00336 static long double multiplyAndAdd(long double x, 00337 long double y, 00338 long double z); 00339 static long double positiveDifference(long double x, 00340 long double y); 00341 00342 static long double argument(long double complex z); 00343 static long double complex conjugate(long double complex z); 00344 static long double complex project(long double complex z); 00345 static long double imaginary(long double complex z); 00346 static long double real(long double complex z); 00347 00348 00349 // may not be in solaris - 00350 // inttypes.h - some integer math functions 00351 // imaxabs(),imaxdiv() 00352 // strtoimax(),strtoumax(),wcstoimax(),wcstoumax() 00353 // not in solaris - 00354 // sys/param.h - howmany(),roundup(),powerof2(),MIN(),MAX() 00355 00356 }; 00357 00358 #ifdef RUDIMENTS_NAMESPACE 00359 } 00360 #endif 00361 00362 #ifdef ENABLE_RUDIMENTS_INLINES 00363 #include <rudiments/private/mathinlines.h> 00364 #endif 00365 00366 #endif