1.4.2.87 DSP_VectorRecip Function

Computes the reciprocal (1/x) of the first N elements of inVector, and stores the result in outVector.

Description

void DSP_VectorRecip(_Q16 *outVector, _Q16 *inVector, int N);

Computes the reciprocal (1/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 minimum respectively.

Preconditions

The pointers outdata and indata must be aligned on 4-byte boundaries. This function uses the Div 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 Div function see the LibQ documentation for _LIBQ_Q16Div.

A value of zero in the array will not cause an error, but will return 0.

Example

int recNum = 4;

_Q16 inRecVec[8] = {0x08000000, 0xfffc0000,0x00020000,0x00100000,0x00038000,

0x00400000,0xfffe0000,0x00058000};

_// 2048.0, -4.0, 2.0, 16.0, 3.5, 64.0, -2.0, 5.5_

_Q16 outRecVec[8] = {0};

DSP_VectorRecip(outRecVec, inRecVec, recNum);

_// outRecVec = 0x00000020, 0xFFFFC0000, 0x00008000, 0x00001000, 0, 0, 0, 0_

_// 0.000488, -0.25, 0.5, 0.0625, 0, 0, 0, 0_

C

void  DSP_VectorRecip (_Q16 * outVector , _Q16 * inVector , int  N );