MSTL 1.4.0
A Modern C++ Library with extended functionality, web components, and utility libraries
载入中...
搜索中...
未找到
math.hpp 文件参考

MSTL数学函数库 更多...

math.hpp 的引用(Include)关系图:

浏览该文件的源代码.

函数

MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 uint64_t fibonacci (const uint32_t n)
 计算斐波那契数
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 uint64_t leonardo (const uint32_t n)
 计算莱昂纳多数
template<typename T>
MSTL_PURE_FUNCTION constexpr T angular2radian (const T angular) noexcept
 角度转弧度
template<typename T>
MSTL_PURE_FUNCTION constexpr T radian2angular (const T radian) noexcept
 弧度转角度
template<typename T>
MSTL_CONST_FUNCTION constexpr enable_if_t< is_signed_v< T >, T > absolute (const T x) noexcept
 取绝对值(有符号数版本)
template<typename T>
MSTL_CONST_FUNCTION constexpr enable_if_t< is_unsigned_v< T >, T > absolute (const T x) noexcept
 取绝对值(无符号数版本)
template<typename T>
MSTL_CONST_FUNCTION constexpr const T & sum (const T &x) noexcept
 单参数求和
template<typename First, typename... Rests, enable_if_t<(sizeof...(Rests) > 0), int > = 0>
MSTL_CONST_FUNCTION constexpr decltype(auto) sum (First first, Rests... args)
 多参数求和
template<typename... Args, enable_if_t<(sizeof...(Args) > 0), int > = 0>
MSTL_CONST_FUNCTION constexpr decltype(auto) average (Args... args)
 计算平均值
template<typename T>
MSTL_CONSTEXPR14 int sign (const T &value) noexcept
 获取数值的符号
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T gcd (const T &m, const T &n) noexcept
 计算最大公约数
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T lcm (const T &m, const T &n) noexcept
 计算最小公倍数
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T float_mod (const T x, const T y)
 浮点数取模运算
template<typename T>
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 T power (const T &x, uint32_t n) noexcept
 幂运算
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t exponential (const uint32_t n) noexcept
 计算e的n次幂
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_e (const T x) noexcept
 计算自然对数
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm (const T x, const uint32_t base)
 计算任意底数的对数
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_2 (const T x)
 计算以2为底的对数
template<typename T>
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 T logarithm_10 (const T x)
 计算以10为底的对数
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t square_root (const decimal_t x, const decimal_t precise=_CONSTANTS PRECISE_TOLERANCE) noexcept
 计算平方根
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cube_root (const decimal_t x, const decimal_t precise=_CONSTANTS PRECISE_TOLERANCE) noexcept
 计算立方根
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 uint64_t factorial (const uint32_t n) noexcept
 计算阶乘
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor_bit (const decimal_t x, const uint32_t bit) noexcept
 向下舍入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil_bit (const decimal_t x, const uint32_t bit) noexcept
 向上舍入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round_bit (const decimal_t x, const uint32_t bit) noexcept
 四舍五入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate_bit (const decimal_t x, const uint32_t bit) noexcept
 截断到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor (const decimal_t x) noexcept
 向下取整
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t floor (const decimal_t x, const uint32_t bit) noexcept
 向下取整到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil (const decimal_t x) noexcept
 向上取整
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t ceil (const decimal_t x, const uint32_t bit) noexcept
 向上取整到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round (const decimal_t x) noexcept
 四舍五入
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t round (const decimal_t x, const uint32_t bit) noexcept
 四舍五入到指定位数
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate (const decimal_t x, const int bit) noexcept
 截断
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t truncate (const decimal_t x) noexcept
 截断到整数位
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_multiple (const decimal_t x, const decimal_t axis, const decimal_t toler=_CONSTANTS PRECISE_TOLERANCE)
 判断是否接近某个倍数值
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_pi (const decimal_t x, const decimal_t toler=_CONSTANTS LOW_PRECISE_TOLERANCE)
 判断是否接近π的整数倍
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 bool around_zero (const decimal_t x, const decimal_t toler=_CONSTANTS PRECISE_TOLERANCE)
 判断是否接近零
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t remainder (const decimal_t x, const decimal_t y) noexcept
 计算余数
MSTL_CONST_FUNCTION constexpr decimal_t float_part (const decimal_t x) noexcept
 获取小数部分
MSTL_CONST_FUNCTION MSTL_CONSTEXPR14 decimal_t float_apart (decimal_t x, int64_t *int_ptr) noexcept
 分离整数和小数部分
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t sine (decimal_t x) noexcept
 计算正弦值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cosine (const decimal_t x) noexcept
 计算余弦值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t tangent (const decimal_t x)
 计算正切值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t cotangent (const decimal_t x)
 计算余切值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arctangent (const decimal_t x) noexcept
 计算反正切值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arcsine (const decimal_t x)
 计算反正弦值
MSTL_PURE_FUNCTION MSTL_CONSTEXPR14 decimal_t arccosine (const decimal_t x)
 计算反余弦值

变量

MSTL_INLINE17 constexpr decimal_t EULER = 2.718281828459045L
 自然常数 e
MSTL_INLINE17 constexpr decimal_t PI = 3.141592653589793L
 圆周率 π(弧度制)
MSTL_INLINE17 constexpr decimal_t PHI = 1.618033988749895L
 黄金分割比 φ
MSTL_INLINE17 constexpr decimal_t SEMI_CIRCLE = 180.0
 半圆角度 180°(角度制)
MSTL_INLINE17 constexpr decimal_t CIRCLE = 360.0
 全圆角度 360°(角度制)
MSTL_INLINE17 constexpr decimal_t EPSILON = 1e-15L
 浮点数精度容差
MSTL_INLINE17 constexpr uint32_t TAYLOR_CONVERGENCE = 10000U
 泰勒展开收敛项数
MSTL_INLINE17 constexpr decimal_t PRECISE_TOLERANCE = TAYLOR_CONVERGENCE * EPSILON
 精确容差
MSTL_INLINE17 constexpr decimal_t LOW_PRECISE_TOLERANCE = TAYLOR_CONVERGENCE * PRECISE_TOLERANCE
 低精度容差
MSTL_INLINE17 constexpr uint64_t FIBONACCI_LIST []
 预计算的斐波那契数列
MSTL_INLINE17 constexpr uint32_t FIBONACCI_COUNT = extent_v<decltype(FIBONACCI_LIST)>
 斐波那契数列预计算数量

详细描述

MSTL数学函数库

此文件提供了MSTL库的数学函数和常量定义, 包括基本数学运算、三角函数、对数函数、数值计算等常用数学功能。

在文件 math.hpp 中定义.

函数说明

◆ absolute()

template<typename T>
MSTL_CONST_FUNCTION constexpr enable_if_t< is_unsigned_v< T >, T > absolute ( const T x)
constexprnoexcept

取绝对值(无符号数版本)

模板参数
T数值类型
参数
x原数值
返回
原数值

在文件 math.hpp139 行定义.