kml_sparse_?dotui_sub
复数域的非共轭点积(欧几里得空间)
x · y = xˆT * y,即对应元素相乘然后累加。
res = x[0] * y[indx[0]] + x[1] * y(indx[1]) + ... + x[nz - 1] * y[indx[nz - 1]]
接口定义
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);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
nz |
整型数 |
x及indx数组中元素的个数。 |
输入 |
x |
|
存储非零元素的数组x,大于或等于nz。 |
输入 |
indx |
整型数组 |
indx[i]表示x数组中第i个元素在稠密向量中的序列号,数组大小大于或等于nz。 |
输入 |
y |
|
数组y,大于或等于max(indx[i])。 |
输入 |
dotui |
|
x与y的点积。 |
输入/输出 |
返回值
函数执行状态,枚举类型kml_sparse_status_t。
依赖
C: "kspblas.h"
Fortran: "kspblas.f03"
示例
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} !