# 吉文斯旋转

## 矩阵表示

${\displaystyle G(i,j,\theta )={\begin{bmatrix}1&\cdots &0&\cdots &0&\cdots &0\\\vdots &\ddots &\vdots &&\vdots &&\vdots \\0&\cdots &c&\cdots &s&\cdots &0\\\vdots &&\vdots &\ddots &\vdots &&\vdots \\0&\cdots &-s&\cdots &c&\cdots &0\\\vdots &&\vdots &&\vdots &\ddots &\vdots \\0&\cdots &0&\cdots &0&\cdots &1\end{bmatrix}}}$

{\displaystyle {\begin{aligned}g_{k\,k}&{}=1\qquad {\text{for}}\ k\neq i,\,j\\g_{i\,i}&{}=c\\g_{j\,j}&{}=c\\g_{i\,j}&{}=s\\g_{j\,i}&{}=-s\end{aligned}}}

Givens 旋转在数值线性代数中主要的用途是在向量或矩阵中介入零。例如，这种效果可用于计算矩阵的 QR分解。超过Householder变换的一个好处是它们可以轻易的并行化，另一个好处是对于非常稀疏的矩阵计算量更小。

## 稳定计算

${\displaystyle {\begin{bmatrix}c&-s\\s&c\end{bmatrix}}{\begin{bmatrix}a\\b\end{bmatrix}}={\begin{bmatrix}r\\0\end{bmatrix}}.}$

{\displaystyle {\begin{aligned}r&{}\leftarrow {\sqrt {a^{2}+b^{2}}}\\c&{}\leftarrow a/r\\s&{}\leftarrow -b/r\end{aligned}}}

if (b = 0) then {c ← copysign(1,a); s ← 0; r ← abs(a)}
else if (a = 0) then {c ← 0; s ← -copysign(1,b); r ← abs(b)}
else if (abs(b) > abs(a)) then
t ← a/b
u ← copysign(sqrt(1+t*t),b)
s ← -1/u
c ← -s*t
r ← b*u
else
t ← b/a
u ← copysign(sqrt(1+t*t),a)
c ← 1/u
s ← -c*t
r ← a*u


${\displaystyle \operatorname {sgn} x={\begin{cases}1&:\ x\geq 0\\-1&:\ x<0\end{cases}}}$

${\displaystyle \operatorname {sgn} x={\begin{cases}1&:\ x>0\\0&:\ x=0\\-1&:\ x<0\end{cases}}}$