89 integer,
parameter :: wp = kind(1.d0)
96 real(wp),
parameter :: zero = 0.0_wp
97 real(wp),
parameter :: one = 1.0_wp
98 complex(wp),
parameter :: czero = 0.0_wp
101 real(wp),
parameter :: safmin = real(radix(0._wp),wp)**max( &
102 minexponent(0._wp)-1, &
103 1-maxexponent(0._wp) &
105 real(wp),
parameter :: safmax = real(radix(0._wp),wp)**max( &
106 1-minexponent(0._wp), &
107 maxexponent(0._wp)-1 &
109 real(wp),
parameter :: rtmin = sqrt( safmin )
113 complex(wp) :: a, b, s
116 real(wp) :: d, f1, f2, g1, g2, h2, u, v, w, rtmax
117 complex(wp) :: f, fs, g, gs, r, t
120 intrinsic :: abs, aimag, conjg, max, min, real, sqrt
126 abssq( t ) = real( t )**2 + aimag( t )**2
132 if( g == czero )
then
136 else if( f == czero )
then
138 if( real(g) == zero )
then
141 elseif( aimag(g) == zero )
then
145 g1 = max( abs(real(g)), abs(aimag(g)) )
146 rtmax = sqrt( safmax/2 )
147 if( g1 > rtmin .and. g1 < rtmax )
then
161 u = min( safmax, max( safmin, g1 ) )
172 f1 = max( abs(real(f)), abs(aimag(f)) )
173 g1 = max( abs(real(g)), abs(aimag(g)) )
174 rtmax = sqrt( safmax/4 )
175 if( f1 > rtmin .and. f1 < rtmax .and. &
176 g1 > rtmin .and. g1 < rtmax )
then
184 if( f2 >= h2 * safmin )
then
189 if( f2 > rtmin .and. h2 < rtmax )
then
191 s = conjg( g ) * ( f / sqrt( f2*h2 ) )
193 s = conjg( g ) * ( r / h2 )
204 if( c >= safmin )
then
211 s = conjg( g ) * ( f / d )
217 u = min( safmax, max( safmin, f1, g1 ) )
220 if( f1 / u < rtmin )
then
225 v = min( safmax, max( safmin, f1 ) )
240 if( f2 >= h2 * safmin )
then
245 if( f2 > rtmin .and. h2 < rtmax )
then
247 s = conjg( gs ) * ( fs / sqrt( f2*h2 ) )
249 s = conjg( gs ) * ( r / h2 )
260 if( c >= safmin )
then
267 s = conjg( gs ) * ( fs / d )
subroutine zrotg(a, b, c, s)
ZROTG generates a Givens rotation with real cosine and complex sine.