kml_sparse_?sctr
将compressed格式的向量写入full-storage格式的稀疏向量y指定位置。
即y[indx[i]] = x[i],i=0,1,…nz-1。
接口定义
C interface:
kml_sparse_status_t kml_sparse_ssctr(const KML_INT nz, const float *x, const KML_INT *indx, float *y);
kml_sparse_status_t kml_sparse_dsctr(const KML_INT nz, const double *x, const KML_INT *indx, double *y);
kml_sparse_status_t kml_sparse_csctr(const KML_INT nz, const KML_Complex8 *x, const KML_INT *indx, KML_Complex8 *y);
kml_sparse_status_t kml_sparse_zsctr(const KML_INT nz, const KML_Complex16 *x, const KML_INT *indx, KML_Complex16 *y);
Fortran interface:
RES = KML_SPARSE_SSCTR(NZ, X, INDX, Y);
RES = KML_SPARSE_DSCTR(NZ, X, INDX, Y);
RES = KML_SPARSE_CSCTR(NZ, X, INDX, Y);
RES = KML_SPARSE_ZSCTR(NZ, X, INDX, Y);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
nz |
整型数 |
x及indx数组中元素的个数。 |
输入 |
y |
|
数组y,大于或等于max(indx[i])。 |
输入/输出 |
x |
|
存储非零元素的数组x,大于或等于nz。 |
输入 |
indx |
整型数组 |
indx[i]表示x数组中第i个元素在稠密向量中的序列号,数组大小大于或等于nz。 |
输入 |
返回值
函数执行状态,枚举类型kml_sparse_status_t。
依赖
C: "kspblas.h"
Fortran: "kspblas.f03"
示例
C interface:
KML_INT nz = 2; KML_INT indx[2] = {1, 2}; float x[2] = {1, 1}; float y[4] = {-1, 5, -2 ,3}; kml_sparse_status_t status = kml_sparse_ssctr(nz, x, indx, y); /* * Output sctr: * -1.000000 1.000000 1.000000 3.000000 */
Fortran interface:
INTEGER(C_INT) :: NZ = 2 INTEGER(C_INT) :: INDX(2) REAL(C_FLOAT) :: X(2), Y(4) INTEGER(C_INT) :: STATUS DATA INDX/1, 2/ DATA X/1, 1/ DATA Y/-1, 5, -2 ,3/ STATUS = KML_SPARSE_SSCTR(NZ, X, INDX, Y) ! ! OUTPUT SCTR: ! -1.000000 1.000000 1.000000 3.000000 !