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

数学函数库 更多...

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

浏览该文件的源代码.

函数

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

变量

NEFORCE_INLINE17 constexpr decimal_t EULER = 2.71828182845904523536L
 自然常数 e
NEFORCE_INLINE17 constexpr decimal_t PI = 3.14159265358979323846L
 圆周率 π (弧度制)
NEFORCE_INLINE17 constexpr decimal_t PHI = 1.61803398874989484820L
 黄金分割比 φ
NEFORCE_INLINE17 constexpr decimal_t SEMI_CIRCLE = 180.0L
 半圆角度 180° (角度制)
NEFORCE_INLINE17 constexpr decimal_t CIRCLE = 360.0L
 全圆角度 360° (角度制)
NEFORCE_INLINE17 constexpr decimal_t TWO_PI_HI = 6.28318530717958647692L
 高精度 2π 高位
NEFORCE_INLINE17 constexpr decimal_t TWO_PI_LO = 2.44929359829470641435e-16L
 高精度 2π 低位
NEFORCE_INLINE17 constexpr decimal_t MACHINE_EPSILON = numeric_traits<decimal_t>::epsilon()
 机器精度
NEFORCE_INLINE17 constexpr decimal_t DEFAULT_TOLERANCE = 1e-12L
 默认容差
NEFORCE_INLINE17 constexpr decimal_t LOOSE_TOLERANCE = 1e-9L
 宽松容差
NEFORCE_INLINE17 constexpr uint64_t FIBONACCI_LIST []
 预计算的斐波那契数列
NEFORCE_INLINE17 constexpr uint32_t FIBONACCI_COUNT = extent_v<decltype(FIBONACCI_LIST)>
 斐波那契数列预计算数量

详细描述

数学函数库

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

在文件 math.hpp 中定义.

函数说明

◆ absolute()

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

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

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

在文件 math.hpp233 行定义.

◆ mod()

template<typename T>
NEFORCE_CONST_FUNCTION NEFORCE_CONSTEXPR14 enable_if_t< is_integral_v< T >, T > mod ( const T x,
const T y )

整数取模运算

模板参数
T整数类型
参数
x被除数
y除数
返回
x除以y的余数
异常
math_exception除数为0时

在文件 math.hpp355 行定义.