|
| 1 | +!> \brief \b SLARTG generates a plane rotation with real cosine and real sine. |
| 2 | +! |
| 3 | +! =========== DOCUMENTATION =========== |
| 4 | +! |
| 5 | +! Online html documentation available at |
| 6 | +! http://www.netlib.org/lapack/explore-html/ |
| 7 | +! |
| 8 | +!> \htmlonly |
| 9 | +!> Download SLARTG + dependencies |
| 10 | +!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slartg.f"> |
| 11 | +!> [TGZ]</a> |
| 12 | +!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slartg.f"> |
| 13 | +!> [ZIP]</a> |
| 14 | +!> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slartg.f"> |
| 15 | +!> [TXT]</a> |
| 16 | +!> \endhtmlonly |
| 17 | +! |
| 18 | +! Definition: |
| 19 | +! =========== |
| 20 | +! |
| 21 | +! SUBROUTINE SLARTG( F, G, CS, SN, R ) |
| 22 | +! |
| 23 | +! .. Scalar Arguments .. |
| 24 | +! REAL CS, F, G, R, SN |
| 25 | +! .. |
| 26 | +! |
| 27 | +! |
| 28 | +!> \par Purpose: |
| 29 | +! ============= |
| 30 | +!> |
| 31 | +!> \verbatim |
| 32 | +!> |
| 33 | +!> SLARTG generates a plane rotation so that |
| 34 | +!> |
| 35 | +!> [ C S ] . [ F ] = [ R ] |
| 36 | +!> [ -S C ] [ G ] [ 0 ] |
| 37 | +!> |
| 38 | +!> where C**2 + S**2 = 1. |
| 39 | +!> |
| 40 | +!> The mathematical formulas used for C and S are |
| 41 | +!> R = sign(F) * sqrt(F**2 + G**2) |
| 42 | +!> C = F / R |
| 43 | +!> S = G / R |
| 44 | +!> Hence C >= 0. The algorithm used to compute these quantities |
| 45 | +!> incorporates scaling to avoid overflow or underflow in computing the |
| 46 | +!> square root of the sum of squares. |
| 47 | +!> |
| 48 | +!> This version is discontinuous in R at F = 0 but it returns the same |
| 49 | +!> C and S as CLARTG for complex inputs (F,0) and (G,0). |
| 50 | +!> |
| 51 | +!> This is a more accurate version of the BLAS1 routine SROTG, |
| 52 | +!> with the following other differences: |
| 53 | +!> F and G are unchanged on return. |
| 54 | +!> If G=0, then C=1 and S=0. |
| 55 | +!> If F=0 and (G .ne. 0), then C=0 and S=sign(1,G) without doing any |
| 56 | +!> floating point operations (saves work in SBDSQR when |
| 57 | +!> there are zeros on the diagonal). |
| 58 | +!> |
| 59 | +!> If F exceeds G in magnitude, CS will be positive. |
| 60 | +!> \endverbatim |
| 61 | +! |
| 62 | +! Arguments: |
| 63 | +! ========== |
| 64 | +! |
| 65 | +!> \param[in] F |
| 66 | +!> \verbatim |
| 67 | +!> F is REAL |
| 68 | +!> The first component of vector to be rotated. |
| 69 | +!> \endverbatim |
| 70 | +!> |
| 71 | +!> \param[in] G |
| 72 | +!> \verbatim |
| 73 | +!> G is REAL |
| 74 | +!> The second component of vector to be rotated. |
| 75 | +!> \endverbatim |
| 76 | +!> |
| 77 | +!> \param[out] CS |
| 78 | +!> \verbatim |
| 79 | +!> CS is REAL |
| 80 | +!> The cosine of the rotation. |
| 81 | +!> \endverbatim |
| 82 | +!> |
| 83 | +!> \param[out] SN |
| 84 | +!> \verbatim |
| 85 | +!> SN is REAL |
| 86 | +!> The sine of the rotation. |
| 87 | +!> \endverbatim |
| 88 | +!> |
| 89 | +!> \param[out] R |
| 90 | +!> \verbatim |
| 91 | +!> R is REAL |
| 92 | +!> The nonzero component of the rotated vector. |
| 93 | +! |
| 94 | +! Authors: |
| 95 | +! ======== |
| 96 | +! |
| 97 | +!> \author Edward Anderson, Lockheed Martin |
| 98 | +! |
| 99 | +!> \date July 2016 |
| 100 | +! |
| 101 | +!> \ingroup OTHERauxiliary |
| 102 | +! |
| 103 | +!> \par Contributors: |
| 104 | +! ================== |
| 105 | +!> |
| 106 | +!> Weslley Pereira, University of Colorado Denver, USA |
| 107 | +! |
| 108 | +!> \par Further Details: |
| 109 | +! ===================== |
| 110 | +!> |
| 111 | +!> \verbatim |
| 112 | +!> |
| 113 | +!> Anderson E. (2017) |
| 114 | +!> Algorithm 978: Safe Scaling in the Level 1 BLAS |
| 115 | +!> ACM Trans Math Softw 44:1--28 |
| 116 | +!> https://doi.org/10.1145/3061665 |
| 117 | +!> |
| 118 | +!> \endverbatim |
| 119 | +! |
1 | 120 | subroutine SLARTG( f, g, c, s, r )
|
2 | 121 | use LA_CONSTANTS32, only: zero, half, one, rtmin, rtmax, safmin, safmax
|
3 | 122 | !
|
4 |
| -! LAPACK auxiliary routine |
5 |
| -! E. Anderson |
6 |
| -! July 30, 2016 |
| 123 | +! -- LAPACK auxiliary routine (version 3.9.0) -- |
| 124 | +! -- LAPACK is a software package provided by Univ. of Tennessee, -- |
| 125 | +! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- |
| 126 | +! February 2021 |
7 | 127 | !
|
8 | 128 | ! .. Scalar Arguments ..
|
9 | 129 | real :: c, f, g, r, s
|
10 | 130 | ! ..
|
11 |
| -! |
12 |
| -! Purpose |
13 |
| -! ======= |
14 |
| -! |
15 |
| -! SLARTG generates a plane rotation so that |
16 |
| -! |
17 |
| -! [ C S ] . [ F ] = [ R ] |
18 |
| -! [ -S C ] [ G ] [ 0 ] |
19 |
| -! |
20 |
| -! where C**2 + S**2 = 1. |
21 |
| -! |
22 |
| -! The mathematical formulas used for C and S are |
23 |
| -! R = sign(F) * sqrt(F**2 + G**2) |
24 |
| -! C = F / R |
25 |
| -! S = G / R |
26 |
| -! Hence C >= 0. The algorithm used to compute these quantities |
27 |
| -! incorporates scaling to avoid overflow or underflow in computing the |
28 |
| -! square root of the sum of squares. |
29 |
| -! |
30 |
| -! This version is discontinuous in R at F = 0 but it returns the same |
31 |
| -! C and S as CLARTG for complex inputs (F,0) and (G,0). |
32 |
| -! |
33 |
| -! Arguments |
34 |
| -! ========= |
35 |
| -! |
36 |
| -! F (input) REAL |
37 |
| -! The first component of vector to be rotated. |
38 |
| -! |
39 |
| -! G (input) REAL |
40 |
| -! The second component of vector to be rotated. |
41 |
| -! |
42 |
| -! C (output) REAL |
43 |
| -! The cosine of the rotation. |
44 |
| -! |
45 |
| -! S (output) REAL |
46 |
| -! The sine of the rotation. |
47 |
| -! |
48 |
| -! R (output) REAL |
49 |
| -! The nonzero component of the rotated vector. |
50 |
| -! |
51 |
| -! ===================================================================== |
52 |
| -! |
53 | 131 | ! .. Local Scalars ..
|
54 | 132 | real :: d, f1, fs, g1, gs, p, u, uu
|
55 | 133 | ! ..
|
|
0 commit comments