Zephyr API 3.6.99
Loading...
Searching...
No Matches

Functions

void zdsp_scale_f32 (const float32_t *src, float32_t scale, float32_t *dst, uint32_t block_size)
 Multiplies a floating-point vector by a scalar.
 
void zdsp_scale_q7 (const q7_t *src, q7_t scale_fract, int8_t shift, q7_t *dst, uint32_t block_size)
 Multiplies a Q7 vector by a scalar.
 
void zdsp_scale_q15 (const q15_t *src, q15_t scale_fract, int8_t shift, q15_t *dst, uint32_t block_size)
 Multiplies a Q15 vector by a scalar.
 
void zdsp_scale_q31 (const q31_t *src, q31_t scale_fract, int8_t shift, q31_t *dst, uint32_t block_size)
 Multiplies a Q31 vector by a scalar.
 
DSP_FUNC_SCOPE void zdsp_scale_f16 (const float16_t *src, float16_t scale, float16_t *dst, uint32_t block_size)
 Multiplies a floating-point vector by a scalar.
 

Detailed Description

Multiply a vector by a scalar value. For floating-point data, the algorithm used is:

    dst[n] = src[n] * scale,   0 <= n < block_size.

In the fixed-point Q7, Q15, and Q31 functions, scale is represented by a fractional multiplication scale_fract and an arithmetic shift shift. The shift allows the gain of the scaling operation to exceed 1.0. The algorithm used with fixed-point data is:

    dst[n] = (src[n] * scale_fract) << shift,   0 <= n < block_size.

The overall scale factor applied to the fixed-point data is

    scale = scale_fract * 2^shift.

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

Function Documentation

◆ zdsp_scale_f16()

DSP_FUNC_SCOPE void zdsp_scale_f16 ( const float16_t * src,
float16_t scale,
float16_t * dst,
uint32_t block_size )

#include <zephyr/dsp/basicmath_f16.h>

Multiplies a floating-point vector by a scalar.

Parameters
[in]srcpoints to the input vector
[in]scalescale factor to be applied
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector

◆ zdsp_scale_f32()

void zdsp_scale_f32 ( const float32_t * src,
float32_t scale,
float32_t * dst,
uint32_t block_size )

#include <zephyr/dsp/basicmath.h>

Multiplies a floating-point vector by a scalar.

Parameters
[in]srcpoints to the input vector
[in]scalescale factor to be applied
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector

◆ zdsp_scale_q15()

void zdsp_scale_q15 ( const q15_t * src,
q15_t scale_fract,
int8_t shift,
q15_t * dst,
uint32_t block_size )

#include <zephyr/dsp/basicmath.h>

Multiplies a Q15 vector by a scalar.

Scaling and Overflow Behavior
The input data *src and scale_fract are in 1.15 format. These are multiplied to yield a 2.30 intermediate result and this is shifted with saturation to 1.15 format.
Parameters
[in]srcpoints to the input vector
[in]scale_fractfractional portion of the scale value
[in]shiftnumber of bits to shift the result by
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector

◆ zdsp_scale_q31()

void zdsp_scale_q31 ( const q31_t * src,
q31_t scale_fract,
int8_t shift,
q31_t * dst,
uint32_t block_size )

#include <zephyr/dsp/basicmath.h>

Multiplies a Q31 vector by a scalar.

Scaling and Overflow Behavior
The input data *src and scale_fract are in 1.31 format. These are multiplied to yield a 2.62 intermediate result and this is shifted with saturation to 1.31 format.
Parameters
[in]srcpoints to the input vector
[in]scale_fractfractional portion of the scale value
[in]shiftnumber of bits to shift the result by
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector

◆ zdsp_scale_q7()

void zdsp_scale_q7 ( const q7_t * src,
q7_t scale_fract,
int8_t shift,
q7_t * dst,
uint32_t block_size )

#include <zephyr/dsp/basicmath.h>

Multiplies a Q7 vector by a scalar.

Scaling and Overflow Behavior
The input data *src and scale_fract are in 1.7 format. These are multiplied to yield a 2.14 intermediate result and this is shifted with saturation to 1.7 format.
Parameters
[in]srcpoints to the input vector
[in]scale_fractfractional portion of the scale value
[in]shiftnumber of bits to shift the result by
[out]dstpoints to the output vector
[in]block_sizenumber of samples in the vector