LAPACK 3.3.1
Linear Algebra PACKage

srotmg.f

Go to the documentation of this file.
00001       SUBROUTINE SROTMG(SD1,SD2,SX1,SY1,SPARAM)
00002 *     .. Scalar Arguments ..
00003       REAL SD1,SD2,SX1,SY1
00004 *     ..
00005 *     .. Array Arguments ..
00006       REAL SPARAM(5)
00007 *     ..
00008 *
00009 *  Purpose
00010 *  =======
00011 *
00012 *     CONSTRUCT THE MODIFIED GIVENS TRANSFORMATION MATRIX H WHICH ZEROS
00013 *     THE SECOND COMPONENT OF THE 2-VECTOR  (SQRT(SD1)*SX1,SQRT(SD2)*
00014 *     SY2)**T.
00015 *     WITH SPARAM(1)=SFLAG, H HAS ONE OF THE FOLLOWING FORMS..
00016 *
00017 *     SFLAG=-1.E0     SFLAG=0.E0        SFLAG=1.E0     SFLAG=-2.E0
00018 *
00019 *       (SH11  SH12)    (1.E0  SH12)    (SH11  1.E0)    (1.E0  0.E0)
00020 *     H=(          )    (          )    (          )    (          )
00021 *       (SH21  SH22),   (SH21  1.E0),   (-1.E0 SH22),   (0.E0  1.E0).
00022 *     LOCATIONS 2-4 OF SPARAM CONTAIN SH11,SH21,SH12, AND SH22
00023 *     RESPECTIVELY. (VALUES OF 1.E0, -1.E0, OR 0.E0 IMPLIED BY THE
00024 *     VALUE OF SPARAM(1) ARE NOT STORED IN SPARAM.)
00025 *
00026 *     THE VALUES OF GAMSQ AND RGAMSQ SET IN THE DATA STATEMENT MAY BE
00027 *     INEXACT.  THIS IS OK AS THEY ARE ONLY USED FOR TESTING THE SIZE
00028 *     OF SD1 AND SD2.  ALL ACTUAL SCALING OF DATA IS DONE USING GAM.
00029 *
00030 *
00031 *  Arguments
00032 *  =========
00033 *
00034 *
00035 *  SD1    (input/output) REAL
00036 *
00037 *  SD2    (input/output) REAL
00038 *
00039 *  SX1    (input/output) REAL
00040 *
00041 *  SY1    (input) REAL
00042 *
00043 *
00044 *  SPARAM (input/output)  REAL array, dimension 5
00045 *     SPARAM(1)=SFLAG
00046 *     SPARAM(2)=SH11
00047 *     SPARAM(3)=SH21
00048 *     SPARAM(4)=SH12
00049 *     SPARAM(5)=SH22
00050 *
00051 *  =====================================================================
00052 *
00053 *     .. Local Scalars ..
00054       REAL GAM,GAMSQ,ONE,RGAMSQ,SFLAG,SH11,SH12,SH21,SH22,SP1,SP2,SQ1,
00055      $     SQ2,STEMP,SU,TWO,ZERO
00056 *     ..
00057 *     .. Intrinsic Functions ..
00058       INTRINSIC ABS
00059 *     ..
00060 *     .. Data statements ..
00061 *
00062       DATA ZERO,ONE,TWO/0.E0,1.E0,2.E0/
00063       DATA GAM,GAMSQ,RGAMSQ/4096.E0,1.67772E7,5.96046E-8/
00064 *     ..
00065 
00066       IF (SD1.LT.ZERO) THEN
00067 *        GO ZERO-H-D-AND-SX1..
00068          SFLAG = -ONE
00069          SH11 = ZERO
00070          SH12 = ZERO
00071          SH21 = ZERO
00072          SH22 = ZERO
00073 *
00074          SD1 = ZERO
00075          SD2 = ZERO
00076          SX1 = ZERO
00077       ELSE
00078 *        CASE-SD1-NONNEGATIVE
00079          SP2 = SD2*SY1
00080          IF (SP2.EQ.ZERO) THEN
00081             SFLAG = -TWO
00082             SPARAM(1) = SFLAG
00083             RETURN
00084          END IF 
00085 *        REGULAR-CASE..
00086          SP1 = SD1*SX1
00087          SQ2 = SP2*SY1
00088          SQ1 = SP1*SX1
00089 *
00090          IF (ABS(SQ1).GT.ABS(SQ2)) THEN
00091             SH21 = -SY1/SX1
00092             SH12 = SP2/SP1
00093 *
00094             SU = ONE - SH12*SH21
00095 *
00096            IF (SU.GT.ZERO) THEN
00097              SFLAG = ZERO
00098              SD1 = SD1/SU
00099              SD2 = SD2/SU
00100              SX1 = SX1*SU
00101            END IF
00102          ELSE
00103 
00104             IF (SQ2.LT.ZERO) THEN
00105 *              GO ZERO-H-D-AND-SX1..
00106                SFLAG = -ONE
00107                SH11 = ZERO
00108                SH12 = ZERO
00109                SH21 = ZERO
00110                SH22 = ZERO
00111 *
00112                SD1 = ZERO
00113                SD2 = ZERO
00114                SX1 = ZERO
00115             ELSE
00116                SFLAG = ONE
00117                SH11 = SP1/SP2
00118                SH22 = SX1/SY1
00119                SU = ONE + SH11*SH22
00120                STEMP = SD2/SU
00121                SD2 = SD1/SU
00122                SD1 = STEMP
00123                SX1 = SY1*SU
00124             END IF
00125          END IF
00126 
00127 *     PROCESURE..SCALE-CHECK
00128          IF (SD1.NE.ZERO) THEN
00129             DO WHILE ((SD1.LE.RGAMSQ) .OR. (SD1.GE.GAMSQ))
00130                IF (SFLAG.EQ.ZERO) THEN
00131                   SH11 = ONE
00132                   SH22 = ONE
00133                   SFLAG = -ONE
00134                ELSE
00135                   SH21 = -ONE
00136                   SH12 = ONE
00137                   SFLAG = -ONE
00138                END IF
00139                IF (SD1.LE.RGAMSQ) THEN
00140                   SD1 = SD1*GAM**2
00141                   SX1 = SX1/GAM
00142                   SH11 = SH11/GAM
00143                   SH12 = SH12/GAM
00144                ELSE
00145                   SD1 = SD1/GAM**2
00146                   SX1 = SX1*GAM
00147                   SH11 = SH11*GAM
00148                   SH12 = SH12*GAM
00149                END IF
00150             ENDDO
00151          END IF
00152   
00153          IF (SD2.NE.ZERO) THEN
00154             DO WHILE ( (ABS(SD2).LE.RGAMSQ) .OR. (ABS(SD2).GE.GAMSQ) )
00155                IF (SFLAG.EQ.ZERO) THEN
00156                   SH11 = ONE
00157                   SH22 = ONE
00158                   SFLAG = -ONE
00159                ELSE
00160                   SH21 = -ONE
00161                   SH12 = ONE
00162                   SFLAG = -ONE
00163                END IF
00164                IF (ABS(SD2).LE.RGAMSQ) THEN
00165                   SD2 = SD2*GAM**2
00166                   SH21 = SH21/GAM
00167                   SH22 = SH22/GAM
00168                ELSE
00169                   SD2 = SD2/GAM**2
00170                   SH21 = SH21*GAM
00171                   SH22 = SH22*GAM
00172                END IF      
00173             END DO
00174          END IF
00175      
00176       END IF
00177 
00178       IF (SFLAG.LT.ZERO) THEN
00179          SPARAM(2) = SH11
00180          SPARAM(3) = SH21
00181          SPARAM(4) = SH12
00182          SPARAM(5) = SH22
00183       ELSE IF (SFLAG.EQ.ZERO) THEN
00184          SPARAM(3) = SH21
00185          SPARAM(4) = SH12 
00186       ELSE
00187          SPARAM(2) = SH11
00188          SPARAM(5) = SH22
00189       END IF
00190 
00191   260 CONTINUE
00192       SPARAM(1) = SFLAG
00193       RETURN
00194       END
00195       
00196      
00197      
00198      
 All Files Functions