282 SUBROUTINE cunbdb( TRANS, SIGNS, M, P, Q, X11, LDX11, X12,
284 $ X21, LDX21, X22, LDX22, THETA, PHI, TAUP1,
285 $ TAUP2, TAUQ1, TAUQ2, WORK, LWORK, INFO )
292 CHARACTER SIGNS, TRANS
293 INTEGER INFO, LDX11, LDX12, LDX21, LDX22, LWORK, M, P,
297 REAL PHI( * ), THETA( * )
298 COMPLEX TAUP1( * ), TAUP2( * ), TAUQ1( * ), TAUQ2( * ),
299 $ WORK( * ), X11( LDX11, * ), X12( LDX12, * ),
300 $ x21( ldx21, * ), x22( ldx22, * )
307 PARAMETER ( REALONE = 1.0e0 )
310 LOGICAL COLMAJOR, LQUERY
311 INTEGER I, LWORKMIN, LWORKOPT
321 REAL SCNRM2, SROUNDUP_LWORK
323 EXTERNAL SCNRM2, SROUNDUP_LWORK, LSAME
326 INTRINSIC atan2, cos, max, min, sin
327 INTRINSIC cmplx, conjg
334 colmajor = .NOT. lsame( trans,
'T' )
335 IF( .NOT. lsame( signs,
'O' ) )
THEN
346 lquery = lwork .EQ. -1
350 ELSE IF( p .LT. 0 .OR. p .GT. m )
THEN
352 ELSE IF( q .LT. 0 .OR. q .GT. p .OR. q .GT. m-p .OR.
355 ELSE IF( colmajor .AND. ldx11 .LT. max( 1, p ) )
THEN
357 ELSE IF( .NOT.colmajor .AND. ldx11 .LT. max( 1, q ) )
THEN
359 ELSE IF( colmajor .AND. ldx12 .LT. max( 1, p ) )
THEN
361 ELSE IF( .NOT.colmajor .AND. ldx12 .LT. max( 1, m-q ) )
THEN
363 ELSE IF( colmajor .AND. ldx21 .LT. max( 1, m-p ) )
THEN
365 ELSE IF( .NOT.colmajor .AND. ldx21 .LT. max( 1, q ) )
THEN
367 ELSE IF( colmajor .AND. ldx22 .LT. max( 1, m-p ) )
THEN
369 ELSE IF( .NOT.colmajor .AND. ldx22 .LT. max( 1, m-q ) )
THEN
375 IF( info .EQ. 0 )
THEN
378 work(1) = sroundup_lwork(lworkopt)
379 IF( lwork .LT. lworkmin .AND. .NOT. lquery )
THEN
383 IF( info .NE. 0 )
THEN
384 CALL xerbla(
'xORBDB', -info )
386 ELSE IF( lquery )
THEN
399 CALL cscal( p-i+1, cmplx( z1, 0.0e0 ), x11(i,i), 1 )
401 CALL cscal( p-i+1, cmplx( z1*cos(phi(i-1)), 0.0e0 ),
403 CALL caxpy( p-i+1, cmplx( -z1*z3*z4*sin(phi(i-1)),
404 $ 0.0e0 ), x12(i,i-1), 1, x11(i,i), 1 )
407 CALL cscal( m-p-i+1, cmplx( z2, 0.0e0 ), x21(i,i), 1 )
409 CALL cscal( m-p-i+1, cmplx( z2*cos(phi(i-1)), 0.0e0 ),
411 CALL caxpy( m-p-i+1, cmplx( -z2*z3*z4*sin(phi(i-1)),
412 $ 0.0e0 ), x22(i,i-1), 1, x21(i,i), 1 )
415 theta(i) = atan2( scnrm2( m-p-i+1, x21(i,i), 1 ),
416 $ scnrm2( p-i+1, x11(i,i), 1 ) )
419 CALL clarfgp( p-i+1, x11(i,i), x11(i+1,i), 1,
421 ELSE IF ( p .EQ. i )
THEN
422 CALL clarfgp( p-i+1, x11(i,i), x11(i,i), 1, taup1(i) )
424 IF ( m-p .GT. i )
THEN
425 CALL clarfgp( m-p-i+1, x21(i,i), x21(i+1,i), 1,
427 ELSE IF ( m-p .EQ. i )
THEN
428 CALL clarfgp( m-p-i+1, x21(i,i), x21(i,i), 1,
433 CALL clarf1f(
'L', p-i+1, q-i, x11(i,i), 1,
434 $ conjg(taup1(i)), x11(i,i+1), ldx11,
436 CALL clarf1f(
'L', m-p-i+1, q-i, x21(i,i), 1,
437 $ conjg(taup2(i)), x21(i,i+1), ldx21,
440 IF ( m-q+1 .GT. i )
THEN
441 CALL clarf1f(
'L', p-i+1, m-q-i+1, x11(i,i), 1,
442 $ conjg(taup1(i)), x12(i,i), ldx12, work )
443 CALL clarf1f(
'L', m-p-i+1, m-q-i+1, x21(i,i), 1,
444 $ conjg(taup2(i)), x22(i,i), ldx22, work )
448 CALL cscal( q-i, cmplx( -z1*z3*sin(theta(i)), 0.0e0 ),
449 $ x11(i,i+1), ldx11 )
450 CALL caxpy( q-i, cmplx( z2*z3*cos(theta(i)), 0.0e0 ),
451 $ x21(i,i+1), ldx21, x11(i,i+1), ldx11 )
453 CALL cscal( m-q-i+1, cmplx( -z1*z4*sin(theta(i)),
456 CALL caxpy( m-q-i+1, cmplx( z2*z4*cos(theta(i)), 0.0e0 ),
457 $ x22(i,i), ldx22, x12(i,i), ldx12 )
460 $ phi(i) = atan2( scnrm2( q-i, x11(i,i+1), ldx11 ),
461 $ scnrm2( m-q-i+1, x12(i,i), ldx12 ) )
464 CALL clacgv( q-i, x11(i,i+1), ldx11 )
465 IF ( i .EQ. q-1 )
THEN
466 CALL clarfgp( q-i, x11(i,i+1), x11(i,i+1), ldx11,
469 CALL clarfgp( q-i, x11(i,i+1), x11(i,i+2), ldx11,
473 IF ( m-q+1 .GT. i )
THEN
474 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
475 IF ( m-q .EQ. i )
THEN
476 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i), ldx12,
479 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i+1), ldx12,
485 CALL clarf1f(
'R', p-i, q-i, x11(i,i+1), ldx11,
486 $ tauq1(i), x11(i+1,i+1), ldx11, work )
487 CALL clarf1f(
'R', m-p-i, q-i, x11(i,i+1), ldx11,
488 $ tauq1(i), x21(i+1,i+1), ldx21, work )
491 CALL clarf1f(
'R', p-i, m-q-i+1, x12(i,i), ldx12,
492 $ tauq2(i), x12(i+1,i), ldx12, work )
494 IF ( m-p .GT. i )
THEN
495 CALL clarf1f(
'R', m-p-i, m-q-i+1, x12(i,i), ldx12,
496 $ tauq2(i), x22(i+1,i), ldx22, work )
500 $
CALL clacgv( q-i, x11(i,i+1), ldx11 )
501 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
509 CALL cscal( m-q-i+1, cmplx( -z1*z4, 0.0e0 ), x12(i,i),
511 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
512 IF ( i .GE. m-q )
THEN
513 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i), ldx12,
516 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i+1), ldx12,
521 CALL clarf1f(
'R', p-i, m-q-i+1, x12(i,i), ldx12,
522 $ tauq2(i), x12(i+1,i), ldx12, work )
525 $
CALL clarf1f(
'R', m-p-q, m-q-i+1, x12(i,i), ldx12,
526 $ tauq2(i), x22(q+1,i), ldx22, work )
528 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
536 CALL cscal( m-p-q-i+1, cmplx( z2*z4, 0.0e0 ),
537 $ x22(q+i,p+i), ldx22 )
538 CALL clacgv( m-p-q-i+1, x22(q+i,p+i), ldx22 )
539 CALL clarfgp( m-p-q-i+1, x22(q+i,p+i), x22(q+i,p+i+1),
540 $ ldx22, tauq2(p+i) )
541 CALL clarf1f(
'R', m-p-q-i, m-p-q-i+1, x22(q+i,p+i),
542 $ ldx22, tauq2(p+i), x22(q+i+1,p+i), ldx22,
545 CALL clacgv( m-p-q-i+1, x22(q+i,p+i), ldx22 )
556 CALL cscal( p-i+1, cmplx( z1, 0.0e0 ), x11(i,i),
559 CALL cscal( p-i+1, cmplx( z1*cos(phi(i-1)), 0.0e0 ),
561 CALL caxpy( p-i+1, cmplx( -z1*z3*z4*sin(phi(i-1)),
562 $ 0.0e0 ), x12(i-1,i), ldx12, x11(i,i), ldx11 )
565 CALL cscal( m-p-i+1, cmplx( z2, 0.0e0 ), x21(i,i),
568 CALL cscal( m-p-i+1, cmplx( z2*cos(phi(i-1)), 0.0e0 ),
570 CALL caxpy( m-p-i+1, cmplx( -z2*z3*z4*sin(phi(i-1)),
571 $ 0.0e0 ), x22(i-1,i), ldx22, x21(i,i), ldx21 )
574 theta(i) = atan2( scnrm2( m-p-i+1, x21(i,i), ldx21 ),
575 $ scnrm2( p-i+1, x11(i,i), ldx11 ) )
577 CALL clacgv( p-i+1, x11(i,i), ldx11 )
578 CALL clacgv( m-p-i+1, x21(i,i), ldx21 )
580 CALL clarfgp( p-i+1, x11(i,i), x11(i,i+1), ldx11,
582 IF ( i .EQ. m-p )
THEN
583 CALL clarfgp( m-p-i+1, x21(i,i), x21(i,i), ldx21,
586 CALL clarfgp( m-p-i+1, x21(i,i), x21(i,i+1), ldx21,
590 CALL clarf1f(
'R', q-i, p-i+1, x11(i,i), ldx11, taup1(i),
591 $ x11(i+1,i), ldx11, work )
592 CALL clarf1f(
'R', m-q-i+1, p-i+1, x11(i,i), ldx11,
593 $ taup1(i), x12(i,i), ldx12, work )
594 CALL clarf1f(
'R', q-i, m-p-i+1, x21(i,i), ldx21,
595 $ taup2(i), x21(i+1,i), ldx21, work )
596 CALL clarf1f(
'R', m-q-i+1, m-p-i+1, x21(i,i), ldx21,
597 $ taup2(i), x22(i,i), ldx22, work )
599 CALL clacgv( p-i+1, x11(i,i), ldx11 )
600 CALL clacgv( m-p-i+1, x21(i,i), ldx21 )
603 CALL cscal( q-i, cmplx( -z1*z3*sin(theta(i)), 0.0e0 ),
605 CALL caxpy( q-i, cmplx( z2*z3*cos(theta(i)), 0.0e0 ),
606 $ x21(i+1,i), 1, x11(i+1,i), 1 )
608 CALL cscal( m-q-i+1, cmplx( -z1*z4*sin(theta(i)),
611 CALL caxpy( m-q-i+1, cmplx( z2*z4*cos(theta(i)), 0.0e0 ),
612 $ x22(i,i), 1, x12(i,i), 1 )
615 $ phi(i) = atan2( scnrm2( q-i, x11(i+1,i), 1 ),
616 $ scnrm2( m-q-i+1, x12(i,i), 1 ) )
619 CALL clarfgp( q-i, x11(i+1,i), x11(i+2,i), 1,
622 CALL clarfgp( m-q-i+1, x12(i,i), x12(i+1,i), 1,
626 CALL clarf1f(
'L', q-i, p-i, x11(i+1,i), 1,
627 $ conjg(tauq1(i)), x11(i+1,i+1), ldx11,
629 CALL clarf1f(
'L', q-i, m-p-i, x11(i+1,i), 1,
630 $ conjg(tauq1(i)), x21(i+1,i+1), ldx21,
633 CALL clarf1f(
'L', m-q-i+1, p-i, x12(i,i), 1,
634 $ conjg(tauq2(i)), x12(i,i+1), ldx12, work )
636 IF ( m-p .GT. i )
THEN
637 CALL clarf1f(
'L', m-q-i+1, m-p-i, x12(i,i), 1,
638 $ conjg(tauq2(i)), x22(i,i+1), ldx22,
647 CALL cscal( m-q-i+1, cmplx( -z1*z4, 0.0e0 ), x12(i,i),
649 CALL clarfgp( m-q-i+1, x12(i,i), x12(i+1,i), 1,
653 CALL clarf1f(
'L', m-q-i+1, p-i, x12(i,i), 1,
654 $ conjg(tauq2(i)), x12(i,i+1), ldx12,
658 $
CALL clarf1f(
'L', m-q-i+1, m-p-q, x12(i,i), 1,
659 $ conjg(tauq2(i)), x22(i,q+1), ldx22,
668 CALL cscal( m-p-q-i+1, cmplx( z2*z4, 0.0e0 ),
670 CALL clarfgp( m-p-q-i+1, x22(p+i,q+i), x22(p+i+1,q+i), 1,
672 IF ( m-p-q .NE. i )
THEN
673 CALL clarf1f(
'L', m-p-q-i+1, m-p-q-i, x22(p+i,q+i),
674 $ 1, conjg(tauq2(p+i)), x22(p+i,q+i+1),