Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Shifts the elements of a fixed-point vector by a specified number of bits. More...

Functions

DSP_FUNC_SCOPE void zdsp_shift_q7 (const DSP_DATA q7_t *src, int8_t shift_bits, DSP_DATA q7_t *dst, uint32_t block_size)
 Shifts the elements of a Q7 vector a specified number of bits.
 
DSP_FUNC_SCOPE void zdsp_shift_q15 (const DSP_DATA q15_t *src, int8_t shift_bits, DSP_DATA q15_t *dst, uint32_t block_size)
 Shifts the elements of a Q15 vector a specified number of bits.
 
DSP_FUNC_SCOPE void zdsp_shift_q31 (const DSP_DATA q31_t *src, int8_t shift_bits, DSP_DATA q31_t *dst, uint32_t block_size)
 Shifts the elements of a Q31 vector a specified number of bits.
 

Detailed Description

Shifts the elements of a fixed-point vector by a specified number of bits.

There are separate functions for Q7, Q15, and Q31 data types. The underlying algorithm used is:

    dst[n] = src[n] << shift,   0 <= n < block_size.

If shift is positive then the elements of the vector are shifted to the left. If shift is negative then the elements of the vector are shifted to the right.

The functions support in-place computation allowing the source and destination pointers to reference the same memory buffer.

Function Documentation

◆ zdsp_shift_q15()

DSP_FUNC_SCOPE void zdsp_shift_q15 ( const DSP_DATA q15_t src,
int8_t  shift_bits,
DSP_DATA q15_t dst,
uint32_t  block_size 
)

#include <include/zephyr/dsp/basicmath.h>

Shifts the elements of a Q15 vector a specified number of bits.

Precondition
Scaling and Overflow Behavior The function uses saturating arithmetic. Results outside of the allowable Q15 range [0x8000 0x7FFF] are saturated.
Parameters
[in]srcpoints to the input vector
[in]shift_bitsnumber of bits to shift. A positive value shifts left; a negative value shifts right.
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector

◆ zdsp_shift_q31()

DSP_FUNC_SCOPE void zdsp_shift_q31 ( const DSP_DATA q31_t src,
int8_t  shift_bits,
DSP_DATA q31_t dst,
uint32_t  block_size 
)

#include <include/zephyr/dsp/basicmath.h>

Shifts the elements of a Q31 vector a specified number of bits.

Scaling and Overflow Behavior
The function uses saturating arithmetic. Results outside of the allowable Q31 range [0x80000000 0x7FFFFFFF] are saturated.
Parameters
[in]srcpoints to the input vector
[in]shift_bitsnumber of bits to shift. A positive value shifts left; a negative value shifts right.
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector

◆ zdsp_shift_q7()

DSP_FUNC_SCOPE void zdsp_shift_q7 ( const DSP_DATA q7_t src,
int8_t  shift_bits,
DSP_DATA q7_t dst,
uint32_t  block_size 
)

#include <include/zephyr/dsp/basicmath.h>

Shifts the elements of a Q7 vector a specified number of bits.

Scaling and Overflow Behavior
The function uses saturating arithmetic. Results outside of the allowable Q7 range [0x80 0x7F] are saturated.
Parameters
[in]srcpoints to the input vector
[in]shift_bitsnumber of bits to shift. A positive value shifts left; a negative value shifts right.
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector