Blame | Last modification | View Log | Download | RSS feed
SUBROUTINE DLANV2( A, B, C, D, RT1R, RT1I, RT2R, RT2I, CS, SN )** -- LAPACK driver routine (version 3.0) --* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,* Courant Institute, Argonne National Lab, and Rice University* June 30, 1999** .. Scalar Arguments ..DOUBLE PRECISION A, B, C, CS, D, RT1I, RT1R, RT2I, RT2R, SN* ..** Purpose* =======** DLANV2 computes the Schur factorization of a real 2-by-2 nonsymmetric* matrix in standard form:** [ A B ] = [ CS -SN ] [ AA BB ] [ CS SN ]* [ C D ] [ SN CS ] [ CC DD ] [-SN CS ]** where either* 1) CC = 0 so that AA and DD are real eigenvalues of the matrix, or* 2) AA = DD and BB*CC < 0, so that AA + or - sqrt(BB*CC) are complex* conjugate eigenvalues.** Arguments* =========** A (input/output) DOUBLE PRECISION* B (input/output) DOUBLE PRECISION* C (input/output) DOUBLE PRECISION* D (input/output) DOUBLE PRECISION* On entry, the elements of the input matrix.* On exit, they are overwritten by the elements of the* standardised Schur form.** RT1R (output) DOUBLE PRECISION* RT1I (output) DOUBLE PRECISION* RT2R (output) DOUBLE PRECISION* RT2I (output) DOUBLE PRECISION* The real and imaginary parts of the eigenvalues. If the* eigenvalues are a complex conjugate pair, RT1I > 0.** CS (output) DOUBLE PRECISION* SN (output) DOUBLE PRECISION* Parameters of the rotation matrix.** Further Details* ===============** Modified by V. Sima, Research Institute for Informatics, Bucharest,* Romania, to reduce the risk of cancellation errors,* when computing real eigenvalues, and to ensure, if possible, that* abs(RT1R) >= abs(RT2R).** =====================================================================** .. Parameters ..DOUBLE PRECISION ZERO, HALF, ONEPARAMETER ( ZERO = 0.0D+0, HALF = 0.5D+0, ONE = 1.0D+0 )DOUBLE PRECISION MULTPLPARAMETER ( MULTPL = 4.0D+0 )* ..* .. Local Scalars ..DOUBLE PRECISION AA, BB, BCMAX, BCMIS, CC, CS1, DD, EPS, P, SAB,$ SAC, SCALE, SIGMA, SN1, TAU, TEMP, Z* ..* .. External Functions ..DOUBLE PRECISION DLAMCH, DLAPY2EXTERNAL DLAMCH, DLAPY2* ..* .. Intrinsic Functions ..INTRINSIC ABS, MAX, MIN, SIGN, SQRT* ..* .. Executable Statements ..*EPS = DLAMCH( 'P' )IF( C.EQ.ZERO ) THENCS = ONESN = ZEROGO TO 10*ELSE IF( B.EQ.ZERO ) THEN** Swap rows and columns*CS = ZEROSN = ONETEMP = DD = AA = TEMPB = -CC = ZEROGO TO 10ELSE IF( ( A-D ).EQ.ZERO .AND. SIGN( ONE, B ).NE.SIGN( ONE, C ) )$ THENCS = ONESN = ZEROGO TO 10ELSE*TEMP = A - DP = HALF*TEMPBCMAX = MAX( ABS( B ), ABS( C ) )BCMIS = MIN( ABS( B ), ABS( C ) )*SIGN( ONE, B )*SIGN( ONE, C )SCALE = MAX( ABS( P ), BCMAX )Z = ( P / SCALE )*P + ( BCMAX / SCALE )*BCMIS** If Z is of the order of the machine accuracy, postpone the* decision on the nature of eigenvalues*IF( Z.GE.MULTPL*EPS ) THEN** Real eigenvalues. Compute A and D.*Z = P + SIGN( SQRT( SCALE )*SQRT( Z ), P )A = D + ZD = D - ( BCMAX / Z )*BCMIS** Compute B and the rotation matrix*TAU = DLAPY2( C, Z )CS = Z / TAUSN = C / TAUB = B - CC = ZEROELSE** Complex eigenvalues, or real (almost) equal eigenvalues.* Make diagonal elements equal.*SIGMA = B + CTAU = DLAPY2( SIGMA, TEMP )CS = SQRT( HALF*( ONE+ABS( SIGMA ) / TAU ) )SN = -( P / ( TAU*CS ) )*SIGN( ONE, SIGMA )** Compute [ AA BB ] = [ A B ] [ CS -SN ]* [ CC DD ] [ C D ] [ SN CS ]*AA = A*CS + B*SNBB = -A*SN + B*CSCC = C*CS + D*SNDD = -C*SN + D*CS** Compute [ A B ] = [ CS SN ] [ AA BB ]* [ C D ] [-SN CS ] [ CC DD ]*A = AA*CS + CC*SNB = BB*CS + DD*SNC = -AA*SN + CC*CSD = -BB*SN + DD*CS*TEMP = HALF*( A+D )A = TEMPD = TEMP*IF( C.NE.ZERO ) THENIF( B.NE.ZERO ) THENIF( SIGN( ONE, B ).EQ.SIGN( ONE, C ) ) THEN** Real eigenvalues: reduce to upper triangular form*SAB = SQRT( ABS( B ) )SAC = SQRT( ABS( C ) )P = SIGN( SAB*SAC, C )TAU = ONE / SQRT( ABS( B+C ) )A = TEMP + PD = TEMP - PB = B - CC = ZEROCS1 = SAB*TAUSN1 = SAC*TAUTEMP = CS*CS1 - SN*SN1SN = CS*SN1 + SN*CS1CS = TEMPEND IFELSEB = -CC = ZEROTEMP = CSCS = -SNSN = TEMPEND IFEND IFEND IF*END IF*10 CONTINUE** Store eigenvalues in (RT1R,RT1I) and (RT2R,RT2I).*RT1R = ART2R = DIF( C.EQ.ZERO ) THENRT1I = ZERORT2I = ZEROELSERT1I = SQRT( ABS( B ) )*SQRT( ABS( C ) )RT2I = -RT1IEND IFRETURN** End of DLANV2*END