32-bit scalar float API#
- group float_s32_api
Functions
-
float_s64_t float_s32_to_float_s64(const float_s32_t x)#
Convert a float_s32_t to a float_s64_t.
- Parameters:
x – [in] Input value
- Returns:
float_s64_t
representation ofx
-
float float_s32_to_float(const float_s32_t x)#
Convert a float_s32_t to an IEEE754
float
.- Parameters:
x – [in] Input value
- Returns:
float
representation ofx
-
double float_s32_to_double(const float_s32_t x)#
Convert a float_s32_t to an IEEE754
double
.- Parameters:
x – [in] Input value
- Returns:
double
representation ofx
-
float_s32_t float_s32_mul(const float_s32_t x, const float_s32_t y)#
Multiply two float_s32_t together.
The inputs \(x\) and \(y\) are multiplied together for a result \(a\) , which is returned.
- Operation Performed
- \[\begin{aligned} & a \leftarrow x \cdot y \end{aligned}\]
- Parameters:
x – [in] Input operand \(x\)
y – [in] Input operand \(y\)
- Returns:
The product of \(x\) and \(y\)
-
float_s32_t float_s32_add(const float_s32_t x, const float_s32_t y)#
Add two float_s32_t together.
The inputs \(x\) and \(y\) are added together for a result \(a\) , which is returned.
- Operation Performed
- \[\begin{aligned} & a \leftarrow x + y \end{aligned}\]
- Parameters:
x – [in] Input operand \(x\)
y – [in] Input operand \(y\)
- Returns:
The sum of \(x\) and \(y\)
-
float_s32_t float_s32_sub(const float_s32_t x, const float_s32_t y)#
Subtract one float_s32_t from another.
The input \(y\) is subtracted from the input \(x\) for a result \(a\) , which is returned.
- Operation Performed
- \[\begin{aligned} & a \leftarrow x - y \end{aligned}\]
- Parameters:
x – [in] Input operand \(x\)
y – [in] Input operand \(y\)
- Returns:
The difference of \(x\) and \(y\)
-
float_s32_t float_s32_div(const float_s32_t x, const float_s32_t y)#
Divide one float_s32_t from another.
The input \(x\) is divided by the input \(y\) for a result \(a\) , which is returned.
- Operation Performed
- \[\begin{aligned} & a \leftarrow \frac{x}{y} \end{aligned}\]
- Parameters:
x – [in] Input operand \(x\)
y – [in] Input operand \(y\)
- Throws ET_ARITHMETIC:
if \(Y\) is \(0\)
- Returns:
The result of \(x / y\)
-
float_s32_t float_s32_abs(const float_s32_t x)#
Get the absolute value of a float_s32_t.
\(a\) , the absolute value of \(x\) is returned.
- Operation Performed
- \[\begin{aligned} & a \leftarrow \left| x \right| \end{aligned}\]
- Parameters:
x – [in] Input operand \(x\)
- Returns:
The absolute value of \(x\)
-
unsigned float_s32_gt(const float_s32_t x, const float_s32_t y)#
Determine whether one float_s32_t is greater than another.
The inputs \(x\) and \(y\) are compared. The result \(a\) is true iff \(x\) is greater than \(y\) and false otherwise. \(a\) is returned.
- Operation Performed
- \[\begin{split}\begin{aligned} & a \leftarrow \begin{cases} 1 & x > y \\ 0 & otherwise \end{cases} \end{aligned}\end{split}\]
- Parameters:
x – [in] Input operand \(x\)
y – [in] Input operand \(y\)
- Returns:
1 iff \(x > y\) ; 0 otherwise
-
unsigned float_s32_gte(const float_s32_t x, const float_s32_t y)#
Determine whether one float_s32_t is greater or equal to another.
The inputs \(x\) and \(y\) are compared. The result \(a\) is true iff \(x\) is greater than or equal to \(y\) and false otherwise. \(a\) is returned.
- Operation Performed
- \[\begin{split}\begin{aligned} & a \leftarrow \begin{cases} 1 & x \geq y \\ 0 & otherwise \end{cases} \end{aligned}\end{split}\]
- Parameters:
x – [in] Input operand \(x\)
y – [in] Input operand \(y\)
- Returns:
1 iff \(x \geq y\) ; 0 otherwise
-
float_s32_t float_s32_ema(const float_s32_t x, const float_s32_t y, const uq2_30 coef)#
Update an exponential moving average.
This function updates an exponential moving average by applying a single new sample. \(x\) is taken as the previous EMA state, with \(y\) as the new sample. The EMA coefficient \(\alpha\) is applied to the term including \(x\) .
coef
is a fixed-point value in a UQ2.30 format (i.e. has an implied exponent of \(-30\) ), and should be in the range \(0 \leq \alpha \leq 1\) .- Operation Performed
- \[\begin{aligned} & a \leftarrow \alpha \cdot x + (1 - \alpha) \cdot y \end{aligned}\]
- Parameters:
x – [in] Input operand \(x\)
y – [in] Input operand \(y\)
coef – [in] EMA coefficient \(\alpha\) encoded in UQ2.30 format
- Returns:
The new EMA state
-
float_s32_t float_s32_sqrt(const float_s32_t x)#
Get the square root of a float_s32_t.
This function computes the square root of \(x\) . The result, \(a\) is returned.
The precision with which \(a\) is computed is configurable via the XMATH_BFP_SQRT_DEPTH_S32 configuration parameter. It indicates the number of most significant bits to be calculated.
- Operation Performed
- \[\begin{aligned} & a \leftarrow \sqrt{x} \end{aligned}\]
See also
Warning
\(x\) must be non-negative to get a correct result.
- Parameters:
x – [in] Input operand \(x\)
- Returns:
The square root of \(x\)
-
float_s32_t float_s32_exp(const float_s32_t x)#
Compute \(e^x\).
This function computes \(e^x\) for real input \(x\) .
If \(x\) is known to be in the interval \(\left[-0.5,0.5\right]\) ,
q30_exp_small()
(which is used internally by this function) may be used instead for a speed boost.- Operation Performed
- \[\begin{aligned} & y \leftarrow e^x \end{aligned}\]
- Parameters:
x – [in] Input \(x\)
- Returns:
\(y\)
-
float_s32_t float_s64_to_float_s32(const float_s64_t x)#
Convert a float_s64_t to a float_s32_t.
Note
This operation may result in precision loss.
- Parameters:
x – [in] Input value
- Returns:
float_s32_t
representation ofx
-
float_s64_t float_s32_to_float_s64(const float_s32_t x)#