我要评分
获取效率
正确性
完整性
易理解

v?hypot

Compute the square root of the sum of the squares of src1 and src2. src1, src2, and the result are all vectors.

Interface Definition

C interface:

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

void vdhypot(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 vshypot
  • Double-precision floating-point type for vdhypot

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 vshypot
  • Double-precision floating-point type for vdhypot

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 vshypot
  • Double-precision floating-point type for vdhypot

Output vector dst with length len.

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

Output

Return Value

The value of is returned. The value range is |(–inf, inf)|.

Input Value 1 (src1)

Input Value 2 (src2)

Output Value (dst)

snan

any

nan

any

snan

nan

±inf

!=snan

inf

!=snan

±inf

inf

qnan

(-inf, inf)

nan

(-inf, inf)

qnan

nan

inf

Dependency

C: "kvml.h"

Examples

C interface:

    #define N 4
    const float src1[N] = {3.0f, 5.0f, 8.44f, NAN};
    const float src2[N] = {-4.0f, 12.0f, -INFINITY, 1.0f};
    float dst[N] = {0};

    vshypot(N, src1, src2, dst);
    printFArr("input1:", N, src1);
    printFArr("input2:", N, src2);
    printFArr("output:", N, dst);
 
    /** 
     *  input1:   3.000    5.000    8.440      nan 
     *  input2:  -4.000   12.000     -inf    1.000
     *  output:   5.000   13.000      inf      nan
     */