平滑数学函数¶
本节中的函数是原始数学函数的平滑等效版本,可用于在间断点附近计算导数。
smooth_abs¶
T smooth_abs(T x, T c = 0.001) 是 abs 的平滑版本,其定义为:
\[ \text{smooth\_abs}(x,c) = \left\{\begin{array}{lll} |x| & & \text{如果 }x < c\text{ 或 } x > c\\[5pt] x^2\left(\frac{2}{c}-\frac{1}{c^2} x\right) & & \text{如果 }0 \leq x \leq c\\[5pt] x^2\left(\frac{2}{c}+\frac{1}{c^2} x\right) & & \text{如果 }-c \leq x < 0 \end{array}\right. \]
x是输入值c是样条近似区域的截止点(默认值:0.001)- returns: 平滑后的绝对值,定义如上所述。
smooth_max¶
T smooth_max(T x, T y, T c = 0.001) 是 max 函数的平滑版本,其定义为:
\[ \text{smooth\_max}(x,y,c) = 0.5\left(x+y+\text{smooth\_abs}(x-y,c)\right) \]
xmax函数的第一个参数ymax函数的第二个参数c样条近似区域的截止点(默认值:0.001)- returns: 平滑最大值函数,定义如上
smooth_min¶
T smooth_min(T x, T y, T c = 0.001) 是 min 函数的平滑版本,其定义为:
\[ \text{smooth\_min}(x,y,c) = 0.5\left(x+y-\text{smooth\_abs}(x-y,c)\right) \]
xmin函数的第一个参数ymin函数的第二个参数c样条近似区域的截断点(默认值:0.001)- returns: 平滑最小值函数,定义如上所述