Rate This Document
Findability
Accuracy
Completeness
Readability

v?sincos

Compute the sine and cosine of vector elements.

Interface Definition

C interface:

void vssincos(const int len, const float* src, float* sindst, float* cosdst);

void vdsincos(const int len, const double* src, double* sindst, double* cosdst);

Fortran interface:

CALL VSSINCOS(LEN, SRC, SINDST, COSDST);

CALL VDSINCOS(LEN, SRC, SINDST, COSDST);

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

  • For vssincos, src is of single-precision floating-point type.
  • For vdsincos, src is of double-precision floating-point type.

Input vector src with length len.

If the pointer is null, the system prompts a null pointer error.

Input

sindst

  • For vssincos, sindst is of single-precision floating-point type.
  • For vdsincos, sindst is of double-precision floating-point type.

Output vector sindst with length len.

If the pointer is null, the system prompts a null pointer error.

Output

cosdst

  • For vssincos, cosdst is of single-precision floating-point type.
  • For vdsincos, cosdst is of double-precision floating-point type.

Output vector cosdst with length len.

If the pointer is null, the system prompts a null pointer error.

Output

Return Value

  • The sine sinx and cosine cosx of the radian angle x is returned for each operation value. sinx ∈ [-1, +1]; cosx ∈ [-1, +1]
  • If the input is +0, the sine is +0 and the cosine is +1.
  • If the input is -0, the sine is -0 and the cosine is +1.
  • If the input is ±∞, the sine and cosine are both NaN.
  • If the input is NaN, the sine and cosine are both NaN.

Dependencies

C: "kvml.h"

Fortran: "kvml.f03"

Examples

C interface:

    int i, len = 4; 
    float src[len] = {0.0f, 2.0f, inf, nan}; 
    float* sindst = (float*)malloc(sizeof(float) * len); 
    float* cosdst = (float*)malloc(sizeof(float) * len); 
    if (sindst == NULL || cosdst == NULL) { 
        printf("Malloc Failed!\n"); 
        return 0; 
    } 
    vssin(len, src, sindst, cosdst); 
    /** 
     *  Output sindst: 
     *     0.0  0.909297406673431  nan  nan 
     *  Output cosdst: 
     *     1.0  -0.416146814823151  nan  nan 
     * 
     */

Fortran interface:

    INTEGER :: LEN = 4 
    REAL(4) SRC(4)  
    REAL(4) COSDST(4) 
    REAL(4) SINDST(4) 
    DATA SRC /1, 2, 3, 4/ 
    CALL VSSINCOS(LEN, SRC, SINDST, COSDST) 
    !  
    ! OUTPUT SINDST: 
    !     0.841470957, 0.909297407, 0.141120002, -0.756802440 
    ! OUTPUT COSDST: 
    !     0.540302277, -0.416146815, -0.989992499, -0.653643608 
    !