This commit is contained in:
2020-10-22 18:03:22 +03:00
parent 91c1487a7e
commit c79f39ad2a
5 changed files with 118 additions and 51 deletions

View File

@@ -95,8 +95,9 @@
const double deg2rad = M_PI_180;
const double rad2deg = M_180_PI;
inline int sign(const float & x) {return (x < 0.) ? -1 : (x > 0. ? 1 : 0);}
inline int sign(const double & x) {return (x < 0.) ? -1 : (x > 0. ? 1 : 0);}
inline int sign(const float & x) {return (x < 0.f) ? -1 : (x > 0.f ? 1 : 0);}
inline int sign(const double & x) {return (x < 0. ) ? -1 : (x > 0. ? 1 : 0);}
inline int sign(const ldouble & x) {return (x < 0.L) ? -1 : (x > 0.L ? 1 : 0);}
inline int pow2(const int p) {return 1 << p;}
inline double sinc(const double & v) {if (v == 0.) return 1.; double t = M_PI * v; return sin(t) / t;}
@@ -107,15 +108,15 @@ PIP_EXPORT double piY0(const double & v);
PIP_EXPORT double piY1(const double & v);
PIP_EXPORT double piYn(int n, const double & v);
template <typename T> inline constexpr T toDb(T val) {return T(10.) * std::log10(val);}
template <typename T> inline constexpr T fromDb(T val) {return std::pow(T(10.), val / T(10.));}
inline constexpr float toRad(float deg) {return deg * M_PI_180;}
inline constexpr double toRad(double deg) {return deg * M_PI_180;}
inline constexpr long double toRad(long double deg) {return deg * M_PI_180;}
inline constexpr float toDeg(float rad) {return rad * M_180_PI;}
inline constexpr double toDeg(double rad) {return rad * M_180_PI;}
inline constexpr long double toDeg(long double rad) {return rad * M_180_PI;}
inline constexpr float toRad(float deg) {return deg * M_PI_180;}
inline constexpr double toRad(double deg) {return deg * M_PI_180;}
inline constexpr ldouble toRad(ldouble deg) {return deg * M_PI_180;}
inline constexpr float toDeg(float rad) {return rad * M_180_PI;}
inline constexpr double toDeg(double rad) {return rad * M_180_PI;}
inline constexpr ldouble toDeg(ldouble rad) {return rad * M_180_PI;}
template <typename T> inline constexpr T sqr(const T & v) {return v * v;}
template <typename T> inline constexpr T toDb (T val) {return T(10.) * std::log10(val);}
template <typename T> inline constexpr T fromDb(T val) {return std::pow(T(10.), val / T(10.));}
// [-1 ; 1]
PIP_EXPORT double randomd();