?asum
向量元素绝对值求和(对于复数,则实部和虚部分别取绝对值后再求和)。
接口定义
C interface:
float cblas_sasum(const BLASINT n, const float *x, const BLASINT incx);
double cblas_dasum(const BLASINT n, const double *x, const BLASINT incx);
float cblas_scasum(const BLASINT n, const void *x, const BLASINT incx);
double cblas_dzasum(const BLASINT n, const void *x, const BLASINT incx);
Fortran interface:
RES = SASUM(N, X, INCX)
RES = DASUM(N, X, INCX)
RES = SCASUM(N, X, INCX)
RES = DZASUM(N, X, INCX)
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
n |
整型数 |
表示x向量元素个数。 |
输入 |
x |
|
向量x,向量规模至少是(1+(n-1)*abs(incx))。 |
输入 |
incx |
整型数 |
表示x向量增长步长。 |
输入 |
依赖
#include "kblas.h"
示例
C interface:
int n = 5, incx = 1, incy = 1; /* * Input X: 0.340188, -0.105617, 0.283099, 0.298440, 0.411647 */ float x[5] = {0.340188, -0.105617, 0.283099, 0.298440, 0.411647}; float res = cblas_sasum(n, x, incx); /* * Output : 1.438991 */
Fortran interface:
INTEGER :: N=5 INTEGER :: INCX=1 REAL(4) X(5) DATA X /0.340188, -0.105617, 0.283099, 0.298440, 0.411647/ RES=SASUM(N,X,INCX) * Output : 1.438991
父主题: KML_BLAS Level 1函数