Square Root
- __STATIC_FORCEINLINE riscv_status riscv_sqrt_f32 (const float32_t in, float32_t *pOut)
-
riscv_status riscv_sqrt_q31(q31_t in, q31_t *pOut)
-
riscv_status riscv_sqrt_q15(q15_t in, q15_t *pOut)
- __STATIC_FORCEINLINE riscv_status riscv_sqrt_f16 (float16_t in, float16_t *pOut)
- group Square Root
Computes the square root of a number. There are separate functions for Q15, Q31, and floating-point data types. The square root function is computed using the Newton-Raphson algorithm. This is an iterative algorithm of the form:
wherex1 = x0 - f(x0)/f'(x0)
x1is the current estimate,x0is the previous estimate, andf'(x0)is the derivative off()evaluated atx0. For the square root function, the algorithm reduces to:x0 = in/2 [initial guess] x1 = 1/2 * ( x0 + in / x0) [each iteration]
Functions
- __STATIC_FORCEINLINE riscv_status riscv_sqrt_f32 (const float32_t in, float32_t *pOut)
Floating-point square root function.
- Parameters:
in – [in] input value
pOut – [out] square root of input value
- Returns:
execution status
RISCV_MATH_SUCCESS : input value is positive
RISCV_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0
-
riscv_status riscv_sqrt_q31(q31_t in, q31_t *pOut)
Q31 square root function.
- Parameters:
in – [in] input value. The range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF
pOut – [out] points to square root of input value
- Returns:
execution status
RISCV_MATH_SUCCESS : input value is positive
RISCV_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0
-
riscv_status riscv_sqrt_q15(q15_t in, q15_t *pOut)
Q15 square root function.
- Parameters:
in – [in] input value. The range of the input value is [0 +1) or 0x0000 to 0x7FFF
pOut – [out] points to square root of input value
- Returns:
execution status
RISCV_MATH_SUCCESS : input value is positive
RISCV_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0
- __STATIC_FORCEINLINE riscv_status riscv_sqrt_f16 (float16_t in, float16_t *pOut)
Floating-point square root function.
- Parameters:
in – [in] input value
pOut – [out] square root of input value
- Returns:
execution status
RISCV_MATH_SUCCESS : input value is positive
RISCV_MATH_ARGUMENT_ERROR : input value is negative; *pOut is set to 0