📄 mathfunc.h
字号:
typedef P_numtype2 T_numtype2;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_IEEEMATHFN_SCOPE(drem)((double)x,(double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "drem(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// exp(P_numtype1) Exponential
template<class P_numtype1>
class _bz_exp : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(exp)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "exp(";
a.prettyPrint(str,format);
str += ")";
}
};
// exp(float)
template<>
class _bz_exp<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(exp)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "exp(";
a.prettyPrint(str,format);
str += ")";
}
};
// exp(long double)
template<>
class _bz_exp<long double> : public OneOperandApplicativeTemplatesBase {
public:
typedef long double T_numtype1;
typedef long double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(exp)((long double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "exp(";
a.prettyPrint(str,format);
str += ")";
}
};
// exp(complex<float> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_exp<complex<float> > : public OneOperandApplicativeTemplatesBase {
public:
typedef complex<float> T_numtype1;
typedef complex<float> T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_CMATHFN_SCOPE(exp)((complex<float> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "exp(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// exp(complex<double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_exp<complex<double> > : public OneOperandApplicativeTemplatesBase {
public:
typedef complex<double> T_numtype1;
typedef complex<double> T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_CMATHFN_SCOPE(exp)((complex<double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "exp(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// exp(complex<long double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_exp<complex<long double> > : public OneOperandApplicativeTemplatesBase {
public:
typedef complex<long double> T_numtype1;
typedef complex<long double> T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_CMATHFN_SCOPE(exp)((complex<long double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "exp(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// expm1(P_numtype1) Exp(x)-1
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_expm1 : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(expm1)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "expm1(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// erf(P_numtype1) Error function
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_erf : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(erf)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "erf(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// erfc(P_numtype1) Complementary error function
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_erfc : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(erfc)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "erfc(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// floor(P_numtype1) Floor function
template<class P_numtype1>
class _bz_floor : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(floor)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "floor(";
a.prettyPrint(str,format);
str += ")";
}
};
// floor(float)
template<>
class _bz_floor<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(floor)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "floor(";
a.prettyPrint(str,format);
str += ")";
}
};
// floor(long double)
template<>
class _bz_floor<long double> : public OneOperandApplicativeTemplatesBase {
public:
typedef long double T_numtype1;
typedef long double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(floor)((long double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "floor(";
a.prettyPrint(str,format);
str += ")";
}
};
// fmod(P_numtype1, P_numtype2) Modulo remainder
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1, class P_numtype2>
class _bz_fmod : public TwoOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef P_numtype2 T_numtype2;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_IEEEMATHFN_SCOPE(fmod)((double)x,(double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "fmod(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// hypot(P_numtype1, P_numtype2) sqrt(x*x+y*y)
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1, class P_numtype2>
class _bz_hypot : public TwoOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef P_numtype2 T_numtype2;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_IEEEMATHFN_SCOPE(hypot)((double)x,(double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "hypot(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// ilogb(P_numtype1) Integer unbiased exponent
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1>
class _bz_ilogb : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef int T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(ilogb)(x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "ilogb(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// isnan(P_numtype1) Nonzero if NaNS or NaNQ
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_isnan : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef int T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(isnan)(x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "isnan(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// itrunc(P_numtype1) Truncate and convert to integer
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1>
class _bz_itrunc : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef int T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(itrunc)(x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "itrunc(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// j0(P_numtype1) Bessel function first kind, order 0
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_j0 : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(j0)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "j0(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// j1(P_numtype1) Bessel function first kind, order 1
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_j1 : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(j1)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "j1(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// lgamma(P_numtype1) Log absolute gamma
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_lgamma : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(lgamma)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "lgamma(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// log(P_numtype1) Natural logarithm
template<class P_numtype1>
class _bz_log : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(log)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log(";
a.prettyPrint(str,format);
str += ")";
}
};
// log(float)
template<>
class _bz_log<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(log)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log(";
a.prettyPrint(str,format);
str += ")";
}
};
// log(long double)
template<>
class _bz_log<long double> : public OneOperandApplicativeTemplatesBase {
public:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -