cuBLAS中的Level-1函数rotm()和rotmg()
2.5.10. cublas<t>rotm()
cublasStatus_t cublasSrotm(cublasHandle_t handle, int n, float *x, int incx,
float *y, int incy, const float* param)
cublasStatus_t cublasDrotm(cublasHandle_t handle, int n, double *x, int incx,
double *y, int incy, const double* param)
此函数应用修改后的 Givens 变换
H = h 1 1 h 1 2 h 2 1 h 2 2
到向量 x 和 y。
因此,结果是 x [ k ] = h 1 1 × x [ k ] + h 1 2 × y [ j ] 和 y [ j ] = h 2 1 × x [ k ] + h 2 2 × y [ j ] 其中 k = 1 + ( i - 1 ) * incx 和 j = 1 + ( i - 1 ) * incy 。 请注意,最后两个等式反映了用于与 Fortran 兼容的基于 1 的索引。
矩阵 H 的元素 、 和 分别存储在 param[1]、param[2]、param[3] 和 param[4] 中。 flag=param[0] 为矩阵 H 项定义以下预定义值
flag=-1.0 | flag= 0.0 | flag= 1.0 | flag=-2.0 |
---|---|---|---|
h 1 1 h 1 2 h 2 1 h 2 2 | 1 . 0 h 1 2 h 2 1 1 . 0 | h 1 1 1 . 0 - 1 . 0 h 2 2 | 1 . 0 0 . 0 0 . 0 1 . 0 |
请注意,标志所隐含的值 -1.0、0.0 和 1.0 未存储在 param 中。
Param. | Memory | In/out | Meaning |
---|---|---|---|
handle | input | handle to the cuBLAS library context. | |
n | input | number of elements in the vector x. | |
x | device | input | <type> vector with n elements. |
incx | input | stride between consecutive elements of x. | |
y | device | in/out | <type> vector with n elements. |
incy | input | stride between consecutive elements of y. | |
param | host or device | input | <type> vector of 5 elements, where param[0] and param[1-4] contain the flag and matrix H . |
该函数可能返回的错误值及其含义如下所列。
Error Value | Meaning |
---|---|
CUBLAS_STATUS_SUCCESS | 操作成功完成 |
CUBLAS_STATUS_NOT_INITIALIZED | 库未初始化 |
CUBLAS_STATUS_EXECUTION_FAILED | 该功能无法在 GPU 上启动 |
2.5.11. cublas<t>rotmg()
cublasStatus_t cublasSrotmg(cublasHandle_t handle, float *d1, float *d2,
float *x1, const float *y1, float *param)
cublasStatus_t cublasDrotmg(cublasHandle_t handle, double *d1, double *d2,
double *x1, const double *y1, double *param)
此函数构造修改后的 Givens 变换
H = h 1 1 h 1 2 h 2 1 h 2 2
将 2 × 1 向量 (d 1 * x 1 , d 2 * y 1 ) T 的第二个条目归零。
flag=param[0]
为矩阵 H 项定义以下预定义值
flag=-1.0 | flag= 0.0 | flag= 1.0 | flag=-2.0 |
---|---|---|---|
h 1 1 h 1 2 h 2 1 h 2 2 | 1 . 0 h 1 2 h 2 1 1 . 0 | h 1 1 1 . 0 - 1 . 0 h 2 2 | 1 . 0 0 . 0 0 . 0 1 . 0 |
Param. | Memory | In/out | Meaning |
---|---|---|---|
handle | input | handle to the cuBLAS library context. | |
d1 | host or device | in/out | <type> scalar that is overwritten on exit. |
d2 | host or device | in/out | <type> scalar that is overwritten on exit. |
x1 | host or device | in/out | <type> scalar that is overwritten on exit. |
y1 | host or device | input | <type> scalar. |
param | host or device | output | <type> vector of 5 elements, where param[0] and param[1-4] contain the flag and matrix H . |
该函数可能返回的错误值及其含义如下所列。
Error Value | Meaning |
---|---|
CUBLAS_STATUS_SUCCESS | 操作成功完成 |
CUBLAS_STATUS_NOT_INITIALIZED | 库未初始化 |
CUBLAS_STATUS_EXECUTION_FAILED | 该功能无法在 GPU 上启动 |
本文含有隐藏内容,请 开通VIP 后查看