LIBML  Version 3.2.4
LIBML DSP Software Library
Functions
Collaboration diagram for Power:

Functions

void tpt_power_f32 (f32_t *aResult, const f32_t *aInData, uint32_t aCount)
 Sum of the squares of the elements of a floating-point vector. More...
 
void tpt_power_f64 (f64_t *aResult, const f64_t *aInData, uint32_t aCount)
 Sum of the squares of the elements of a floating-point vector. More...
 
void tpt_power_q15 (q33_30_t *aResult, const q15_t *aInData, uint32_t aCount)
 Sum of the squares of the elements of a Q15 vector. More...
 
void tpt_power_q31 (q15_48_t *aResult, const q31_t *aInData, uint32_t aCount)
 Sum of the squares of the elements of a Q31 vector. More...
 
void tpt_power_q7 (q17_14_t *aResult, const q7_t *aInData, uint32_t aCount)
 Sum of the squares of the elements of a Q7 vector. More...
 

Detailed Description

Calculates the sum of the squares of the elements in the input vector. The underlying algorithm is used:

   aResult = aInData[0] * aInData[0] + aInData[1] * aInData[1] + aInData[2] *
             aInData[2] + ... + aInData[aCount-1] * aInData[aCount-1];
 

There are separate functions for floating point, Q31, Q15, and Q7 data types.

Function Documentation

◆ tpt_power_f32()

void tpt_power_f32 ( f32_t aResult,
const f32_t aInData,
uint32_t  aCount 
)

Sum of the squares of the elements of a floating-point vector.

Parameters
[out]aResultsum of the squares value returned here
[in]aInDatapoints to the input vector
[in]aCountnumber of samples in input vector
Returns
none

◆ tpt_power_f64()

void tpt_power_f64 ( f64_t aResult,
const f64_t aInData,
uint32_t  aCount 
)

Sum of the squares of the elements of a floating-point vector.

Parameters
[out]aResultsum of the squares value returned here
[in]aInDatapoints to the input vector
[in]aCountnumber of samples in input vector
Returns
none

◆ tpt_power_q15()

void tpt_power_q15 ( q33_30_t aResult,
const q15_t aInData,
uint32_t  aCount 
)

Sum of the squares of the elements of a Q15 vector.

Parameters
[out]aResultsum of the squares value returned here
[in]aInDatapoints to the input vector
[in]aCountnumber of samples in input vector
Returns
none
Scaling and Overflow Behavior
The function is implemented using a 64-bit internal accumulator. The input is represented in 1.15 format. Intermediate multiplication yields a 2.30 format, and this result is added without saturation to a 64-bit accumulator in 34.30 format. With 33 guard bits in the accumulator, there is no risk of overflow, and the full precision of the intermediate multiplication is preserved. Finally, the return result is in 34.30 format.

◆ tpt_power_q31()

void tpt_power_q31 ( q15_48_t aResult,
const q31_t aInData,
uint32_t  aCount 
)

Sum of the squares of the elements of a Q31 vector.

Parameters
[out]aResultsum of the squares value returned here
[in]aInDatapoints to the input vector
[in]aCountnumber of samples in input vector
Returns
none
Scaling and Overflow Behavior
The function is implemented using a 64-bit internal accumulator. The input is represented in 1.31 format. Intermediate multiplication yields a 2.62 format, and this result is truncated to 2.48 format by discarding the lower 14 bits. The 2.48 result is then added without saturation to a 64-bit accumulator in 16.48 format. With 15 guard bits in the accumulator, there is no risk of overflow, and the full precision of the intermediate multiplication is preserved. Finally, the return result is in 16.48 format.

◆ tpt_power_q7()

void tpt_power_q7 ( q17_14_t aResult,
const q7_t aInData,
uint32_t  aCount 
)

Sum of the squares of the elements of a Q7 vector.

Parameters
[out]aResultsum of the squares value returned here
[in]aInDatapoints to the input vector
[in]aCountnumber of samples in input vector
Returns
none
Scaling and Overflow Behavior
The function is implemented using a 32-bit internal accumulator. The input is represented in 1.7 format. Intermediate multiplication yields a 2.14 format, and this result is added without saturation to an accumulator in 18.14 format. With 17 guard bits in the accumulator, there is no risk of overflow, and the full precision of the intermediate multiplication is preserved. Finally, the return result is in 18.14 format.