112
113
114
115
116
117
118 CHARACTER UPLO, WAY
119 INTEGER INFO, LDA, N
120
121
122 INTEGER IPIV( * )
123 COMPLEX A( LDA, * ), E( * )
124
125
126
127
128
129 COMPLEX ZERO
130 parameter( zero = (0.0e+0,0.0e+0) )
131
132
133 LOGICAL LSAME
135
136
138
139 LOGICAL UPPER, CONVERT
140 INTEGER I, IP, J
141 COMPLEX TEMP
142
143
144
145 info = 0
146 upper =
lsame( uplo,
'U' )
147 convert =
lsame( way,
'C' )
148 IF( .NOT.upper .AND. .NOT.
lsame( uplo,
'L' ) )
THEN
149 info = -1
150 ELSE IF( .NOT.convert .AND. .NOT.
lsame( way,
'R' ) )
THEN
151 info = -2
152 ELSE IF( n.LT.0 ) THEN
153 info = -3
154 ELSE IF( lda.LT.max( 1, n ) ) THEN
155 info = -5
156
157 END IF
158 IF( info.NE.0 ) THEN
159 CALL xerbla(
'CSYCONV', -info )
160 RETURN
161 END IF
162
163
164
165 IF( n.EQ.0 )
166 $ RETURN
167
168 IF( upper ) THEN
169
170
171
172
173
174
175
176 IF ( convert ) THEN
177 i=n
178 e(1)=zero
179 DO WHILE ( i .GT. 1 )
180 IF( ipiv(i) .LT. 0 ) THEN
181 e(i)=a(i-1,i)
182 e(i-1)=zero
183 a(i-1,i)=zero
184 i=i-1
185 ELSE
186 e(i)=zero
187 ENDIF
188 i=i-1
189 END DO
190
191
192
193 i=n
194 DO WHILE ( i .GE. 1 )
195 IF( ipiv(i) .GT. 0) THEN
196 ip=ipiv(i)
197 IF( i .LT. n) THEN
198 DO 12 j= i+1,n
199 temp=a(ip,j)
200 a(ip,j)=a(i,j)
201 a(i,j)=temp
202 12 CONTINUE
203 ENDIF
204 ELSE
205 ip=-ipiv(i)
206 IF( i .LT. n) THEN
207 DO 13 j= i+1,n
208 temp=a(ip,j)
209 a(ip,j)=a(i-1,j)
210 a(i-1,j)=temp
211 13 CONTINUE
212 ENDIF
213 i=i-1
214 ENDIF
215 i=i-1
216 END DO
217
218 ELSE
219
220
221
222
223
224
225 i=1
226 DO WHILE ( i .LE. n )
227 IF( ipiv(i) .GT. 0 ) THEN
228 ip=ipiv(i)
229 IF( i .LT. n) THEN
230 DO j= i+1,n
231 temp=a(ip,j)
232 a(ip,j)=a(i,j)
233 a(i,j)=temp
234 END DO
235 ENDIF
236 ELSE
237 ip=-ipiv(i)
238 i=i+1
239 IF( i .LT. n) THEN
240 DO j= i+1,n
241 temp=a(ip,j)
242 a(ip,j)=a(i-1,j)
243 a(i-1,j)=temp
244 END DO
245 ENDIF
246 ENDIF
247 i=i+1
248 END DO
249
250
251
252 i=n
253 DO WHILE ( i .GT. 1 )
254 IF( ipiv(i) .LT. 0 ) THEN
255 a(i-1,i)=e(i)
256 i=i-1
257 ENDIF
258 i=i-1
259 END DO
260 END IF
261 ELSE
262
263
264
265 IF ( convert ) THEN
266
267
268
269
270
271
272 i=1
273 e(n)=zero
274 DO WHILE ( i .LE. n )
275 IF( i.LT.n .AND. ipiv(i) .LT. 0 ) THEN
276 e(i)=a(i+1,i)
277 e(i+1)=zero
278 a(i+1,i)=zero
279 i=i+1
280 ELSE
281 e(i)=zero
282 ENDIF
283 i=i+1
284 END DO
285
286
287
288 i=1
289 DO WHILE ( i .LE. n )
290 IF( ipiv(i) .GT. 0 ) THEN
291 ip=ipiv(i)
292 IF (i .GT. 1) THEN
293 DO 22 j= 1,i-1
294 temp=a(ip,j)
295 a(ip,j)=a(i,j)
296 a(i,j)=temp
297 22 CONTINUE
298 ENDIF
299 ELSE
300 ip=-ipiv(i)
301 IF (i .GT. 1) THEN
302 DO 23 j= 1,i-1
303 temp=a(ip,j)
304 a(ip,j)=a(i+1,j)
305 a(i+1,j)=temp
306 23 CONTINUE
307 ENDIF
308 i=i+1
309 ENDIF
310 i=i+1
311 END DO
312 ELSE
313
314
315
316
317
318
319 i=n
320 DO WHILE ( i .GE. 1 )
321 IF( ipiv(i) .GT. 0 ) THEN
322 ip=ipiv(i)
323 IF (i .GT. 1) THEN
324 DO j= 1,i-1
325 temp=a(i,j)
326 a(i,j)=a(ip,j)
327 a(ip,j)=temp
328 END DO
329 ENDIF
330 ELSE
331 ip=-ipiv(i)
332 i=i-1
333 IF (i .GT. 1) THEN
334 DO j= 1,i-1
335 temp=a(i+1,j)
336 a(i+1,j)=a(ip,j)
337 a(ip,j)=temp
338 END DO
339 ENDIF
340 ENDIF
341 i=i-1
342 END DO
343
344
345
346 i=1
347 DO WHILE ( i .LE. n-1 )
348 IF( ipiv(i) .LT. 0 ) THEN
349 a(i+1,i)=e(i)
350 i=i+1
351 ENDIF
352 i=i+1
353 END DO
354 END IF
355 END IF
356
357 RETURN
358
359
360
subroutine xerbla(srname, info)
logical function lsame(ca, cb)
LSAME