Skip to main content
欢迎来到PAWPAW技术文档网站了解更多信息

32-bit Scalar Float API

float_s64_t float_s32_to_float_s64()

float_s32_t类型转换为float_s64_t类型。

参数:

  • const float_s32_t x – [in] 输入值

返回值:

  • 表示xfloat_s64_t类型

float float_s32_to_float()

float_s32_t类型转换为IEEE754标准的float类型。

参数:

  • const float_s32_t x – [in] 输入值

返回值:

  • 表示xfloat类型

double float_s32_to_double()

float_s32_t类型转换为IEEE754标准的double类型。

参数:

  • const float_s32_t x – [in] 输入值

返回值:

  • 表示xdouble类型

float_s32_t float_s32_mul()

将两个float_s32_t类型相乘。

将输入的xxyy相乘得到结果aa,并返回。

操作:

axya \leftarrow x \cdot y

参数:

  • const float_s32_t x – [in] 输入操作数xx
  • const float_s32_t y – [in] 输入操作数yy

返回值:

  • xxyy的乘积

float_s32_t float_s32_add()

将两个float_s32_t类型相加。

将输入的xxyy相加得到结果aa,并返回。

操作:

ax+ya \leftarrow x + y

参数:

  • const float_s32_t x – [in] 输入操作数xx
  • const float_s32_t y – [in] 输入操作数yy

返回值:

  • xxyy的和

float_s32_t float_s32_sub()

将一个float_s32_t类型减去另一个float_s32_t类型。

将输入的yy从输入的xx中减去得到结果aa,并返回。

操作:

axya \leftarrow x - y

参数:

  • const float_s32_t x – [in] 输入操作数xx
  • const float_s32_t y – [in] 输入操作数yy

返回值:

  • xxyy的差

float_s32_t float_s32_div()

将一个float_s32_t类型除以另一个float_s32_t类型。

将输入的xx除以输入的yy得到结果aa,并返回。

操作:

axya \leftarrow \frac{x}{y}

参数:

  • const float_s32_t x – [in] 输入操作数xx
  • const float_s32_t y – [in] 输入操作数yy

返回值:

  • x/yx / y的结果

异常:

  • 如果yy00,则抛出ET_ARITHMETIC异常

float_s32_t float_s32_abs()

获取float_s32_t类型的绝对值。

返回xx的绝对值aa

操作:

axa \leftarrow \left| x \right|

参数:

  • const float_s32_t x – [in] 输入操作数xx

返回值:

  • xx的绝对值

unsigned float_s32_gt()

判断一个float_s32_t类型是否大于另一个。

比较输入的xxyy。如果xx大于yy,则结果aa为真;否则为假。返回aa

操作:

a{1x>y0其他情况a \leftarrow \begin{cases} 1 & x > y \\ 0 & 其他情况 \end{cases}

参数:

  • const float_s32_t x – [in] 输入操作数xx
  • const float_s32_t y – [in] 输入操作数yy

返回值:

  • 如果x>yx > y,则返回11;否则返回00

unsigned float_s32_gte()

判断一个 float_s32_t 是否大于或等于另一个。

对输入的 xxyy 进行比较。结果 aa 当且仅当 xx 大于或等于 yy 时为真,否则为假。返回 aa

操作:

a{1xy0其他情况a \leftarrow \begin{cases} 1 & x \geq y \\ 0 & 其他情况 \end{cases}

参数:

  • const float_s32_t x – [in] 输入操作数 xx

  • const float_s32_t y – [in] 输入操作数 yy

返回值:

当且仅当 xyx \geq y 时为 1;否则为 0


float_s32_t float_s32_ema()

更新指数移动平均值(EMA)。

该函数通过应用单个新样本来更新指数移动平均值。xx 被视为先前的 EMA 状态,yy 是新样本。EMA 系数 α\alpha 被应用于包含 xx 的项。

coef 是一个使用 UQ2.30 格式表示的定点值(即隐含指数为 30-30),应在范围 0α10 \leq \alpha \leq 1 内。

操作:

aαx+(1α)ya \leftarrow \alpha \cdot x + (1 - \alpha) \cdot y

参数:

  • const float_s32_t x – [in] 输入操作数 xx

  • const float_s32_t y – [in] 输入操作数 yy

  • const uq2_30 coef – [in] 使用 UQ2.30 格式编码的 EMA 系数 α\alpha

返回值:

新的 EMA 状态


float_s32_t float_s32_sqrt()

获取 float_s32_t 的平方根。

该函数计算 xx 的平方根。结果 aa 被返回。

通过 XMATH_BFP_SQRT_DEPTH_S32 配置参数可以配置计算 aa 的精度。它表示要计算的最高有效位数。

操作:

axa \leftarrow \sqrt{x}

警告:

xx 必须为非负数才能得到正确的结果。

参数:

  • const float_s32_t x – [in] 输入操作数 xx

返回值:

xx 的平方根


float_s32_t float_s32_exp()

计算 exe^x

该函数计算实数输入 xxexe^x

如果 xx 知道在区间 [0.5,0.5][-0.5,0.5] 内,可以使用 q30_exp_small()(该函数在内部使用)来提高速度。

操作:

yexy \leftarrow e^x

参数:

  • const float_s32_t x – [in] 输入值 xx

返回值:

yy