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