187
188
189
190
191
192
193 CHARACTER VECT
194 INTEGER INFO, KL, KU, LDAB, LDC, LDPT, LDQ, M, N, NCC
195
196
197 DOUBLE PRECISION AB( LDAB, * ), C( LDC, * ), D( * ), E( * ),
198 $ PT( LDPT, * ), Q( LDQ, * ), WORK( * )
199
200
201
202
203
204 DOUBLE PRECISION ZERO, ONE
205 parameter( zero = 0.0d+0, one = 1.0d+0 )
206
207
208 LOGICAL WANTB, WANTC, WANTPT, WANTQ
209 INTEGER I, INCA, J, J1, J2, KB, KB1, KK, KLM, KLU1,
210 $ KUN, L, MINMN, ML, ML0, MN, MU, MU0, NR, NRT
211 DOUBLE PRECISION RA, RB, RC, RS
212
213
215
216
217 INTRINSIC max, min
218
219
220 LOGICAL LSAME
222
223
224
225
226
227 wantb =
lsame( vect,
'B' )
228 wantq =
lsame( vect,
'Q' ) .OR. wantb
229 wantpt =
lsame( vect,
'P' ) .OR. wantb
230 wantc = ncc.GT.0
231 klu1 = kl + ku + 1
232 info = 0
233 IF( .NOT.wantq .AND. .NOT.wantpt .AND. .NOT.
lsame( vect,
'N' ) )
234 $ THEN
235 info = -1
236 ELSE IF( m.LT.0 ) THEN
237 info = -2
238 ELSE IF( n.LT.0 ) THEN
239 info = -3
240 ELSE IF( ncc.LT.0 ) THEN
241 info = -4
242 ELSE IF( kl.LT.0 ) THEN
243 info = -5
244 ELSE IF( ku.LT.0 ) THEN
245 info = -6
246 ELSE IF( ldab.LT.klu1 ) THEN
247 info = -8
248 ELSE IF( ldq.LT.1 .OR. wantq .AND. ldq.LT.max( 1, m ) ) THEN
249 info = -12
250 ELSE IF( ldpt.LT.1 .OR. wantpt .AND. ldpt.LT.max( 1, n ) ) THEN
251 info = -14
252 ELSE IF( ldc.LT.1 .OR. wantc .AND. ldc.LT.max( 1, m ) ) THEN
253 info = -16
254 END IF
255 IF( info.NE.0 ) THEN
256 CALL xerbla(
'DGBBRD', -info )
257 RETURN
258 END IF
259
260
261
262 IF( wantq )
263 $
CALL dlaset(
'Full', m, m, zero, one, q, ldq )
264 IF( wantpt )
265 $
CALL dlaset(
'Full', n, n, zero, one, pt, ldpt )
266
267
268
269 IF( m.EQ.0 .OR. n.EQ.0 )
270 $ RETURN
271
272 minmn = min( m, n )
273
274 IF( kl+ku.GT.1 ) THEN
275
276
277
278
279
280 IF( ku.GT.0 ) THEN
281 ml0 = 1
282 mu0 = 2
283 ELSE
284 ml0 = 2
285 mu0 = 1
286 END IF
287
288
289
290
291
292
293
294 mn = max( m, n )
295 klm = min( m-1, kl )
296 kun = min( n-1, ku )
297 kb = klm + kun
298 kb1 = kb + 1
299 inca = kb1*ldab
300 nr = 0
301 j1 = klm + 2
302 j2 = 1 - kun
303
304 DO 90 i = 1, minmn
305
306
307
308 ml = klm + 1
309 mu = kun + 1
310 DO 80 kk = 1, kb
311 j1 = j1 + kb
312 j2 = j2 + kb
313
314
315
316
317 IF( nr.GT.0 )
318 $
CALL dlargv( nr, ab( klu1, j1-klm-1 ), inca,
319 $ work( j1 ), kb1, work( mn+j1 ), kb1 )
320
321
322
323 DO 10 l = 1, kb
324 IF( j2-klm+l-1.GT.n ) THEN
325 nrt = nr - 1
326 ELSE
327 nrt = nr
328 END IF
329 IF( nrt.GT.0 )
330 $
CALL dlartv( nrt, ab( klu1-l, j1-klm+l-1 ), inca,
331 $ ab( klu1-l+1, j1-klm+l-1 ), inca,
332 $ work( mn+j1 ), work( j1 ), kb1 )
333 10 CONTINUE
334
335 IF( ml.GT.ml0 ) THEN
336 IF( ml.LE.m-i+1 ) THEN
337
338
339
340
341 CALL dlartg( ab( ku+ml-1, i ), ab( ku+ml, i ),
342 $ work( mn+i+ml-1 ), work( i+ml-1 ),
343 $ ra )
344 ab( ku+ml-1, i ) = ra
345 IF( i.LT.n )
346 $
CALL drot( min( ku+ml-2, n-i ),
347 $ ab( ku+ml-2, i+1 ), ldab-1,
348 $ ab( ku+ml-1, i+1 ), ldab-1,
349 $ work( mn+i+ml-1 ), work( i+ml-1 ) )
350 END IF
351 nr = nr + 1
352 j1 = j1 - kb1
353 END IF
354
355 IF( wantq ) THEN
356
357
358
359 DO 20 j = j1, j2, kb1
360 CALL drot( m, q( 1, j-1 ), 1, q( 1, j ), 1,
361 $ work( mn+j ), work( j ) )
362 20 CONTINUE
363 END IF
364
365 IF( wantc ) THEN
366
367
368
369 DO 30 j = j1, j2, kb1
370 CALL drot( ncc, c( j-1, 1 ), ldc, c( j, 1 ), ldc,
371 $ work( mn+j ), work( j ) )
372 30 CONTINUE
373 END IF
374
375 IF( j2+kun.GT.n ) THEN
376
377
378
379 nr = nr - 1
380 j2 = j2 - kb1
381 END IF
382
383 DO 40 j = j1, j2, kb1
384
385
386
387
388 work( j+kun ) = work( j )*ab( 1, j+kun )
389 ab( 1, j+kun ) = work( mn+j )*ab( 1, j+kun )
390 40 CONTINUE
391
392
393
394
395 IF( nr.GT.0 )
396 $
CALL dlargv( nr, ab( 1, j1+kun-1 ), inca,
397 $ work( j1+kun ), kb1, work( mn+j1+kun ),
398 $ kb1 )
399
400
401
402 DO 50 l = 1, kb
403 IF( j2+l-1.GT.m ) THEN
404 nrt = nr - 1
405 ELSE
406 nrt = nr
407 END IF
408 IF( nrt.GT.0 )
409 $
CALL dlartv( nrt, ab( l+1, j1+kun-1 ), inca,
410 $ ab( l, j1+kun ), inca,
411 $ work( mn+j1+kun ), work( j1+kun ),
412 $ kb1 )
413 50 CONTINUE
414
415 IF( ml.EQ.ml0 .AND. mu.GT.mu0 ) THEN
416 IF( mu.LE.n-i+1 ) THEN
417
418
419
420
421 CALL dlartg( ab( ku-mu+3, i+mu-2 ),
422 $ ab( ku-mu+2, i+mu-1 ),
423 $ work( mn+i+mu-1 ), work( i+mu-1 ),
424 $ ra )
425 ab( ku-mu+3, i+mu-2 ) = ra
426 CALL drot( min( kl+mu-2, m-i ),
427 $ ab( ku-mu+4, i+mu-2 ), 1,
428 $ ab( ku-mu+3, i+mu-1 ), 1,
429 $ work( mn+i+mu-1 ), work( i+mu-1 ) )
430 END IF
431 nr = nr + 1
432 j1 = j1 - kb1
433 END IF
434
435 IF( wantpt ) THEN
436
437
438
439 DO 60 j = j1, j2, kb1
440 CALL drot( n, pt( j+kun-1, 1 ), ldpt,
441 $ pt( j+kun, 1 ), ldpt, work( mn+j+kun ),
442 $ work( j+kun ) )
443 60 CONTINUE
444 END IF
445
446 IF( j2+kb.GT.m ) THEN
447
448
449
450 nr = nr - 1
451 j2 = j2 - kb1
452 END IF
453
454 DO 70 j = j1, j2, kb1
455
456
457
458
459 work( j+kb ) = work( j+kun )*ab( klu1, j+kun )
460 ab( klu1, j+kun ) = work( mn+j+kun )*ab( klu1, j+kun )
461 70 CONTINUE
462
463 IF( ml.GT.ml0 ) THEN
464 ml = ml - 1
465 ELSE
466 mu = mu - 1
467 END IF
468 80 CONTINUE
469 90 CONTINUE
470 END IF
471
472 IF( ku.EQ.0 .AND. kl.GT.0 ) THEN
473
474
475
476
477
478
479
480 DO 100 i = 1, min( m-1, n )
481 CALL dlartg( ab( 1, i ), ab( 2, i ), rc, rs, ra )
482 d( i ) = ra
483 IF( i.LT.n ) THEN
484 e( i ) = rs*ab( 1, i+1 )
485 ab( 1, i+1 ) = rc*ab( 1, i+1 )
486 END IF
487 IF( wantq )
488 $
CALL drot( m, q( 1, i ), 1, q( 1, i+1 ), 1, rc, rs )
489 IF( wantc )
490 $
CALL drot( ncc, c( i, 1 ), ldc, c( i+1, 1 ), ldc, rc,
491 $ rs )
492 100 CONTINUE
493 IF( m.LE.n )
494 $ d( m ) = ab( 1, m )
495 ELSE IF( ku.GT.0 ) THEN
496
497
498
499 IF( m.LT.n ) THEN
500
501
502
503
504
505 rb = ab( ku, m+1 )
506 DO 110 i = m, 1, -1
507 CALL dlartg( ab( ku+1, i ), rb, rc, rs, ra )
508 d( i ) = ra
509 IF( i.GT.1 ) THEN
510 rb = -rs*ab( ku, i )
511 e( i-1 ) = rc*ab( ku, i )
512 END IF
513 IF( wantpt )
514 $
CALL drot( n, pt( i, 1 ), ldpt, pt( m+1, 1 ), ldpt,
515 $ rc, rs )
516 110 CONTINUE
517 ELSE
518
519
520
521 DO 120 i = 1, minmn - 1
522 e( i ) = ab( ku, i+1 )
523 120 CONTINUE
524 DO 130 i = 1, minmn
525 d( i ) = ab( ku+1, i )
526 130 CONTINUE
527 END IF
528 ELSE
529
530
531
532
533 DO 140 i = 1, minmn - 1
534 e( i ) = zero
535 140 CONTINUE
536 DO 150 i = 1, minmn
537 d( i ) = ab( 1, i )
538 150 CONTINUE
539 END IF
540 RETURN
541
542
543
subroutine xerbla(srname, info)
subroutine dlargv(n, x, incx, y, incy, c, incc)
DLARGV generates a vector of plane rotations with real cosines and real sines.
subroutine dlartg(f, g, c, s, r)
DLARTG generates a plane rotation with real cosine and real sine.
subroutine dlartv(n, x, incx, y, incy, c, s, incc)
DLARTV applies a vector of plane rotations with real cosines and real sines to the elements of a pair...
subroutine dlaset(uplo, m, n, alpha, beta, a, lda)
DLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
logical function lsame(ca, cb)
LSAME
subroutine drot(n, dx, incx, dy, incy, c, s)
DROT