Function xf::cv::Sqrt
Defined in File xf_math.h
Function Documentation
-
static int xf::cv::Sqrt(unsigned int D)
Square root computation D is 32-bit fixed point number. Q is the sqrt(D) and is 16-bit type If format of D is QM.N then format of Q is Q(M/2).N
For more details on Q formats of square root refer to sqrt.pdf
Square root computation for a 16-bit fixed point number.
Input argument D should be 16-bit number though it is declared as 32-bit. Q is the sqrt(D) and is 16-bit type If format of D is QM.N (where M+N = 16) then format of Q is Q(M/2).N
In order to get a precision of ‘n’ bits in fractional part, you can simply shift left the radicand (D) by ‘2n’ before function call and shift the solution right by ‘n’ to get the correct answer.
For example, if you want to find the square root of 35 (01100011) with one bit after decimal point i.e. N=1. You have to first find the square root of 0110001100 (shift left by 2). After you get the answer (1011) you have right shift it right by 1, so that the correct answer is 101.1 which is 5.5.