LIBML  Version 3.2.4
LIBML DSP Software Library
Functions
Vector Scale
Collaboration diagram for Vector Scale:

Functions

void tpt_scale_f32 (f32_t *__restrict aOutData, const f32_t *__restrict aInData, f32_t aScale, uint32_t aCount)
 Multiplies a floating-point vector by a scalar. More...
 
void tpt_scale_f64 (f64_t *__restrict aOutData, const f64_t *__restrict aInData, f64_t aScale, uint32_t aCount)
 Multiplies a floating-point vector by a scalar. More...
 
void tpt_scale_q15 (q15_t *__restrict aOutData, const q15_t *__restrict aInData, q15_t aScaleFract, int8_t aShift, uint32_t aCount)
 Multiplies a Q15 vector by a scalar. More...
 
void tpt_scale_q31 (q31_t *__restrict aOutData, const q31_t *__restrict aInData, q31_t aScaleFract, int8_t aShift, uint32_t aCount)
 Multiplies a Q31 vector by a scalar. More...
 
void tpt_scale_q7 (q7_t *__restrict aOutData, const q7_t *__restrict aInData, q7_t aScaleFract, int8_t aShift, uint32_t aCount)
 Multiplies a Q7 vector by a scalar. More...
 

Detailed Description

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

    aOutData[n] = aInData[n] * aScale,   0 <= n < aCount.
  

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

    aOutData[n] = (aInData[n] * aScaleFract) << aShift,   0 <= n < aCount.
  

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

    scale = aScaleFract * 2^aShift,   0 <= n < aCount.
  

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

Function Documentation

◆ tpt_scale_f32()

void tpt_scale_f32 ( f32_t *__restrict  aOutData,
const f32_t *__restrict  aInData,
f32_t  aScale,
uint32_t  aCount 
)

Multiplies a floating-point vector by a scalar.

Parameters
[out]aOutDatapoints to the output vector
[in]aInDatapoints to the input vector
[in]aScalescale factor to be applied
[in]aCountnumber of samples in the vector
Returns
none

◆ tpt_scale_f64()

void tpt_scale_f64 ( f64_t *__restrict  aOutData,
const f64_t *__restrict  aInData,
f64_t  aScale,
uint32_t  aCount 
)

Multiplies a floating-point vector by a scalar.

Parameters
[out]aOutDatapoints to the output vector
[in]aInDatapoints to the input vector
[in]aScalescale factor to be applied
[in]aCountnumber of samples in the vector
Returns
none

◆ tpt_scale_q15()

void tpt_scale_q15 ( q15_t *__restrict  aOutData,
const q15_t *__restrict  aInData,
q15_t  aScaleFract,
int8_t  aShift,
uint32_t  aCount 
)

Multiplies a Q15 vector by a scalar.

Parameters
[out]aOutDatapoints to the output vector
[in]aInDatapoints to the input vector
[in]aScaleFractfractional portion of the scale value
[in]aShiftnumber of bits to shift the result by
[in]aCountnumber of samples in the vector
Returns
none
Scaling and Overflow Behavior
The input data *aInData and aScaleFract 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.

◆ tpt_scale_q31()

void tpt_scale_q31 ( q31_t *__restrict  aOutData,
const q31_t *__restrict  aInData,
q31_t  aScaleFract,
int8_t  aShift,
uint32_t  aCount 
)

Multiplies a Q31 vector by a scalar.

Parameters
[out]aOutDatapoints to the output vector
[in]aInDatapoints to the input vector
[in]aScaleFractfractional portion of the scale value
[in]aShiftnumber of bits to shift the result by
[in]aCountnumber of samples in the vector
Returns
none
Scaling and Overflow Behavior
The input data *aInData and aScaleFract 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.

◆ tpt_scale_q7()

void tpt_scale_q7 ( q7_t *__restrict  aOutData,
const q7_t *__restrict  aInData,
q7_t  aScaleFract,
int8_t  aShift,
uint32_t  aCount 
)

Multiplies a Q7 vector by a scalar.

Parameters
[out]aOutDatapoints to the output vector
[in]aInDatapoints to the input vector
[in]aScaleFractfractional portion of the scale value
[in]aShiftnumber of bits to shift the result by
[in]aCountnumber of samples in the vector
Returns
none
Scaling and Overflow Behavior
The input data *aInData and aScaleFract 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.