1
SUBROUTINE DLASV2( F, G, H, SSMIN, SSMAX, SNR, CSR, SNL, CSL )
3
* -- LAPACK auxiliary routine (version 2.0) --
4
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5
* Courant Institute, Argonne National Lab, and Rice University
8
* .. Scalar Arguments ..
9
DOUBLE PRECISION CSL, CSR, F, G, H, SNL, SNR, SSMAX, SSMIN
15
* DLASV2 computes the singular value decomposition of a 2-by-2
19
* On return, abs(SSMAX) is the larger singular value, abs(SSMIN) is the
20
* smaller singular value, and (CSL,SNL) and (CSR,SNR) are the left and
21
* right singular vectors for abs(SSMAX), giving the decomposition
23
* [ CSL SNL ] [ F G ] [ CSR -SNR ] = [ SSMAX 0 ]
24
* [-SNL CSL ] [ 0 H ] [ SNR CSR ] [ 0 SSMIN ].
29
* F (input) DOUBLE PRECISION
30
* The (1,1) element of the 2-by-2 matrix.
32
* G (input) DOUBLE PRECISION
33
* The (1,2) element of the 2-by-2 matrix.
35
* H (input) DOUBLE PRECISION
36
* The (2,2) element of the 2-by-2 matrix.
38
* SSMIN (output) DOUBLE PRECISION
39
* abs(SSMIN) is the smaller singular value.
41
* SSMAX (output) DOUBLE PRECISION
42
* abs(SSMAX) is the larger singular value.
44
* SNL (output) DOUBLE PRECISION
45
* CSL (output) DOUBLE PRECISION
46
* The vector (CSL, SNL) is a unit left singular vector for the
47
* singular value abs(SSMAX).
49
* SNR (output) DOUBLE PRECISION
50
* CSR (output) DOUBLE PRECISION
51
* The vector (CSR, SNR) is a unit right singular vector for the
52
* singular value abs(SSMAX).
57
* Any input parameter may be aliased with any output parameter.
59
* Barring over/underflow and assuming a guard digit in subtraction, all
60
* output quantities are correct to within a few units in the last
63
* In IEEE arithmetic, the code works correctly if one matrix element is
66
* Overflow will not occur unless the largest singular value itself
67
* overflows or is within a few ulps of overflow. (On machines with
68
* partial overflow, like the Cray, overflow may occur if the largest
69
* singular value is within a factor of 2 of overflow.)
71
* Underflow is harmless if underflow is gradual. Otherwise, results
72
* may correspond to a matrix modified by perturbations of size near
73
* the underflow threshold.
75
* =====================================================================
79
PARAMETER ( ZERO = 0.0D0 )
81
PARAMETER ( HALF = 0.5D0 )
83
PARAMETER ( ONE = 1.0D0 )
85
PARAMETER ( TWO = 2.0D0 )
87
PARAMETER ( FOUR = 4.0D0 )
92
DOUBLE PRECISION A, CLT, CRT, D, FA, FT, GA, GT, HA, HT, L, M,
93
$ MM, R, S, SLT, SRT, T, TEMP, TSIGN, TT
95
* .. Intrinsic Functions ..
96
INTRINSIC ABS, SIGN, SQRT
98
* .. External Functions ..
99
DOUBLE PRECISION DLAMCH
102
* .. Executable Statements ..
109
* PMAX points to the maximum absolute element of matrix
110
* PMAX = 1 if F largest in absolute values
111
* PMAX = 2 if G largest in absolute values
112
* PMAX = 3 if H largest in absolute values
130
IF( GA.EQ.ZERO ) THEN
144
IF( ( FA / GA ).LT.DLAMCH( 'EPS' ) ) THEN
146
* Case of very large GA
151
SSMIN = FA / ( GA / HA )
153
SSMIN = ( FA / GA )*HA
168
* Copes with infinite F or H
175
* Note that 0 .le. L .le. 1
179
* Note that abs(M) .le. 1/macheps
189
* Note that 1 .le. S .le. 1 + 1/macheps
197
* Note that 0 .le. R .le. 1 + 1/macheps
201
* Note that 1 .le. A .le. 1 + abs(M)
205
IF( MM.EQ.ZERO ) THEN
207
* Note that M is very tiny
210
T = SIGN( TWO, FT )*SIGN( ONE, GT )
212
T = GT / SIGN( D, FT ) + M / T
215
T = ( M / ( S+T )+M / ( R+L ) )*( ONE+A )
220
CLT = ( CRT+SRT*M ) / A
221
SLT = ( HT / FT )*SRT / A
236
* Correct signs of SSMAX and SSMIN
239
$ TSIGN = SIGN( ONE, CSR )*SIGN( ONE, CSL )*SIGN( ONE, F )
241
$ TSIGN = SIGN( ONE, SNR )*SIGN( ONE, CSL )*SIGN( ONE, G )
243
$ TSIGN = SIGN( ONE, SNR )*SIGN( ONE, SNL )*SIGN( ONE, H )
244
SSMAX = SIGN( SSMAX, TSIGN )
245
SSMIN = SIGN( SSMIN, TSIGN*SIGN( ONE, F )*SIGN( ONE, H ) )