drotg Subroutine

public subroutine drotg(a, b, c, s)

NAME

drotg(3f) - [BLAS:SINGLE_BLAS_LEVEL1] constructs a plane rotation

SYNOPSIS

subroutine DROTG( a, b, c, s )

 .. Scalar Arguments ..
 real(wp),intent(inout) :: a, b
 real(wp),intent(out)   :: c, s

DEFINITION

DROTG constructs a plane rotation

  [  c  s ] [ a ] = [ r ]
  [ -s  c ] [ b ]   [ 0 ]

satisfying c2 + s2 = 1.

The computation uses the formulas

 sigma = sgn(a)    if |a| >  |b|
       = sgn(b)    if |b| >= |a|
 r = sigma*sqrt( a**2 + b**2 )
 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 - z**2) and s = z.
 If |z| > 1, set c = 1/z and s = sqrt( 1 - c**2).

OPTIONS

A On entry, the scalar a. On exit, the scalar r.

B On entry, the scalar b. On exit, the scalar z.

C The scalar c.

S The scalar s.

AUTHORS

  • Edward Anderson, Lockheed Martin

\par Contributors:

Weslley Pereira, University of Colorado Denver, USA

\ingroup single_blas_level1

FURTHER DETAILS

Anderson E. (2017) Algorithm 978: Safe Scaling in the Level 1 BLAS ACM Trans Math Softw 44:1–28 https://doi.org/10.1145/3061665

SEE ALSO

Online html documentation available at
http://www.netlib.org/lapack/explore-html/

Arguments

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

Contents


Variables

Type Visibility Attributes Name Initial
real(kind=wp), public :: anorm
real(kind=wp), public :: bnorm
real(kind=wp), public, parameter :: one = 1.0_wp
real(kind=wp), public :: r
real(kind=wp), public, parameter :: safmax = real(radix(0.0_wp), wp)**max(1-minexponent(0.0_wp), maxexponent(0.0_wp)-1)
real(kind=wp), public, parameter :: safmin = real(radix(0.0_wp), wp)**max(minexponent(0.0_wp)-1, 1-maxexponent(0.0_wp))
real(kind=wp), public :: scl
real(kind=wp), public :: sigma
integer, public, parameter :: wp = kind(1.d0)
real(kind=wp), public :: z
real(kind=wp), public, parameter :: zero = 0.0_wp