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

v?log2

Compute the base-2 logarithm of a vector.

Interface Definition

C interface:

void vslog2(const int len, const float* src, float* dst);

void vdlog2(const int len, const double* src, double* dst);

Parameters

Parameter

Type

Description

Input/Output

len

Integer

Number of elements in the input vector.

If len ≤ 0, an invalid parameter error is reported and the function returns.

Input

src

  • Single-precision floating-point type for vslog2
  • Double-precision floating-point type for vdlog2

Input vector src with length len.

If the pointer is null, a null pointer error is reported and the function returns.

Input

dst

  • Single-precision floating-point type for vslog2
  • Double-precision floating-point type for vdlog2

Output vector dst with length len.

If the pointer is null, a null pointer error is reported and the function returns.

Output

Return Value

Return the result of . For special values, see the following table.

Input Value (src)

Output Value (dst)

±0

-inf

<0

nan

+inf

+inf

nan

nan

Dependencies

C: "kvml.h"

Examples

C interface:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
    #define N 4
    const float src[N] = {2.2f, 1.0f, +INFINITY, -3.0f};
    float dst[N] = {0};

    vslog2(N, src, dst);
    printFArr("input1:", N, src);
    printFArr("output:", N, dst);

    /** 
     *  input1:   2.200    1.000      inf   -3.000
     *  output:   1.138    0.000      inf      nan 
     * 
     */