Constructs Givens plane rotation.
SUBROUTINE SROTG(A,B,C,S)
REAL A, B, C, S
SUBROUTINE DROTG(A,B,C,S) DOUBLE PRECISION A,B,C,S
SUBROUTINE CROTG(A,B,C,S) REAL C COMPLEX A,B,S
SUBROUTINE ZROTG(A,B,C,S) DOUBLE PRECISION C COMPLEX*16 A,B,S
Given vectors A and B, the SROTG, DROTG, CROTG, or ZROTG subroutine computes:
A B a = ---------, b = --------- |A| + |B| |A| + |B|
2 2 1/2 roe = { a if |A| > |B| } r = roe ( a + b ), { b if |B| >= |A| }
C = { A/r if r not = 0} S = { B/r if r not = 0 } { 1 if r = 0 } { 0 if r = 0 }
The numbers C, S, and r then satisfy the matrix equation:
--- --- --- --- --- --- | C S | | A | | r | | | . | | = | | | -S C | | B | | 0 | --- --- --- --- --- ---
{ S if |A| > |B|, z = { 1/C if |B| >= |A| and C not = 0, { 1 if C = 0.
The subroutines return r overwriting A and z overwriting B, as well as returning C and S.