1.4.2.90 DSP_VectorSqrt Function
Computes the square root of the first N elements of inVector, and stores the result in outVector.
Description
void DSP_VectorSqrt(_Q16 *outVector, _Q16 *inVector, int N);
Computes the Sqrt(x) on the first N elements of inVector. The output is stored to outVector. Both vectors are _Q16 format, which is 32-bit data with 15 bits for the integer and 16 bits for the fractional portion. If values exceed maximum or minimum they will saturate to the maximum or zero respectively.
Preconditions
The pointers outdata and indata must be aligned on 4-byte boundaries. This function uses the Sqrt function from the LibQ library.
That library must be compiled as part of the project.
Parameters
outdata pointer to destination array of elements (_Q16)
indata pointer to source array of elements (_Q16)
N number of samples (int)
Returns
None.
Remarks
This function uses the Microchip PIC32MZ LibQ library to function. The user must include that library and header file into the design in order to operate this function. For more information on the Sqrt function see the LibQ documentation for _LIBQ_Q16Sqrt. A negative number input will return a saturated value (0x00FFFFxx).
Example
int sqrtNum = 4; _Q16 inSqrtVec[8] = {0x40000000, 0xffff0000,0x00020000,0x00100000,0x00038000, 0x00400000,0xfffe0000,0x00058000}; _// 16384.0, -1.0, 2.0, 16.0, 3.5, 64.0, -2.0, 5.5_ _Q16 outSqrtVec[8] = {0}; DSP_VectorSqrt(outSqrtVec, inSqrtVec, sqrtNum); _// outSqrtVec = 0x00800000, 0x00FFFF80, 0x00016A0A, 0x00040000, 0, 0, 0, 0_ _// 128.0, sat negative, 1.41422, 4.0, 0, 0, 0, 0_
C
void DSP_VectorSqrt (_Q16 * outVector , _Q16 * inVector , int N );