Rate This Document
Findability
Accuracy
Completeness
Readability

kml_sparse_?dotci_sub

x · y = xˆH * y. That is, multiply the conjugate complex number of an element in vector x by the corresponding element in vector y and then add the products. The conjugate of the complex number a + bi is a - bi. The calculation is defined as follows:conjg(x[0]) * y[indx[0]] + ... + conjg(x[nz-1]) * y[indx[nz-1]].

Interface Definition

C interface:

kml_sparse_status_t kml_sparse_cdotci_sub(const KML_INT nz, const KML_Complex8 *x, const KML_INT *indx, const KML_Complex8 *y, KML_Complex8 *dotci);

kml_sparse_status_t kml_sparse_zdotci_sub(const KML_INT nz, const KML_Complex16 *x, const KML_INT *indx, const KML_Complex16 *y, KML_Complex16 *dotci);

Fortran interface:

RES = KML_SPARSE_CDOTCI_SUB(NZ, X, INDX, Y, DOTCI);

RES = KML_SPARSE_ZDOTCI_SUB(NZ, X, INDX, Y, DOTCI);

Parameters

Parameter

Type

Description

Input/Output

nz

Integer

Number of elements in the x and indx arrays.

Input

x

  • For cdotci, x is a single-precision floating-point array.
  • For zdotci, x is a double-precision floating-point array.

Array x for storing non-zero elements. The size is at least nz.

Input

indx

Integer array

indx[i] indicates the serial number of the i-th element in the x array in the dense vector. The array size is at least nz.

Input

y

  • For cdotci, y is a single-precision floating-point array.
  • For zdotci, y is a double-precision floating-point array.

Array y. The size is at least max(indx[i]).

Input

dotci

  • For cdotci, dotci is of the single-precision floating-point type.
  • For zdotci, dotci is of the double-precision floating-point type.

Returns the conjugate dot product of x and y.

Input/Output

Return Value

Function execution status. The enumeration type is kml_sparse_status_t.

Dependencies

C: "kspblas.h"

Fortran: "kspblas.f03"

Examples

C interface:

    KML_INT nz = 2; 
    KML_Complex8 dotci = {0, 0}; 
    KML_INT indx[2] = {1, 2}; 
    KML_Complex8 x[2] = {{1, 2}, {3, 4}}; 
    KML_Complex8 y[4] = {{-1, 1}, {5, 3}, {-2, -3}, {4, 1}}; 
    kml_sparse_status_t status = kml_sparse_cdotci_sub(nz, x, indx, y, &dotci); 
 
    /* 
     *  Output dotci: 
     *     {-7.000000, -8.000000} 
     */

Fortran interface:

    INTEGER(C_INT) :: NZ = 2 
    INTEGER(C_INT) :: STATUS 
    INTEGER(C_INT) :: I 
    TYPE(KML_COMPLEX8), TARGET :: DOTCI = KML_COMPLEX8(0, 0) 
    INTEGER(C_INT) :: INDX(2) 
    TYPE(KML_COMPLEX8) :: CX(2), Y(4) 
    REAL(C_FLOAT) :: X(4), Y(8) 
    TYPE(C_PTR) :: PDOTCI 
    PDOTCI = C_LOC(DOTCI) 
    DATA INDX/1, 2/ 
    DATA X/1, 2, 3, 4/ 
    DATA Y /-1, 1, 5, 3, -2, -3, 4, 1/ 
    I = 1 
    DO WHILE(I <= 2) 
        CX(I)%REAL = X(2 * I - 1) 
        CX(I)%IMAG = X(2 * I) 
    END DO 
    I = 1 
    DO WHILE(I <= 4) 
        CY(I)%REAL = Y(2 * I - 1) 
        CY(I)%IMAG = Y(2 * I) 
    END DO 
    STATUS = KML_SPARSE_CDOTCI_SUB(NZ, CX, INDX, CY, PDOTCI) 
    ! 
    !  OUTPUT DOTCI: 
    !     {-7.000000, -8.000000} 
    !