|
| 1 | +!> \brief \b CLARTG generates a plane rotation with real cosine and complex sine. |
| 2 | +! |
| 3 | +! =========== DOCUMENTATION =========== |
| 4 | +! |
| 5 | +! Online html documentation available at |
| 6 | +! http://www.netlib.org/lapack/explore-html/ |
| 7 | +! |
| 8 | +! Definition: |
| 9 | +! =========== |
| 10 | +! |
| 11 | +! SUBROUTINE CLARTG( F, G, C, S, R ) |
| 12 | +! |
| 13 | +! .. Scalar Arguments .. |
| 14 | +! REAL(wp) C |
| 15 | +! COMPLEX(wp) F, G, R, S |
| 16 | +! .. |
| 17 | +! |
| 18 | +!> \par Purpose: |
| 19 | +! ============= |
| 20 | +!> |
| 21 | +!> \verbatim |
| 22 | +!> |
| 23 | +!> CLARTG generates a plane rotation so that |
| 24 | +!> |
| 25 | +!> [ C S ] . [ F ] = [ R ] |
| 26 | +!> [ -conjg(S) C ] [ G ] [ 0 ] |
| 27 | +!> |
| 28 | +!> where C is real and C**2 + |S|**2 = 1. |
| 29 | +!> |
| 30 | +!> The mathematical formulas used for C and S are |
| 31 | +!> |
| 32 | +!> sgn(x) = { x / |x|, x != 0 |
| 33 | +!> { 1, x = 0 |
| 34 | +!> |
| 35 | +!> R = sgn(F) * sqrt(|F|**2 + |G|**2) |
| 36 | +!> |
| 37 | +!> C = |F| / sqrt(|F|**2 + |G|**2) |
| 38 | +!> |
| 39 | +!> S = sgn(F) * conjg(G) / sqrt(|F|**2 + |G|**2) |
| 40 | +!> |
| 41 | +!> When F and G are real, the formulas simplify to C = F/R and |
| 42 | +!> S = G/R, and the returned values of C, S, and R should be |
| 43 | +!> identical to those returned by CLARTG. |
| 44 | +!> |
| 45 | +!> The algorithm used to compute these quantities incorporates scaling |
| 46 | +!> to avoid overflow or underflow in computing the square root of the |
| 47 | +!> sum of squares. |
| 48 | +!> |
| 49 | +!> This is a faster version of the BLAS1 routine CROTG, except for |
| 50 | +!> the following differences: |
| 51 | +!> F and G are unchanged on return. |
| 52 | +!> If G=0, then C=1 and S=0. |
| 53 | +!> If F=0, then C=0 and S is chosen so that R is real. |
| 54 | +!> |
| 55 | +!> Below, wp=>sp stands for single precision from LA_CONSTANTS module. |
| 56 | +!> \endverbatim |
| 57 | +! |
| 58 | +! Arguments: |
| 59 | +! ========== |
| 60 | +! |
| 61 | +!> \param[in] F |
| 62 | +!> \verbatim |
| 63 | +!> F is COMPLEX(wp) |
| 64 | +!> The first component of vector to be rotated. |
| 65 | +!> \endverbatim |
| 66 | +!> |
| 67 | +!> \param[in] G |
| 68 | +!> \verbatim |
| 69 | +!> G is COMPLEX(wp) |
| 70 | +!> The second component of vector to be rotated. |
| 71 | +!> \endverbatim |
| 72 | +!> |
| 73 | +!> \param[out] C |
| 74 | +!> \verbatim |
| 75 | +!> C is REAL(wp) |
| 76 | +!> The cosine of the rotation. |
| 77 | +!> \endverbatim |
| 78 | +!> |
| 79 | +!> \param[out] S |
| 80 | +!> \verbatim |
| 81 | +!> S is COMPLEX(wp) |
| 82 | +!> The sine of the rotation. |
| 83 | +!> \endverbatim |
| 84 | +!> |
| 85 | +!> \param[out] R |
| 86 | +!> \verbatim |
| 87 | +!> R is COMPLEX(wp) |
| 88 | +!> The nonzero component of the rotated vector. |
| 89 | +!> \endverbatim |
| 90 | +! |
| 91 | +! Authors: |
| 92 | +! ======== |
| 93 | +! |
| 94 | +!> \author Edward Anderson, Lockheed Martin |
| 95 | +! |
| 96 | +!> \date August 2016 |
| 97 | +! |
| 98 | +!> \ingroup OTHERauxiliary |
| 99 | +! |
| 100 | +!> \par Contributors: |
| 101 | +! ================== |
| 102 | +!> |
| 103 | +!> Weslley Pereira, University of Colorado Denver, USA |
| 104 | +! |
| 105 | +!> \par Further Details: |
| 106 | +! ===================== |
| 107 | +!> |
| 108 | +!> \verbatim |
| 109 | +!> |
| 110 | +!> Anderson E. (2017) |
| 111 | +!> Algorithm 978: Safe Scaling in the Level 1 BLAS |
| 112 | +!> ACM Trans Math Softw 44:1--28 |
| 113 | +!> https://doi.org/10.1145/3061665 |
| 114 | +!> |
| 115 | +!> \endverbatim |
| 116 | +! |
1 | 117 | subroutine CLARTG( f, g, c, s, r )
|
2 |
| - use LA_CONSTANTS32, only: zero, one, two, czero, rtmin, rtmax, & |
3 |
| - safmin, safmax |
| 118 | + use LA_CONSTANTS, & |
| 119 | + only: wp=>sp, zero=>szero, one=>sone, two=>stwo, czero, & |
| 120 | + rtmin=>srtmin, rtmax=>srtmax, safmin=>ssafmin, safmax=>ssafmax |
4 | 121 | !
|
5 |
| -! LAPACK auxiliary routine |
6 |
| -! E. Anderson |
7 |
| -! August 4, 2016 |
| 122 | +! -- LAPACK auxiliary routine (version 3.10.0) -- |
| 123 | +! -- LAPACK is a software package provided by Univ. of Tennessee, -- |
| 124 | +! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
| 125 | +! February 2021 |
8 | 126 | !
|
9 | 127 | ! .. Scalar Arguments ..
|
10 |
| - real c |
11 |
| - complex f, g, r, s |
| 128 | + real(wp) c |
| 129 | + complex(wp) f, g, r, s |
12 | 130 | ! ..
|
13 |
| -! |
14 |
| -! Purpose |
15 |
| -! ======= |
16 |
| -! |
17 |
| -! CLARTG generates a plane rotation so that |
18 |
| -! |
19 |
| -! [ C S ] . [ F ] = [ R ] |
20 |
| -! [ -conjg(S) C ] [ G ] [ 0 ] |
21 |
| -! |
22 |
| -! where C is real and C**2 + |S|**2 = 1. |
23 |
| -! |
24 |
| -! The mathematical formulas used for C and S are |
25 |
| -! |
26 |
| -! sgn(x) = { x / |x|, x != 0 |
27 |
| -! { 1, x = 0 |
28 |
| -! |
29 |
| -! R = sgn(F) * sqrt(|F|**2 + |G|**2) |
30 |
| -! |
31 |
| -! C = |F| / sqrt(|F|**2 + |G|**2) |
32 |
| -! |
33 |
| -! S = sgn(F) * conjg(G) / sqrt(|F|**2 + |G|**2) |
34 |
| -! |
35 |
| -! When F and G are real, the formulas simplify to C = F/R and |
36 |
| -! S = G/R, and the returned values of C, S, and R should be |
37 |
| -! identical to those returned by SLARTG. |
38 |
| -! |
39 |
| -! The algorithm used to compute these quantities incorporates scaling |
40 |
| -! to avoid overflow or underflow in computing the square root of the |
41 |
| -! sum of squares. |
42 |
| -! |
43 |
| -! Arguments |
44 |
| -! ========= |
45 |
| -! |
46 |
| -! F (input) COMPLEX |
47 |
| -! The first component of vector to be rotated. |
48 |
| -! |
49 |
| -! G (input) COMPLEX |
50 |
| -! The second component of vector to be rotated. |
51 |
| -! |
52 |
| -! C (output) REAL |
53 |
| -! The cosine of the rotation. |
54 |
| -! |
55 |
| -! S (output) COMPLEX |
56 |
| -! The sine of the rotation. |
57 |
| -! |
58 |
| -! R (output) COMPLEX |
59 |
| -! The nonzero component of the rotated vector. |
60 |
| -! |
61 |
| -! ===================================================================== |
62 |
| -! |
63 | 131 | ! .. Local Scalars ..
|
64 |
| - real :: d, f1, f2, g1, g2, h2, p, u, uu, v, vv, w |
65 |
| - complex :: fs, gs, t |
| 132 | + real(wp) :: d, f1, f2, g1, g2, h2, p, u, uu, v, vv, w |
| 133 | + complex(wp) :: fs, gs, t |
66 | 134 | ! ..
|
67 | 135 | ! .. Intrinsic Functions ..
|
68 | 136 | intrinsic :: abs, aimag, conjg, max, min, real, sqrt
|
69 | 137 | ! ..
|
70 | 138 | ! .. Statement Functions ..
|
71 |
| - real :: ABSSQ |
| 139 | + real(wp) :: ABSSQ |
72 | 140 | ! ..
|
73 | 141 | ! .. Statement Function definitions ..
|
74 | 142 | ABSSQ( t ) = real( t )**2 + aimag( t )**2
|
|
0 commit comments