> 文档中心 > 23.cuBLAS开发指南中文版--cuBLAS中的Level-2函数spr()

23.cuBLAS开发指南中文版--cuBLAS中的Level-2函数spr()


2.6.6. cublasspr()

在这里插入图片描述

cublasStatus_t cublasSspr(cublasHandle_t handle, cublasFillMode_t uplo,     int n, const float  *alpha,     const float  *x, int incx, float  *AP)cublasStatus_t cublasDspr(cublasHandle_t handle, cublasFillMode_t uplo,     int n, const double *alpha,     const double *x, int incx, double *AP)

此函数执行对称带状矩阵向量乘法:

y = α x x T + A y = \alpha xx^T+A y=αxxT+A

其中 A 是以压缩格式存储的 n*n 对称矩阵,x 是向量,而 α \alpha α 是标量。

如果 uplo == CUBLAS_FILL_MODE_LOWER 则对称矩阵 a 的下三角部分中的元素被逐列填充在一起,没有间隙. 因此,一般来说,元素 A(i,j) 存储在内存位置 AP[i+((2*n-j+1)*j)/2] 中 j=1,…,n 和 i < = j i <= j i<=j 。 因此,打包格式只需要存储n(n+1) 2 \frac{n(n+1)}{2} 2n(n+1)个元素。

如果 uplo == CUBLAS_FILL_MODE_UPPER 则对称矩阵 a 的下三角部分中的元素被逐列填充在一起,没有间隙. 因此,一般来说,元素 A(i,j) 存储在内存位置 AP[i+(j*(j+1))/2] 中 j=1,…,n 和 i < = j i <= j i<=j 。 因此,打包格式只需要存储n(n+1) 2 \frac{n(n+1)}{2} 2n(n+1)个元素。

Param. Memory In/out Meaning
handle input handle to the cuBLAS library context.
uplo input indicates if matrix A lower or upper part is stored, the other symmetric part is not referenced and is inferred from the stored elements.
n input number of rows and columns of matrix A.
alpha host or device input scalar used for multiplication.
AP device input array with stored in packed format.
x device input vector with n elements.
incx input stride between consecutive elements of x.

该函数可能返回的错误值及其含义如下所列。

ErrorValue Meaning
CUBLAS_STATUS_SUCCESS 操作成功完成
CUBLAS_STATUS_NOT_INITIALIZED 库未初始化
CUBLAS_STATUS_INVALID_VALUE 参数 m,n<0 或 incx,incy=0
CUBLAS_STATUS_EXECUTION_FAILED 该功能无法在 GPU 上启动

请参考:
sspr, dspr