📄 mathfunc.h
字号:
str += ")";
}
};
#endif
// scalb(P_numtype1, P_numtype2) x * (2**y)
#ifdef BZ_HAVE_SYSTEM_V_MATH
template<class P_numtype1, class P_numtype2>
class _bz_scalb : 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(scalb)((double)x,(double)y); }
template<class T1, class T2>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a, const T2& b)
{
str += "scalb(";
a.prettyPrint(str,format);
str += ",";
b.prettyPrint(str,format);
str += ")";
}
};
#endif
// sin(P_numtype1) Sine
template<class P_numtype1>
class _bz_sin : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(sin)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sin(";
a.prettyPrint(str,format);
str += ")";
}
};
// sin(float)
template<>
class _bz_sin<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(sin)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sin(";
a.prettyPrint(str,format);
str += ")";
}
};
// sin(long double)
template<>
class _bz_sin<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(sin)((long double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sin(";
a.prettyPrint(str,format);
str += ")";
}
};
// sin(complex<float> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sin<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(sin)((complex<float> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sin(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sin(complex<double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sin<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(sin)((complex<double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sin(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sin(complex<long double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sin<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(sin)((complex<long double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sin(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sinh(P_numtype1) Hyperbolic sine
template<class P_numtype1>
class _bz_sinh : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(sinh)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sinh(";
a.prettyPrint(str,format);
str += ")";
}
};
// sinh(float)
template<>
class _bz_sinh<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(sinh)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sinh(";
a.prettyPrint(str,format);
str += ")";
}
};
// sinh(long double)
template<>
class _bz_sinh<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(sinh)((long double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sinh(";
a.prettyPrint(str,format);
str += ")";
}
};
// sinh(complex<float> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sinh<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(sinh)((complex<float> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sinh(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sinh(complex<double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sinh<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(sinh)((complex<double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sinh(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sinh(complex<long double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sinh<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(sinh)((complex<long double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sinh(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
template<class P_numtype>
class _bz_sqr : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype T_numtype;
static inline T_numtype apply(T_numtype x)
{ return x*x; }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqr(";
a.prettyPrint(str,format);
str += ")";
}
};
#ifdef BZ_HAVE_COMPLEX_MATH
// Specialization of _bz_sqr for complex<T>
template<class T>
class _bz_sqr<complex<T> > : public OneOperandApplicativeTemplatesBase {
public:
typedef complex<T> T_numtype;
static inline T_numtype apply(T_numtype x)
{
T r = x.real(); T i = x.imag();
return T_numtype(r*r-i*i, 2*r*i);
}
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqr(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sqrt(P_numtype1) Square root
template<class P_numtype1>
class _bz_sqrt : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(sqrt)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqrt(";
a.prettyPrint(str,format);
str += ")";
}
};
// sqrt(float)
template<>
class _bz_sqrt<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(sqrt)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqrt(";
a.prettyPrint(str,format);
str += ")";
}
};
// sqrt(long double)
template<>
class _bz_sqrt<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(sqrt)((long double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqrt(";
a.prettyPrint(str,format);
str += ")";
}
};
// sqrt(complex<float> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sqrt<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(sqrt)((complex<float> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqrt(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sqrt(complex<double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sqrt<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(sqrt)((complex<double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqrt(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// sqrt(complex<long double> )
#ifdef BZ_HAVE_COMPLEX_MATH
template<>
class _bz_sqrt<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(sqrt)((complex<long double> )x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "sqrt(";
a.prettyPrint(str,format);
str += ")";
}
};
#endif
// tan(P_numtype1) Tangent
template<class P_numtype1>
class _bz_tan : public OneOperandApplicativeTemplatesBase {
public:
typedef P_numtype1 T_numtype1;
typedef double T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(tan)((double)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "tan(";
a.prettyPrint(str,format);
str += ")";
}
};
// tan(float)
template<>
class _bz_tan<float> : public OneOperandApplicativeTemplatesBase {
public:
typedef float T_numtype1;
typedef float T_numtype;
static inline T_numtype apply(T_numtype1 x)
{ return BZ_MATHFN_SCOPE(tan)((float)x); }
template<class T1>
static void prettyPrint(string& str, prettyPrintFormat& format,
const T1& a)
{
str += "tan(";
a.prettyPrint(str,format);
str += ")";
}
};
// tan(long double)
template<>
class _bz_tan<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(
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -