kml_sparse_?dotui_sub
Compute the non-conjugate dot product of complex vectors (Euclidean space). x · y = xˆT * y. That is, multiply an element in vector x by the corresponding element in vector y and then add the products.
res = x[0] * y[indx[0]] + x[1] * y(indx[1]) + ... + x[nz - 1] * y[indx[nz - 1]]
Interface Definition
C interface:
kml_sparse_status_t kml_sparse_cdotui_sub(const KML_INT nz, const KML_Complex8 *x, const KML_INT *indx, const KML_Complex8 *y, KML_Complex8 *dotui);
kml_sparse_status_t kml_sparse_zdotui_sub(const KML_INT nz, const KML_Complex16 *x, const KML_INT *indx,const KML_Complex16 *y, KML_Complex16 *dotui);
Fortran interface:
RES = KML_SPARSE_CDOTUI_SUB(NZ, X, INDX, Y, DOTUI);
RES = KML_SPARSE_ZDOTUI_SUB(NZ, X, INDX, Y, DOTUI);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
nz |
Integer |
Number of elements in the x and indx arrays. |
Input |
x |
|
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 ith element in the x array in the dense vector. The array size is at least nz. |
Input |
y |
|
Array y. The size is at least max(indx[i]). |
Input |
dotui |
|
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 dotui = {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_cdotui_sub(nz, x, indx, y, &dotui);
/*
* Output dotui:
* {5.000000, -4.000000}
*/
Fortran interface:
INTEGER(C_INT) :: NZ = 2
INTEGER(C_INT) :: STATUS
INTEGER(C_INT) :: I
TYPE(KML_COMPLEX8), TARGET :: DOTUI = 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) :: PDOTCUI
PDOTUI = C_LOC(DOTUI)
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_CDOTUI_SUB(NZ, CX, INDX, CY, PDOTUI)
!
! OUTPUT DOTCI:
! {5.000000, -4.000000}
!