1 SUBROUTINE DLARTG
( F
, G
, CS
, SN
, R
)
3 * -- LAPACK auxiliary routine
(version
3.1) --
4 * Univ
. of Tennessee
, Univ
. of California Berkeley and NAG Ltd
..
7 * .. Scalar Arguments
..
8 DOUBLE PRECISION CS
, F
, G
, R
, SN
14 * DLARTG generate a plane rotation so that
16 * [ CS SN
] . [ F
] = [ R
] where CS**2
+ SN**2
= 1.
17 * [ -SN CS
] [ G
] [ 0 ]
19 * This is a slower
, more accurate version of the BLAS1 routine DROTG
,
20 * with the following other differences
:
21 * F and G are unchanged on
return.
22 * If G
=0, then CS
=1 and SN
=0.
23 * If F
=0 and
(G
.ne
. 0), then CS
=0 and SN
=1 without doing any
24 * floating point operations
(saves work in DBDSQR when
25 * there are zeros on the diagonal
).
27 * If F exceeds G in magnitude
, CS will be positive
.
32 * F
(input
) DOUBLE PRECISION
33 * The first component of vector
to be rotated
.
35 * G
(input
) DOUBLE PRECISION
36 * The second component of vector
to be rotated
.
38 * CS
(output
) DOUBLE PRECISION
39 * The cosine of the rotation
.
41 * SN
(output
) DOUBLE PRECISION
42 * The sine of the rotation
.
44 * R
(output
) DOUBLE PRECISION
45 * The nonzero component of the rotated vector
.
47 * This version has a few statements commented out
for thread safety
48 * (machine parameters are computed on each entry
). 10 feb
03, SJH
.
50 * =====================================================================
54 PARAMETER ( ZERO
= 0.0D0
)
56 PARAMETER ( ONE
= 1.0D0
)
58 PARAMETER ( TWO
= 2.0D0
)
63 DOUBLE PRECISION EPS
, F1
, G1
, SAFMIN
, SAFMN2
, SAFMX2
, SCALE
65 * .. External Functions
..
66 DOUBLE PRECISION DLAMCH
69 * .. Intrinsic Functions
..
70 INTRINSIC ABS
, INT
, LOG
, MAX
, SQRT
72 * .. Save statement
..
73 * SAVE FIRST
, SAFMX2
, SAFMIN
, SAFMN2
75 * .. Data statements
..
76 * DATA FIRST
/ .TRUE
. /
78 * .. Executable Statements
..
81 SAFMIN
= DLAMCH
( 'S' )
83 SAFMN2
= DLAMCH
( 'B' )**INT
( LOG
( SAFMIN
/ EPS
) /
84 $ LOG
( DLAMCH
( 'B' ) ) / TWO
)
92 ELSE IF( F
.EQ
.ZERO
) THEN
99 SCALE
= MAX
( ABS
( F1
), ABS
( G1
) )
100 IF( SCALE
.GE
.SAFMX2
) THEN
106 SCALE
= MAX
( ABS
( F1
), ABS
( G1
) )
107 IF( SCALE
.GE
.SAFMX2
)
109 R
= SQRT
( F1**2
+G1**2
)
115 ELSE IF( SCALE
.LE
.SAFMN2
) THEN
121 SCALE
= MAX
( ABS
( F1
), ABS
( G1
) )
122 IF( SCALE
.LE
.SAFMN2
)
124 R
= SQRT
( F1**2
+G1**2
)
131 R
= SQRT
( F1**2
+G1**2
)
135 IF( ABS
( F
).GT
.ABS
( G
) .AND
. CS
.LT
.ZERO
) THEN