📄 integral.h
字号:
// static double ceil(double arg) { return ::ceil(arg); } // method: cos // static double cos(double arg) { return ::cos(arg); } // method: cosh // static double cosh(double arg) { return ::cosh(arg); } // method: exp // static double exp(double arg) { return ::exp(arg); } // method: exp2 // static double exp2(double arg) { return ::exp(arg * LN2); } // method: exp10 // static double exp10(double arg) { return ::exp(arg * LN10); } // method: floor // static double floor(double arg) { return ::floor(arg); } // method: fraction // static double fraction(double arg) { static double temp; return ::modf(arg, &temp); } // method: hash // hash methods for byte, ushort, short, ulong, llong, ullong, // float, double, long. static ulong hash(byte val, ulong capacity) { ulong temp = (ulong)val; return hash_32(temp, capacity); } static ulong hash(ushort val, ulong capacity) { ulong temp = (ulong)val; return hash_32(temp, capacity); } static ulong hash(short val, ulong capacity) { int32 copy = (int32) val; int32 temp = *((int32*) ©); return hash_32(temp, capacity); } static ulong hash(ulong val, ulong capacity) { return hash_32(val, capacity); } static ulong hash(llong val, ulong capacity) { int64 copy = (int64) val; int64 temp = *((int64*) ©); return hash_64(temp, capacity); } static ulong hash(ullong val, ulong capacity) { ullong temp = (ullong)val; return hash_64(temp, capacity); } static ulong hash(float val, ulong capacity) { // we don't know what size a float is so we move it to a 32 bit number // so we can guarantee the size // float32 copy = (float32) val; // we want to reinterpret those 32 bits as an integer. If we were to // cast then we would greatly reduce the variability in the possible // numbers. Instead, we cast the location pointer to an integer pointer // so the the 32-bit float will be interpreted as a 32-bit integer // the full range of variablity in the 32 bits is preserved // int32 temp = *((int32*) ©); return hash_32(temp, capacity); } static ulong hash(double val, ulong capacity) { float64 copy = (float64) val; int64 temp = *((int64*) ©); return hash_64(temp, capacity); } static ulong hash(long val, ulong capacity) { int32 copy = (int32) val; int32 temp = *((int32*) ©); return hash_32(temp, capacity); } // method: hash // for 32 bits single value static ulong hash_32(ulong val, ulong capacity) { return val % (capacity - 1); } // method: hash_64 // for 64 bits single value static ulong hash_64(ullong val, ulong capacity) { return val % (capacity - 1); } // for 32 bits vector static long hash(ulong* vector, long num_elements, long capacity); // method: integer // static double integer(double arg) { static double integ; ::modf(arg, &integ); return integ; } // method: log // static double log(double arg) { return ::log(arg); } // method: log2 // static double log2(double arg) { return ::log(arg) * INV_LN2; } // method: log10 // static double log10(double arg) { return ::log10(arg); } // method: log1p // static double log1p(double arg) { return ::log((double)1 + arg); } // method: max // static double max(double arg1, double arg2) { if (arg1 > arg2) { return arg1; } else { return arg2; } } // method: min // static double min(double arg1, double arg2) { if (arg1 < arg2) { return arg1; } else { return arg2; } } // method: pow // static double pow(double arg, double exponent) { return ::pow(arg, exponent); } // method: round // static double round(double arg) { if (arg > (double)0) { return ::floor(arg + 0.5); } else { return ::ceil(arg - 0.5); } } // method: sin // static double sin(double arg) { return ::sin(arg); } // method: sinh // static double sinh(double arg) { return ::sinh(arg); } // method: sleep // static boolean sleep(long sleep_seconds) { ::sleep(sleep_seconds); return true; } // method: sqrt // static double sqrt(double arg) { return ::sqrt(arg); } // method: tan // static double tan(double arg) { return ::tan(arg); } // method: tanh // static double tanh(double arg) { return ::tanh(arg); } //--------------------------------------------------------------------------- // // class-specific public methods: // complex versions of math and other C functions (listed alphabetically) // // the implementations used below can be found in: // // R.V. Churchill, J.W. Brown, and R.F. Verhey, // Complex Variables and Applications, Mc-Graw Hill, // New York, New York, USA, 1976, pp. 52-71. // //--------------------------------------------------------------------------- // method: abs // static double abs(const complexdouble& arg) { return arg.mag(); } // method: acos // static complexdouble acos(const complexdouble& arg) { static const complexdouble j(0, 1); return (complexdouble)-1 * j * log(arg + j * sqrt((complexdouble)1 - arg * arg)); } // method: acosh // static complexdouble acosh(const complexdouble& arg) { return complexdouble (log(arg + sqrt(arg * arg - (complexdouble)1))); } // method: asin // static complexdouble asin(const complexdouble& arg) { static const complexdouble j(0, 1); return (complexdouble)-1 * j * log((j * arg) + sqrt((complexdouble)1 - (arg * arg))); } // method: asinh // static complexdouble asinh(const complexdouble& arg) { return complexdouble(log(arg + sqrt(arg * arg + (complexdouble)1))); } // method: atan // static complexdouble atan(const complexdouble& arg) { static const complexdouble j(0, 1); return log((j + arg) / (j - arg)) * j / (complexdouble)2; } // method: atanh // static complexdouble atanh(const complexdouble& arg) { return log(((complexdouble)1 + arg) / ((complexdouble)1 - arg)) / (complexdouble)2; } // method: ceil // static complexdouble ceil(const complexdouble& arg) { return complexdouble(ceil(arg.real()), ceil(arg.imag())); } // method: cos // static complexdouble cos(const complexdouble& arg) { return complexdouble(cos(arg.real()) * cosh(arg.imag()), - sin(arg.real()) * sinh(arg.imag())); } // method: cosh // static complexdouble cosh(const complexdouble& arg) { return complexdouble(cosh(arg.real()) * cos(arg.imag()), + sinh(arg.real()) * sin(arg.imag())); } // method: exp // static complexdouble exp(const complexdouble& arg) { return complexdouble::polar(exp(arg.real()), arg.imag()); } // method: exp2 // static complexdouble exp2(const complexdouble& arg) { return exp(arg * LN2); } // method: exp10 // static complexdouble exp10(const complexdouble& arg) { return exp(arg * LN10); } // method: floor // static complexdouble floor(const complexdouble& arg) { return complexdouble(floor(arg.real()), floor(arg.imag())); } // method: log // static complexdouble log(const complexdouble& arg) { return complexdouble(log(arg.mag()), arg.angle()); } // method: log2 // static complexdouble log2(const complexdouble& arg) { return log(arg) * INV_LN2; } // method: log10 // static complexdouble log10(const complexdouble& arg) { return log(arg) * INV_LN10; } // method: log1p // static complexdouble log1p(const complexdouble& arg) { return log((complexdouble)1 + arg); } // method: max // static complexdouble max(const complexdouble& arg1, const complexdouble& arg2) { if (arg1 >= arg2) { return arg1; } else { return arg2; } } // method: min // static complexdouble min(const complexdouble& arg1, const complexdouble& arg2) { if (arg1 < arg2) { return arg1; } else { return arg2; } } // method: pow // static complexdouble pow(const complexdouble& arg, const complexdouble& exponent) { return exp(exponent * log(arg)); } // method: round // static complexdouble round(const complexdouble& arg) { return complexdouble(round(arg.real()), round(arg.imag())); } // method: sin // static complexdouble sin(const complexdouble& arg) { return complexdouble(sin(arg.real()) * cosh(arg.imag()), cos(arg.real()) * sinh(arg.imag())); } // method: sinh // static complexdouble sinh(const complexdouble& arg) { return complexdouble(sinh(arg.real()) * cos(arg.imag()), cosh(arg.real()) * sin(arg.imag())); } // method: sqrt // static complexdouble sqrt(const complexdouble& arg) { double r = arg.mag(); double nr, ni; if (r == 0.0) { ni = r; nr = r; } else if (arg.real() > 0) { nr = sqrt(0.5 * (r + arg.real())); ni = arg.imag() / nr; ni /= 2; } else { ni = sqrt(0.5 * (r - arg.real())); if (arg.imag() < 0) { ni = -ni; } nr = arg.imag() / ni; nr /= 2; } return complexdouble(nr, ni); } // method: tan // static complexdouble tan(const complexdouble& arg) { return sin(arg) / cos(arg); } // method: tanh // static complexdouble tanh(const complexdouble& arg) { return sinh(arg) / cosh(arg); } //--------------------------------------------------------------------------- // // class-specific public methods: // other math functions that are useful for speech research // //--------------------------------------------------------------------------- // logarithm-related methods // static double logAddLog(const double x, const double y); //--------------------------------------------------------------------------- // // class-specific public methods: // other time functions that are useful for speech research // //--------------------------------------------------------------------------- // method: time // static long time() { long* p = (long*)NULL; return ::time(p); } //--------------------------------------------------------------------------- // // private methods // //---------------------------------------------------------------------------private: // destructor/constructor(s): // these methods are private so the class cannot be instantiated. // ~Integral(); Integral(); Integral(const Integral& arg);};// end of include file//#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -