CMSIS-DSP
CMSIS-DSP copied to clipboard
[Feature Request] `arm_cmplx_dot_prod_real_*` — optimized real × complex dot product
Summary
Add a function to compute a dot product between a real input vector and complex coefficient vector, returning a complex result. This is useful for FIR filtering with complex taps and real input (e.g., frequency-translating FIR filters on real data), or filtering complex input with real taps.
Current API gap
CMSIS-DSP currently provides:
| Function | Operation | Input types | Output |
|---|---|---|---|
arm_dot_prod_* |
Real dot product | real × real | real |
arm_cmplx_dot_prod_* |
Complex dot product | complex × complex | complex |
arm_cmplx_mult_real_* |
Element-wise multiply | complex × real | complex |
However, there is no function for real × complex → complex in dot-product form.
Proposed API
Following the existing naming and prototype conventions:
void arm_cmplx_dot_prod_real_f16(const float16_t *pSrcReal,
const float16_t *pSrcCmplx,
uint32_t numSamples,
float16_t *realResult,
float16_t *imagResult);
void arm_cmplx_dot_prod_real_f32(const float32_t *pSrcReal,
const float32_t *pSrcCmplx,
uint32_t numSamples,
float32_t *realResult,
float32_t *imagResult);
void arm_cmplx_dot_prod_real_q15(const q15_t *pSrcReal,
const q15_t *pSrcCmplx,
uint32_t numSamples,
q31_t *realResult,
q31_t *imagResult);
void arm_cmplx_dot_prod_real_q31(const q31_t *pSrcReal,
const q31_t *pSrcCmplx,
uint32_t numSamples,
q63_t *realResult,
q63_t *imagResult);`
Semantics:
$$ (\text{realResult}, \text{imagResult}) = \sum_{n=0}^{N-1} x[n] \cdot (h_r[n] + j h_i[n]) $$
Implementation notes
- Could internally reuse the complex-by-real multiplication kernels (
arm_cmplx_mult_real_*) with accumulation.
Example use case
Frequency-translating FIR filter:
// x: real input, h: complex bandpass taps
arm_cmplx_dot_prod_real_f32(x, h, numTaps, &accReal, &accImag);
This avoids manually separating real/imag taps or converting x[n] to complex.