Skip to content

Commit 93173dd

Browse files
Adding Doxygen preambles; Return to original real(wp) and complex(wp)
1 parent e39bc0f commit 93173dd

File tree

4 files changed

+395
-194
lines changed

4 files changed

+395
-194
lines changed

SRC/clartg.f90

Lines changed: 128 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,142 @@
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+
!
1117
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
4121
!
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
8126
!
9127
! .. Scalar Arguments ..
10-
real c
11-
complex f, g, r, s
128+
real(wp) c
129+
complex(wp) f, g, r, s
12130
! ..
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-
!
63131
! .. 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
66134
! ..
67135
! .. Intrinsic Functions ..
68136
intrinsic :: abs, aimag, conjg, max, min, real, sqrt
69137
! ..
70138
! .. Statement Functions ..
71-
real :: ABSSQ
139+
real(wp) :: ABSSQ
72140
! ..
73141
! .. Statement Function definitions ..
74142
ABSSQ( t ) = real( t )**2 + aimag( t )**2

SRC/dlartg.f90

Lines changed: 120 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,129 @@
1+
!> \brief \b DLARTG 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+
! Definition:
9+
! ===========
10+
!
11+
! SUBROUTINE DLARTG( F, G, C, S, R )
12+
!
13+
! .. Scalar Arguments ..
14+
! REAL(wp) C, F, G, R, S
15+
! ..
16+
!
17+
!> \par Purpose:
18+
! =============
19+
!>
20+
!> \verbatim
21+
!>
22+
!> DLARTG generates a plane rotation so that
23+
!>
24+
!> [ C S ] . [ F ] = [ R ]
25+
!> [ -S C ] [ G ] [ 0 ]
26+
!>
27+
!> where C**2 + S**2 = 1.
28+
!>
29+
!> The mathematical formulas used for C and S are
30+
!> R = sign(F) * sqrt(F**2 + G**2)
31+
!> C = F / R
32+
!> S = G / R
33+
!> Hence C >= 0. The algorithm used to compute these quantities
34+
!> incorporates scaling to avoid overflow or underflow in computing the
35+
!> square root of the sum of squares.
36+
!>
37+
!> This version is discontinuous in R at F = 0 but it returns the same
38+
!> C and S as ZLARTG for complex inputs (F,0) and (G,0).
39+
!>
40+
!> This is a more accurate version of the BLAS1 routine DROTG,
41+
!> with the following other differences:
42+
!> F and G are unchanged on return.
43+
!> If G=0, then C=1 and S=0.
44+
!> If F=0 and (G .ne. 0), then C=0 and S=sign(1,G) without doing any
45+
!> floating point operations (saves work in DBDSQR when
46+
!> there are zeros on the diagonal).
47+
!>
48+
!> If F exceeds G in magnitude, C will be positive.
49+
!>
50+
!> Below, wp=>dp stands for double precision from LA_CONSTANTS module.
51+
!> \endverbatim
52+
!
53+
! Arguments:
54+
! ==========
55+
!
56+
!> \param[in] F
57+
!> \verbatim
58+
!> F is REAL(wp)
59+
!> The first component of vector to be rotated.
60+
!> \endverbatim
61+
!>
62+
!> \param[in] G
63+
!> \verbatim
64+
!> G is REAL(wp)
65+
!> The second component of vector to be rotated.
66+
!> \endverbatim
67+
!>
68+
!> \param[out] C
69+
!> \verbatim
70+
!> C is REAL(wp)
71+
!> The cosine of the rotation.
72+
!> \endverbatim
73+
!>
74+
!> \param[out] S
75+
!> \verbatim
76+
!> S is REAL(wp)
77+
!> The sine of the rotation.
78+
!> \endverbatim
79+
!>
80+
!> \param[out] R
81+
!> \verbatim
82+
!> R is REAL(wp)
83+
!> The nonzero component of the rotated vector.
84+
!> \endverbatim
85+
!
86+
! Authors:
87+
! ========
88+
!
89+
!> \author Edward Anderson, Lockheed Martin
90+
!
91+
!> \date July 2016
92+
!
93+
!> \ingroup OTHERauxiliary
94+
!
95+
!> \par Contributors:
96+
! ==================
97+
!>
98+
!> Weslley Pereira, University of Colorado Denver, USA
99+
!
100+
!> \par Further Details:
101+
! =====================
102+
!>
103+
!> \verbatim
104+
!>
105+
!> Anderson E. (2017)
106+
!> Algorithm 978: Safe Scaling in the Level 1 BLAS
107+
!> ACM Trans Math Softw 44:1--28
108+
!> https://doi.org/10.1145/3061665
109+
!>
110+
!> \endverbatim
111+
!
1112
subroutine DLARTG( f, g, c, s, r )
2-
use LA_CONSTANTS, only: zero, half, one, rtmin, rtmax, safmin, safmax
113+
use LA_CONSTANTS, &
114+
only: wp=>dp, zero=>dzero, half=>dhalf, one=>done, &
115+
rtmin=>drtmin, rtmax=>drtmax, safmin=>dsafmin, safmax=>dsafmax
3116
!
4-
! LAPACK auxiliary routine
5-
! E. Anderson
6-
! July 30, 2016
117+
! -- LAPACK auxiliary routine (version 3.10.0) --
118+
! -- LAPACK is a software package provided by Univ. of Tennessee, --
119+
! -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
120+
! February 2021
7121
!
8122
! .. Scalar Arguments ..
9-
double precision :: c, f, g, r, s
123+
real(wp) :: c, f, g, r, s
10124
! ..
11-
!
12-
! Purpose
13-
! =======
14-
!
15-
! DLARTG 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-
!
53125
! .. Local Scalars ..
54-
double precision :: d, f1, fs, g1, gs, p, u, uu
126+
real(wp) :: d, f1, fs, g1, gs, p, u, uu
55127
! ..
56128
! .. Intrinsic Functions ..
57129
intrinsic :: abs, sign, sqrt

0 commit comments

Comments
 (0)