CSI-DSP  Version 1.0.0
CSI DSP Software Library
Functions

Functions

q15_t csky_dsp_lib_sqrt_int32 (q31_t x, uint32_t rnd_flag)
 Q31 square root function. More...
 

Description

Computes the square root of a number. Only the Q31 format data is supported here.Two methods are used to compute the result. When a CPU with FPU is used, the instruction fsqrts is used to compute the result, while a CPU without FPU, Newton-Raphson algorithm is used. For Newton-Raphson algorithm, this is an iterative algorithm of the form:

     x1 = x0 - f(x0)/f'(x0)

where x1 is the current estimate, x0 is the previous estimate, and f'(x0) is the derivative of f() evaluated at x0. For the square root function, the algorithm reduces to:

    x0 = in/2                         [initial guess]
    x1 = 1/2 * ( x0 + in / x0)        [each iteration]

For both of the two method, the mantissa is longer than 15, so the result will abandon the low 16 bits and be rounded if the flag is set.

Function Documentation

q15_t csky_dsp_lib_sqrt_int32 ( q31_t  x,
uint32_t  rnd_flag 
)
Parameters
[in]xinput value, the range of the input value is [0 +1) or 0x00000000 to 0x7FFFFFFF
[in]rnd_flagthe result should be rounded if this flag is set
Returns
The result of sqrt.