v?div
Perform element-wise division of vectors. The quotient is also a vector.
Interface Definition
C interface:
void vsdiv(const int len, const float* src1, const float* src2, float* dst);
void vddiv(const int len, const double* src1, const double* src2, double* dst);
void vzdiv(const int len, const double complex* src1, const double complex* src2, double complex* dst);
Fortran interface:
CALL VSDIV(LEN, SRC1, SRC2, DST);
CALL VDDIV(LEN, SRC1, SRC2, DST);
CALL VZDIV(LEN, SRC1, SRC2, 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 |
src1 |
|
Input vector src1 (dividend) with length len. If the pointer is null, the system prompts a null pointer error. |
Input |
src2 |
|
Input vector src2 (divisor) 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 quotient of two numbers is returned for each operation value. The value range is (-INF, +INF).
- If the value of src1 is ±0 and the value of src2 is ±0, then the value of dst is NaN.
- If the value of src1 is greater than +0 and the value of src2 is ±∞, then the value of dst is ±0. If the value of src1 is greater than +0 and the value of src2 is ±0, then the value of dst is ±∞.
- If the value of src1 is less than +0 and the value of src2 is +0, then the value of dst is -∞. If the value of src1 is less than +0 and the value of src2 is -0, then the value of dst is +∞.
- If the value of src1 is +∞ and the value of src2 is +∞, then the value of dst is NaN. If the value of src1 is less than -∞ and the value of src2 is -∞, then the value of dst is NaN.
- If the value of src1 or src2 is NaN, the value of dst is NaN.
- The calculation result and special value of complex number division are defined according to the following formula:
Dependencies
C: "kvml.h"
Fortran: "kvml.f03"
Examples
C interface:
int i, len = 4;
float src1[len] = {0.0f, 0.5f, 1.5f, 5.5f};
float src2[len] = {0.3f, 0.1f, 3.0f, 10.0f};
float* dst = (float*)malloc(sizeof(float) * len);
if (dst == NULL) {
printf("Malloc Failed!\n");
return 0;
}
vsdiv(len, src1, src2, dst);
/**
* Output dst:
* 0.0 5.0 0.5 0.55
*
*/
Fortran interface:
INTEGER :: LEN = 4
REAL(4) SRC1(4)
REAL(4) SRC2(4)
REAL(4) DST(4)
DATA SRC1 /1.2, 2.5, -2.4, 3.6/
DATA SRC2 /8.6, -2.5, -12.4, 32.6/
CALL VSDIV(LEN, SRC1, SRC2, DST)
!
! OUTPUT DST:
! 0.139534876, -1.000000000, 0.193548396, 0.110429451
!
