RealToCplx
Combines the input imaginary part and real part to a complex number.
The function interface declaration is as follows:
- Operations on integers:
HmppResult HMPPS_RealToCplx_16s(const int16_t* srcRe, const int16_t* srcIm, Hmpp16sc* dst, int32_t len);
- Operations on floating-point numbers:
HmppResult HMPPS_RealToCplx_32f(const float* srcRe, const float* srcIm, Hmpp32fc* dst, int32_t len);
HmppResult HMPPS_RealToCplx_64f(const double* srcRe, const double* srcIm, Hmpp64fc* dst, int32_t len);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
srcRe |
Pointer to the real part source vector of a complex number |
The value cannot be NULL. |
Input |
srcIm |
Pointer to the imaginary part source vector of a complex number |
The value cannot be NULL. |
Input |
dst |
Pointer to the destination vector |
The value cannot be NULL. |
Output |
len |
Vector length |
(0, INT_MAX] |
Input |
Return Value
- Success: HMPP_STS_NO_ERR
- Failure: An error code is returned.
Error Codes
Error Code |
Description |
|---|---|
HMPP_STS_NULL_PTR_ERR |
The value of srcRe, srcIm, or dst is NULL. |
HMPP_STS_SIZE_ERR |
The value of len is less than or equal to 0. |
Example
#define BUFFER_SIZE_T 5
void RealToCplxExample(void)
{
int16_t srcRe[BUFFER_SIZE_T] = {1, 63, 9, 71, 3};
int16_t srcIm[BUFFER_SIZE_T] = {43, 41, 255, 0, 127};
Hmpp16sc dst[BUFFER_SIZE_T];
int32_t i;
HmppResult result = HMPPS_RealToCplx_16s(srcRe, srcIm, dst, BUFFER_SIZE_T);
printf("result = %d \ndst =", result);
if (result != HMPP_STS_NO_ERR) {
return;
}
for (i = 0; i < BUFFER_SIZE_T; i++) {
printf(" %d %d ", dst[i].re, dst[i].im);
}
printf("\n");
}
Output:
result = 0 dst = 1 43 63 41 9 255 71 0 3 127