v?tanh
Interface Definition
C interface:
void vstanh(const int len, const float* src, float* dst);
void vdtanh(const int len, const double* src, double* dst);
void vctanh(const int len, const float complex *src, float complex *dst);
void vztanh(const int len, const double complex *src, double complex *dst);
Fortran interface:
CALL VSTANH(LEN, SRC, DST);
CALL VDTANH(LEN, SRC, 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
- The hyperbolic tangent y of radian angle x is returned for each operation value, that is, y = tanh(x) = sinh(x)/cosh(x). y ∈ [-1, +1]
- For special values, see the following table.
Input Radian (src)
Output Hyperbolic Tangent (dst)
+0
+0
-0
-0
+inf
+1
-inf
-1
nan
nan
Dependencies
C: "kvml.h"
Examples
C interface:
int i, len = 4;
float src[len] = {0.0f, 2.0f, inf, nan};
float* dst = (float*)malloc(sizeof(float) * len);
if (dst == NULL) {
printf("Malloc Failed!\n");
return 0;
}
vstanh(len, src, dst);
/**
* Output dst:
* 0.0 0.964027580 1.0 nan
*
*/
Fortran interface:
INTEGER :: LEN = 4
REAL(4) SRC(4)
REAL(4) DST(4)
DATA SRC /1, 2, 3, 4/
CALL VSTANH(LEN, SRC, DST)
!
! OUTPUT DST:
! 0.761594156, 0.964027580, 0.995054754, 0.9993292997
!