v?abs
Interface Definition
C interface:
void vsabs(const int len, const float *src, float *dst);
void vdabs(const int len, const double *src, double *dst);
void vcabs(const int len, const float complex *src, float*dst);
void vzabs(const int len, const double complex *src, double*dst);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
len |
Integer |
Number of elements in the input vector. If len ≤ 0, the system displays a message indicating that the value of len is invalid. |
Input |
src |
|
Input vector src with length len. If the pointer is null, the system prompts a null pointer error. |
Input |
dst |
|
Output vector dst with length len. If the pointer is null, the system prompts a null pointer error. |
Output |
Return Value
- For vsabs and vdabs, the absolute value of the real number is returned. For vcabs and vzabs, the modulus of the complex number is returned. That is, given
and
, obtain
. - For vsabs and vdabs, special output values are listed in the following table.
Input Value (src)
Output Value (dst)
+inf
+inf
-inf
+inf
nan
nan
- For vcabs and vzabs, special output values are listed in the following table.
Real Part of the Input (src->real)
Imaginary Part of the Input (src->imag)
Output Value (dst)
snan
any
nan
any
snan
nan
±inf
!=snan
inf
!=snan
±inf
inf
qnan
|srcImag| < inf
nan
|srcReal| < inf
qnan
nan

inf
Dependency
C: "kvml.h"
Example
#define N 4
const float src[N] = {-1.4f, 27.8f, -INFINITY, NAN};
float dst[N] = {0};
vsabs(N, src, dst);
printFArr("input :", N, src);
printFArr("output:", N, dst);
/**
* input : -1.400 27.800 -inf nan
* output: 1.400 27.800 inf nan
*
*/