1.4.2.74 DSP_VectorLn Function

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

Description

void DSP_VectorLn(_Q4_11 *outVector, _Q16 *inVector, int N);

Computes the Ln(x) value, 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 Q4.11 format, which is a 16-bit integer format with 11 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 Ln 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 (_Q4_11)

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

Example

int lnNum = 4;

_Q16 inLnVal[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_

_Q4_11 outLnVal[8] = {0};

DSP_VectorLn(outLnVal, inLnVal, lnNum);

_// outLnVal = 0x4DA2, 0x8000, 0x058C, 0x162E, 0, 0, 0, 0_

_// 9.704, sat negative, 0.6934, 2.772, 0, 0, 0, 0_

C

void  DSP_VectorLn (_Q4_11 * outVector , _Q16 * inVector , int  N );