Previous Next Contents Generated Index Doc Set Home



Givens Plane Rotation

The subroutines in this section construct a Given's plane rotation. It is typical to follow the call to xROTG with a call to xROT to apply the rotation to annihilate an element of the input vector.

Calling Sequence

CALL DROTG 
(DA, DB, DC, DS)
CALL SROTG 
(SA, SB, SC, SS)






void drotg 
(double *da, double *db, double *dc, double *ds)
void srotg 
(float *sa, float *sb, float *sc, float *ss)

Arguments

xA

On entry, the value a shown in the equation above.

On exit, the values shown here:

If |a| > |b|

sign(a) × (a2 + b2)1/2

Otherwise

sign(b) × (a2 + b2)1/2

xB

On entry, the value b shown in the equation above.

On exit, the values shown here:

If |a| > |b|

s

If |b| |a| and c 0

1/c

If c = 0

1

xC

On exit, the value c shown in the equation above.

xS

On exit, the value s shown in the equation above.

Sample Program

 
      PROGRAM TEST
      IMPLICIT NONE
C
      INTEGER           N
      PARAMETER        (N = 5)
C
      DOUBLE PRECISION  A, B, C, S, X(N), Y(N)
      INTEGER           I, INCX, INCY
C
      EXTERNAL          DROT, DROTG
C
C     Initialize the arrays X and Y to store the vectors x and y
C     shown below.
C
C         1         2
C         2         4
C     x = 3    y =  8
C         4        16
C         5        32
C
      DATA X / 1.0D0, 2.0D0, 3.0D0, 4.0D0, 5.0D0 /
      DATA Y / 2.0D0, 4.0D0, 8.0D0, 1.6D1, 3.2D1 /
C
      PRINT 1000
      PRINT 1010, (X(I), Y(I), I = 1, N)
C
C     Set up the rotation that will eliminate the last element.
C
      A = X(N)
      B = Y(N)
      CALL DROTG (A, B, C, S)
C
C     Apply the rotation to eliminate the last element and print
C     the results.
C
      INCX = 1
      INCY = 1
      CALL DROT (N, X, INCX, Y, INCY, C, S)
      PRINT 1020
      PRINT 1010, (X(I), Y(I), I = 1, N)
C
 1000 FORMAT (7X, 'x ', 8X, 'y')
 1010 FORMAT (2(3X, F7.4))
 1020 FORMAT (/7X, 'x''', 8X, 'y''')
C
      END
 

Sample Output

 
       x         y
    1.0000    2.0000
    2.0000    4.0000
    3.0000    8.0000
    4.0000   16.0000
    5.0000   32.0000



       x'        y'
    2.1304   -0.6793
    4.2608   -1.3585
    8.3672   -1.7290
   16.4257   -1.4820
   32.3883    0.0000






Previous Next Contents Generated Index Doc Set Home