1.4.2.76 DSP_VectorLog2 Function

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

Description

void DSP_VectorLog2(_Q5_10 *outVector, _Q16 *inVector, int N);

Computes the Log2 value, where log2(x) = ln(x) * log2(e), on the first N elements of inVector. The output is stored to outVector.

Input vector is _Q16 format, which is 32-bit data with 15 bits for the integer and 16 bits for the fractional portion. The output vector is reduced resolution Q5.10 format, which is a 16-bit integer format with 10 bits representing the fractional resolution. 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 Log2 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 (_Q5_10)

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 Log2 function see the LibQ documentation for _LIBQ_Q5_10_log2_Q16. A negative number input will return a saturated negative value (0x8000).

Example

int log2Num = 4;

_Q16 inLog2Val[8] = {0x40000000, 0xffff0000,0x00020000,0x00030000,0x00038000,

0x00040000,0xfffe0000,0x00058000};

_// 16384.0, -1.0, 2.0, 3.0, 3.5, 4.0, -2.0, 5.5_

_Q5_10 outLog2Val[8] = {0};

DSP_VectorLog2(outLog2Val, inLog2Val, log2Num);

_// outLog2Val = 0x3800, 0x8000, 0x0400, 0x0657, 0, 0, 0, 0_

_// 14.0, sat negative, 1.0, 1.585, 0, 0, 0, 0_

C

void  DSP_VectorLog2 (_Q5_10 * outVector , _Q16 * inVector , int  N );