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

v?mul

Perform element-wise multiplication of vectors. The product is also a vector.

Interface Definition

C interface:

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

void vdmul(const int len, const double* src1, const double* src2, double* dst);

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

void vzmul(const int len, const double complex* src1, const double complex* src2, double complex* dst);

Fortran interface:

CALL VSMUL(LEN, SRC1, SRC2, DST);

CALL VDMUL(LEN, SRC1, SRC2, DST);

CALL VZMUL(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

  • Single-precision floating-point type for vsmul
  • Double-precision floating-point type for vdmul
  • Single-precision floating-point complex type for vcmul
  • Double-precision floating-point complex type for vzmul

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 vsmul
  • Double-precision floating-point type for vdmul
  • Single-precision floating-point complex type for vcmul
  • Double-precision floating-point complex type for vzmul

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 vsmul
  • Double-precision floating-point type for vdmul
  • Single-precision floating-point complex type for vcmul
  • Double-precision floating-point complex type for vzmul

Output vector dst with length len.

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

Output

Return Value

  • The product of two numbers is returned for each operation value. The value range is (-INF, +INF).
  • For vsmul and vdmul, special output values are listed in the following table.

    Input Value 1 (src1)

    Input Value 2 (src2)

    Output Value (dst)

    +inf

    -inf

    -inf

    -inf

    -inf

    +inf

    +inf

    +inf

    +inf

    -inf

    +inf

    -inf

    nan

    nan

    nan

  • For vcmul and vzmul (complex number multiplication), the results and special values are defined according to the following formula:

    For details about the special output values, see vcmul&vzmul.xlsx.

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.7f, 2.5f, 10.0f}; 
    float* dst = (float*)malloc(sizeof(float) * len); 
    if (dst == NULL) { 
        printf("Malloc Failed!\n"); 
        return 0; 
    } 
    vsmul(len, src1, src2, dst); 
    /** 
     *  Output dst: 
     *     0.0  0.35  3.75  55.0 
     * 
     */

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 VSMUL(LEN, SRC1, SRC2, DST) 
    !  
    ! OUTPUT DST: 
    !     10.320000648, -6.250000000, 29.760000229, 117.359992981 
    !