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

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


2.6.7. cublasspr2()

在这里插入图片描述

cublasStatus_t cublasSspr2(cublasHandle_t handle, cublasFillMode_t uplo,      int n, const float  *alpha,      const float  *x, int incx,      const float  *y, int incy, float  *AP)cublasStatus_t cublasDspr2(cublasHandle_t handle, cublasFillMode_t uplo,      int n, const double *alpha,      const double *x, int incx,      const double *y, int incy, double *AP)

此函数执行打包的对称 rank-2 更新

y = α ( x y T + y x T ) + A y = \alpha (xy^T + yx^T)+A y=α(xyT+yxT)+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 A stored in packed format.
x device input vector with n elements.
incx input stride between consecutive elements of x.
y device input vector with n elements.
incy input stride between consecutive elements of y.

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

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

请参考:
sspr2,