Rate This Document
Findability
Accuracy
Completeness
Readability

v?copysign

Interface Definition

C interface:

void vscopysign(const int len, const float* src1, const float* src2, float* dst);

void vdcopysign(const int len, const double* src1, const double* src2, 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

src1

  • Single-precision floating-point type for vscopysign
  • Double-precision floating-point type for vdcopysign

Input vector src1 with length len.

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

Input

src2

  • Single-precision floating-point type for vscopysign
  • Double-precision floating-point type for vdcopysign

Input vector src2 with length len.

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

Input

dst

  • Single-precision floating-point type for vscopysign
  • Double-precision floating-point type for vdcopysign

Output vector dst with length len.

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

Output

Return Value

  • Each operation value returns the result obtained by copying the sign bit of x2 to x1.
  • For special values, see the following table.

    Input Value 1 (src1)

    Sign Bit of the Input Value 2 (src2)

    Output Value (dst)

    ±inf

    0

    +inf

    ±inf

    1

    -inf

    nan

    0

    nan

    nan

    1

    -nan

Dependency

C: "kvml.h"

Example

C interface:

    int i, len = 8; 
    float src1[8] = {-1.5f, -0.0f, 0.0f, 1.0f, 1.5f, -INFINITY, INFINITY, NAN};
    float src2[8] = {1.5f, 0.0f, +0.0f, -1.0f, -1.5f, +INFINITY, -INFINITY, -NAN}; 
    float* dst = (float*)malloc(sizeof(float) * len); 
    if (dst == NULL) { 
        printf("Malloc Failed!\n"); 
        return 0;
    }
    vscopysign(len, src1, src2, dst);

    /** 
     *  Output dst: 
     *     1.500000 0.000000 0.000000 -1.000000 -1.500000 inf -inf -nan
     */