v?abs
Compute the absolute value or modulus of the input vector.
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, an invalid parameter error is reported and the function returns. |
Input |
|
src |
|
Input vector src with length len. If the pointer is null, a null pointer error is reported and the function returns. |
Input |
|
dst |
|
Output vector dst with length len. If the pointer is null, a null pointer error is reported and the function returns. |
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
Dependencies
C: "kvml.h"
Examples
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#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 * */ |