15.cuBLAS开发指南中文版--cuBLAS中的Level-1函数rotg()

发布于:2023-01-22 ⋅ 阅读:(339) ⋅ 点赞:(0)

cuBLAS中的Level-1函数rotg()

在这里插入图片描述

2.5.9. cublas<t>rotg()

cublasStatus_t cublasSrotg(cublasHandle_t handle,
                           float           *a, float           *b,
                           float  *c, float           *s)
cublasStatus_t cublasDrotg(cublasHandle_t handle,
                           double          *a, double          *b,
                           double *c, double          *s)
cublasStatus_t cublasCrotg(cublasHandle_t handle,
                           cuComplex       *a, cuComplex       *b,
                           float  *c, cuComplex       *s)
cublasStatus_t cublasZrotg(cublasHandle_t handle,
                           cuDoubleComplex *a, cuDoubleComplex *b,
                           double *c, cuDoubleComplex *s)

此函数构造 Givens 旋转矩阵

G = c s - s c

将 2 × 1 向量 ( a , b ) T 的第二个条目归零。

然后,对于实数,我们可以写

c s - s c a b = r 0

其中 c 2 + s 2 = 1 和 r = a 2 + b 2 。 参数 a 和 b 分别被 r 和 z 覆盖。 z 的值使得 c 和 s 可以使用以下规则恢复:

( c , s ) = ( 1 - z 2 , z ) if | z | < 1 ( 0 . 0 , 1 . 0 ) if | z | = 1 ( 1 ∕ z , 1 - z 2 ) if | z | > 1

对于复数,我们可以写

c s - s ̄ c a b = r 0

其中 c 2 + ( s ̄ × s ) = 1 and r = a | a | × || ( a , b ) T || 2 with || ( a , b ) T || 2 = | a | 2 + | b | 2 for a ≠ 0 and r = b for a = 0。 最后,参数 a 在退出时被 r 覆盖。

Param. Memory In/out Meaning
handle input handle to the cuBLAS library context.
a host or device in/out <type> scalar that is overwritten with r .
b host or device in/out <type> scalar that is overwritten with z .
c host or device input cosine element of the rotation matrix.
s host or device input sine element of the rotation matrix.
Error Value Meaning
CUBLAS_STATUS_SUCCESS 操作成功完成
CUBLAS_STATUS_NOT_INITIALIZED 库未初始化
CUBLAS_STATUS_EXECUTION_FAILED 该功能无法在 GPU 上启动

请参考:
srotg, drotg, crotg, zrotg


网站公告

今日签到

点亮在社区的每一天
去签到