84
85
86
87
88
89
90 CHARACTER UPLO
91 INTEGER N
92
93
94 INTEGER ISEED( * )
95 COMPLEX*16 X( * )
96
97
98
99
100
101 COMPLEX*16 EYE
102 parameter( eye = ( 0.0d0, 1.0d0 ) )
103
104
105 INTEGER J, JJ, N5
106 DOUBLE PRECISION ALPHA, ALPHA3, BETA
107 COMPLEX*16 A, B, C, R
108
109
110 COMPLEX*16 ZLARND
112
113
114 INTRINSIC abs, sqrt
115
116
117
118
119
120 alpha = ( 1.d0+sqrt( 17.d0 ) ) / 8.d0
121 beta = alpha - 1.d0 / 1000.d0
122 alpha3 = alpha*alpha*alpha
123
124
125
126 DO 10 j = 1, n*( n+1 ) / 2
127 x( j ) = 0.0d0
128 10 CONTINUE
129
130
131
132 IF( uplo.EQ.'U' ) THEN
133 n5 = n / 5
134 n5 = n - 5*n5 + 1
135
136 jj = n*( n+1 ) / 2
137 DO 20 j = n, n5, -5
138 a = alpha3*
zlarnd( 5, iseed )
139 b =
zlarnd( 5, iseed ) / alpha
140 c = a - 2.d0*b*eye
141 r = c / beta
142 x( jj ) = a
143 x( jj-2 ) = b
144 jj = jj - j
145 x( jj ) =
zlarnd( 2, iseed )
146 x( jj-1 ) = r
147 jj = jj - ( j-1 )
148 x( jj ) = c
149 jj = jj - ( j-2 )
150 x( jj ) =
zlarnd( 2, iseed )
151 jj = jj - ( j-3 )
152 x( jj ) =
zlarnd( 2, iseed )
153 IF( abs( x( jj+( j-3 ) ) ).GT.abs( x( jj ) ) ) THEN
154 x( jj+( j-4 ) ) = 2.0d0*x( jj+( j-3 ) )
155 ELSE
156 x( jj+( j-4 ) ) = 2.0d0*x( jj )
157 END IF
158 jj = jj - ( j-4 )
159 20 CONTINUE
160
161
162
163 j = n5 - 1
164 IF( j.GT.2 ) THEN
165 a = alpha3*
zlarnd( 5, iseed )
166 b =
zlarnd( 5, iseed ) / alpha
167 c = a - 2.d0*b*eye
168 r = c / beta
169 x( jj ) = a
170 x( jj-2 ) = b
171 jj = jj - j
172 x( jj ) =
zlarnd( 2, iseed )
173 x( jj-1 ) = r
174 jj = jj - ( j-1 )
175 x( jj ) = c
176 jj = jj - ( j-2 )
177 j = j - 3
178 END IF
179 IF( j.GT.1 ) THEN
180 x( jj ) =
zlarnd( 2, iseed )
181 x( jj-j ) =
zlarnd( 2, iseed )
182 IF( abs( x( jj ) ).GT.abs( x( jj-j ) ) ) THEN
183 x( jj-1 ) = 2.0d0*x( jj )
184 ELSE
185 x( jj-1 ) = 2.0d0*x( jj-j )
186 END IF
187 jj = jj - j - ( j-1 )
188 j = j - 2
189 ELSE IF( j.EQ.1 ) THEN
190 x( jj ) =
zlarnd( 2, iseed )
191 j = j - 1
192 END IF
193
194
195
196 ELSE
197 n5 = n / 5
198 n5 = n5*5
199
200 jj = 1
201 DO 30 j = 1, n5, 5
202 a = alpha3*
zlarnd( 5, iseed )
203 b =
zlarnd( 5, iseed ) / alpha
204 c = a - 2.d0*b*eye
205 r = c / beta
206 x( jj ) = a
207 x( jj+2 ) = b
208 jj = jj + ( n-j+1 )
209 x( jj ) =
zlarnd( 2, iseed )
210 x( jj+1 ) = r
211 jj = jj + ( n-j )
212 x( jj ) = c
213 jj = jj + ( n-j-1 )
214 x( jj ) =
zlarnd( 2, iseed )
215 jj = jj + ( n-j-2 )
216 x( jj ) =
zlarnd( 2, iseed )
217 IF( abs( x( jj-( n-j-2 ) ) ).GT.abs( x( jj ) ) ) THEN
218 x( jj-( n-j-2 )+1 ) = 2.0d0*x( jj-( n-j-2 ) )
219 ELSE
220 x( jj-( n-j-2 )+1 ) = 2.0d0*x( jj )
221 END IF
222 jj = jj + ( n-j-3 )
223 30 CONTINUE
224
225
226
227 j = n5 + 1
228 IF( j.LT.n-1 ) THEN
229 a = alpha3*
zlarnd( 5, iseed )
230 b =
zlarnd( 5, iseed ) / alpha
231 c = a - 2.d0*b*eye
232 r = c / beta
233 x( jj ) = a
234 x( jj+2 ) = b
235 jj = jj + ( n-j+1 )
236 x( jj ) =
zlarnd( 2, iseed )
237 x( jj+1 ) = r
238 jj = jj + ( n-j )
239 x( jj ) = c
240 jj = jj + ( n-j-1 )
241 j = j + 3
242 END IF
243 IF( j.LT.n ) THEN
244 x( jj ) =
zlarnd( 2, iseed )
245 x( jj+( n-j+1 ) ) =
zlarnd( 2, iseed )
246 IF( abs( x( jj ) ).GT.abs( x( jj+( n-j+1 ) ) ) ) THEN
247 x( jj+1 ) = 2.0d0*x( jj )
248 ELSE
249 x( jj+1 ) = 2.0d0*x( jj+( n-j+1 ) )
250 END IF
251 jj = jj + ( n-j+1 ) + ( n-j )
252 j = j + 2
253 ELSE IF( j.EQ.n ) THEN
254 x( jj ) =
zlarnd( 2, iseed )
255 jj = jj + ( n-j+1 )
256 j = j + 1
257 END IF
258 END IF
259
260 RETURN
261
262
263
complex *16 function zlarnd(idist, iseed)
ZLARND