stdlib_srotg Subroutine

public pure subroutine stdlib_srotg(a, b, c, s)

The computation uses the formulas sigma = sgn(a) if |a| > |b| = sgn(b) if |b| >= |a| r = sigmasqrt( a2 + b2 ) c = 1; s = 0 if r = 0 c = a/r; s = b/r if r != 0 The subroutine also computes z = s if |a| > |b|, = 1/c if |b| >= |a| and c != 0 = 1 if c = 0 This allows c and s to be reconstructed from z as follows: If z = 1, set c = 0, s = 1. If |z| < 1, set c = sqrt(1 - z2) and s = z. If |z| > 1, set c = 1/z and s = sqrt( 1 - c*2).

Arguments

Type IntentOptional Attributes Name
real(kind=sp), intent(inout) :: a
real(kind=sp), intent(inout) :: b
real(kind=sp), intent(out) :: c
real(kind=sp), intent(out) :: s