📄 mathfunc.h
字号:
typedef long double T_numtype1;
typedef long double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(log)((long double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log(";
a.prettyPrint(str,format);
str += ")";
}
};
// log(complex<float> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_log<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(log)((complex<float> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// log(complex<double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_log<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(log)((complex<double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// log(complex<long double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_log<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(log)((complex<long double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// logb(P_numtype1) Unbiased exponent (IEEE)
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_logb : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(logb)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "logb(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// log1p(P_numtype1) Compute log(1 + x)
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_log1p : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(log1p)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log1p(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// log10(P_numtype1) Logarithm base 10
template<class P_numtype1>
class _bz_log10 : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(log10)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log10(";
a.prettyPrint(str,format);
str += ")";
}
};
// log10(float)
template<>
class _bz_log10<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(log10)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log10(";
a.prettyPrint(str,format);
str += ")";
}
};
// log10(long double)
template<>
class _bz_log10<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(log10)((long double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "log10(";
a.prettyPrint(str,format);
str += ")";
}
};
// nearest(P_numtype1) Nearest floating point integer
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1>
class _bz_nearest : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(nearest)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "nearest(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// nextafter(P_numtype1, P_numtype2) Next representable number after x towards y
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1, class P_numtype2>
class _bz_nextafter : 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(nextafter)((double)x,(double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "nextafter(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
template<class P_numtype>
class _bz_negate : public OneOperandApplicativeTemplatesBase {
public:
typedef BZ_SIGNEDTYPE(P_numtype) T_numtype;
static inline T_numtype apply(T_numtype x)
{ return -x; }
};
// norm(P_numtype1)
#ifdef BZ_HAVE_COMPLEX_MATH
template<class P_numtype1>
class _bz_norm : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef P_numtype1 T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_CMATHFN_SCOPE(norm)(x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "norm(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// polar(P_numtype1, P_numtype2)
#ifdef BZ_HAVE_COMPLEX_MATH
template<class P_numtype1, class P_numtype2>
class _bz_polar : public TwoOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef P_numtype2 T_numtype2;
typedef complex<T_numtype1> T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_CMATHFN_SCOPE(polar)(x,y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "polar(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// pow(P_numtype1, P_numtype2) Power
template<class P_numtype1, class P_numtype2>
class _bz_pow : 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_MATHFN_SCOPE(pow)((double)x,(double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "pow(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
// pow(float, float)
template<>
class _bz_pow<float, float > : public TwoOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype2;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_MATHFN_SCOPE(pow)((float)x,(float)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "pow(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
// pow(long double, long double)
template<>
class _bz_pow<long double, long double > : public TwoOperandApplicativeTemplatesBase {
public:
typedef long double T_numtype1;
typedef long double T_numtype2;
typedef long double T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_MATHFN_SCOPE(pow)((long double)x,(long double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "pow(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
// pow(complex<float>, complex<float>)
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_pow<complex<float>, complex<float> > : public TwoOperandApplicativeTemplatesBase {
public:
typedef complex<float> T_numtype1;
typedef complex<float> T_numtype2;
typedef complex<float> T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_CMATHFN_SCOPE(pow)((complex<float>)x,(complex<float>)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "pow(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// pow(complex<double>, complex<double>)
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_pow<complex<double>, complex<double> > : public TwoOperandApplicativeTemplatesBase {
public:
typedef complex<double> T_numtype1;
typedef complex<double> T_numtype2;
typedef complex<double> T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_CMATHFN_SCOPE(pow)((complex<double>)x,(complex<double>)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "pow(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// pow(complex<long double>, complex<long double>)
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_pow<complex<long double>, complex<long double> > : public TwoOperandApplicativeTemplatesBase {
public:
typedef complex<long double> T_numtype1;
typedef complex<long double> T_numtype2;
typedef complex<long double> T_numtype;
static inline T_numtype apply(T_numtype1 x, T_numtype2 y)
{ return BZ_CMATHFN_SCOPE(pow)((complex<long double>)x,(complex<long double>)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "pow(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// remainder(P_numtype1, P_numtype2) Remainder
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1, class P_numtype2>
class _bz_remainder : 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(remainder)((double)x,(double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "remainder(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// rint(P_numtype1) Round to floating point integer
#ifdef BZ_HAVE_IEEE_MATH
template<class P_numtype1>
class _bz_rint : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(rint)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "rint(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// rsqrt(P_numtype1) Reciprocal square root
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1>
class _bz_rsqrt : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_IEEEMATHFN_SCOPE(rsqrt)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "rsqrt(";
a.prettyPrint(str,format);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -