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

2.6.15. cublas<t>trmv()

在这里插入图片描述

cublasStatus_t cublasStrmv(cublasHandle_t handle, cublasFillMode_t uplo,
                           cublasOperation_t trans, cublasDiagType_t diag,
                           int n, const float           *A, int lda,
                           float           *x, int incx)
cublasStatus_t cublasDtrmv(cublasHandle_t handle, cublasFillMode_t uplo,
                           cublasOperation_t trans, cublasDiagType_t diag,
                           int n, const double          *A, int lda,
                           double          *x, int incx)
cublasStatus_t cublasCtrmv(cublasHandle_t handle, cublasFillMode_t uplo,
                           cublasOperation_t trans, cublasDiagType_t diag,
                           int n, const cuComplex       *A, int lda,
                           cuComplex       *x, int incx)
cublasStatus_t cublasZtrmv(cublasHandle_t handle, cublasFillMode_t uplo,
                           cublasOperation_t trans, cublasDiagType_t diag,
                           int n, const cuDoubleComplex *A, int lda,
                           cuDoubleComplex *x, int incx)

此函数执行三角带状矩阵向量乘法

x = o p ( A ) x x = op(A)x x=op(A)x

其中 A 是三角带状矩阵,x 是向量。 此外,对于矩阵 A

o p ( A ) = { A     如果 t r a n s a = = C U B L A S _ O P _ N , A T   如果 t r a n s a = = C U B L A S _ O P _ T , A H   如果 t r a n s a = = C U B L A S _ O P _ H op(A)= \begin{cases} A\ \ \ \ 如果 transa == CUBLAS\_OP\_N,\\ A^T \ \ 如果 transa == CUBLAS\_OP\_T,\\ A^H \ \ 如果 transa == CUBLAS\_OP\_H \end{cases} op(A)= A    如果transa==CUBLAS_OP_N,AT  如果transa==CUBLAS_OP_T,AH  如果transa==CUBLAS_OP_H

如果 uplo == CUBLAS_FILL_MODE_LOWER 则将三角矩阵下三角部分的元素 A(i, j) 逐列无间隙地打包在一起,从而将元素存储在内存位置 AP[i+((2*n -j+1)*j)/2] 对于 j=1 , …,n 和 i>=j 。 因此,打包格式只需要 n ( n + 1 ) 2 \frac{n(n+1)}{2} 2n(n+1) 个元素进行存储。

如果 uplo == CUBLAS_FILL_MODE_UPPER 则将三角矩阵下三角部分的元素 A(i, j) 逐列无间隙地打包在一起,从而将元素存储在内存位置 AP[i+(j*(j+1))/2] 对于 j=1 , …,n 和 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.
trans input operation op(A) that is non- or (conj.) transpose.
diag input indicates if the elements on the main diagonal of matrix A are unity and should not be accessed.
n input number of rows and columns of matrix A.
A device input <type> array of dimensions lda x n , with lda>=max(1,n).
lda input leading dimension of two-dimensional array used to store matrix A.
x device input <type> vector with n elements.
incx input stride between consecutive elements of x.

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

ErrorValue Meaning
CUBLAS_STATUS_SUCCESS 操作成功完成
CUBLAS_STATUS_NOT_INITIALIZED 库未初始化
CUBLAS_STATUS_ALLOC_FAILED 内部暂存内存分配失败
CUBLAS_STATUS_EXECUTION_FAILED 该功能无法在 GPU 上启动

请参考:

strmv, dtrmv, ctrmv, ztrmv

猜你喜欢

转载自blog.csdn.net/kunhe0512/article/details/127132526