284 SUBROUTINE cunbdb( TRANS, SIGNS, M, P, Q, X11, LDX11, X12, LDX12,
285 $ X21, LDX21, X22, LDX22, THETA, PHI, TAUP1,
286 $ TAUP2, TAUQ1, TAUQ2, WORK, LWORK, INFO )
293 CHARACTER SIGNS, TRANS
294 INTEGER INFO, LDX11, LDX12, LDX21, LDX22, LWORK, M, P,
298 REAL PHI( * ), THETA( * )
299 COMPLEX TAUP1( * ), TAUP2( * ), TAUQ1( * ), TAUQ2( * ),
300 $ work( * ), x11( ldx11, * ), x12( ldx12, * ),
301 $ x21( ldx21, * ), x22( ldx22, * )
308 PARAMETER ( REALONE = 1.0e0 )
310 parameter( one = (1.0e0,0.0e0) )
313 LOGICAL COLMAJOR, LQUERY
314 INTEGER I, LWORKMIN, LWORKOPT
323 REAL SCNRM2, SROUNDUP_LWORK
325 EXTERNAL scnrm2, sroundup_lwork, lsame
328 INTRINSIC atan2, cos, max, min, sin
329 INTRINSIC cmplx, conjg
336 colmajor = .NOT. lsame( trans,
'T' )
337 IF( .NOT. lsame( signs,
'O' ) )
THEN
348 lquery = lwork .EQ. -1
352 ELSE IF( p .LT. 0 .OR. p .GT. m )
THEN
354 ELSE IF( q .LT. 0 .OR. q .GT. p .OR. q .GT. m-p .OR.
357 ELSE IF( colmajor .AND. ldx11 .LT. max( 1, p ) )
THEN
359 ELSE IF( .NOT.colmajor .AND. ldx11 .LT. max( 1, q ) )
THEN
361 ELSE IF( colmajor .AND. ldx12 .LT. max( 1, p ) )
THEN
363 ELSE IF( .NOT.colmajor .AND. ldx12 .LT. max( 1, m-q ) )
THEN
365 ELSE IF( colmajor .AND. ldx21 .LT. max( 1, m-p ) )
THEN
367 ELSE IF( .NOT.colmajor .AND. ldx21 .LT. max( 1, q ) )
THEN
369 ELSE IF( colmajor .AND. ldx22 .LT. max( 1, m-p ) )
THEN
371 ELSE IF( .NOT.colmajor .AND. ldx22 .LT. max( 1, m-q ) )
THEN
377 IF( info .EQ. 0 )
THEN
380 work(1) = sroundup_lwork(lworkopt)
381 IF( lwork .LT. lworkmin .AND. .NOT. lquery )
THEN
385 IF( info .NE. 0 )
THEN
386 CALL xerbla(
'xORBDB', -info )
388 ELSE IF( lquery )
THEN
401 CALL cscal( p-i+1, cmplx( z1, 0.0e0 ), x11(i,i), 1 )
403 CALL cscal( p-i+1, cmplx( z1*cos(phi(i-1)), 0.0e0 ),
405 CALL caxpy( p-i+1, cmplx( -z1*z3*z4*sin(phi(i-1)),
406 $ 0.0e0 ), x12(i,i-1), 1, x11(i,i), 1 )
409 CALL cscal( m-p-i+1, cmplx( z2, 0.0e0 ), x21(i,i), 1 )
411 CALL cscal( m-p-i+1, cmplx( z2*cos(phi(i-1)), 0.0e0 ),
413 CALL caxpy( m-p-i+1, cmplx( -z2*z3*z4*sin(phi(i-1)),
414 $ 0.0e0 ), x22(i,i-1), 1, x21(i,i), 1 )
417 theta(i) = atan2( scnrm2( m-p-i+1, x21(i,i), 1 ),
418 $ scnrm2( p-i+1, x11(i,i), 1 ) )
421 CALL clarfgp( p-i+1, x11(i,i), x11(i+1,i), 1, taup1(i) )
422 ELSE IF ( p .EQ. i )
THEN
423 CALL clarfgp( p-i+1, x11(i,i), x11(i,i), 1, taup1(i) )
426 IF ( m-p .GT. i )
THEN
427 CALL clarfgp( m-p-i+1, x21(i,i), x21(i+1,i), 1,
429 ELSE IF ( m-p .EQ. i )
THEN
430 CALL clarfgp( m-p-i+1, x21(i,i), x21(i,i), 1,
436 CALL clarf(
'L', p-i+1, q-i, x11(i,i), 1,
437 $ conjg(taup1(i)), x11(i,i+1), ldx11, work )
438 CALL clarf(
'L', m-p-i+1, q-i, x21(i,i), 1,
439 $ conjg(taup2(i)), x21(i,i+1), ldx21, work )
441 IF ( m-q+1 .GT. i )
THEN
442 CALL clarf(
'L', p-i+1, m-q-i+1, x11(i,i), 1,
443 $ conjg(taup1(i)), x12(i,i), ldx12, work )
444 CALL clarf(
'L', m-p-i+1, m-q-i+1, x21(i,i), 1,
445 $ conjg(taup2(i)), x22(i,i), ldx22, work )
449 CALL cscal( q-i, cmplx( -z1*z3*sin(theta(i)), 0.0e0 ),
450 $ x11(i,i+1), ldx11 )
451 CALL caxpy( q-i, cmplx( z2*z3*cos(theta(i)), 0.0e0 ),
452 $ x21(i,i+1), ldx21, x11(i,i+1), ldx11 )
454 CALL cscal( m-q-i+1, cmplx( -z1*z4*sin(theta(i)), 0.0e0 ),
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,
474 IF ( m-q+1 .GT. i )
THEN
475 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
476 IF ( m-q .EQ. i )
THEN
477 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i), ldx12,
480 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i+1), ldx12,
487 CALL clarf(
'R', p-i, q-i, x11(i,i+1), ldx11, tauq1(i),
488 $ x11(i+1,i+1), ldx11, work )
489 CALL clarf(
'R', m-p-i, q-i, x11(i,i+1), ldx11, tauq1(i),
490 $ x21(i+1,i+1), ldx21, work )
493 CALL clarf(
'R', p-i, m-q-i+1, x12(i,i), ldx12, tauq2(i),
494 $ x12(i+1,i), ldx12, work )
496 IF ( m-p .GT. i )
THEN
497 CALL clarf(
'R', m-p-i, m-q-i+1, x12(i,i), ldx12,
498 $ tauq2(i), x22(i+1,i), ldx22, work )
502 $
CALL clacgv( q-i, x11(i,i+1), ldx11 )
503 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
511 CALL cscal( m-q-i+1, cmplx( -z1*z4, 0.0e0 ), x12(i,i),
513 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
514 IF ( i .GE. m-q )
THEN
515 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i), ldx12,
518 CALL clarfgp( m-q-i+1, x12(i,i), x12(i,i+1), ldx12,
524 CALL clarf(
'R', p-i, m-q-i+1, x12(i,i), ldx12, tauq2(i),
525 $ x12(i+1,i), ldx12, work )
528 $
CALL clarf(
'R', m-p-q, m-q-i+1, x12(i,i), ldx12,
529 $ tauq2(i), x22(q+1,i), ldx22, work )
531 CALL clacgv( m-q-i+1, x12(i,i), ldx12 )
539 CALL cscal( m-p-q-i+1, cmplx( z2*z4, 0.0e0 ),
540 $ x22(q+i,p+i), ldx22 )
541 CALL clacgv( m-p-q-i+1, x22(q+i,p+i), ldx22 )
542 CALL clarfgp( m-p-q-i+1, x22(q+i,p+i), x22(q+i,p+i+1),
543 $ ldx22, tauq2(p+i) )
545 CALL clarf(
'R', m-p-q-i, m-p-q-i+1, x22(q+i,p+i), ldx22,
546 $ tauq2(p+i), x22(q+i+1,p+i), ldx22, work )
548 CALL clacgv( m-p-q-i+1, x22(q+i,p+i), ldx22 )
559 CALL cscal( p-i+1, cmplx( z1, 0.0e0 ), x11(i,i),
562 CALL cscal( p-i+1, cmplx( z1*cos(phi(i-1)), 0.0e0 ),
564 CALL caxpy( p-i+1, cmplx( -z1*z3*z4*sin(phi(i-1)),
565 $ 0.0e0 ), x12(i-1,i), ldx12, x11(i,i), ldx11 )
568 CALL cscal( m-p-i+1, cmplx( z2, 0.0e0 ), x21(i,i),
571 CALL cscal( m-p-i+1, cmplx( z2*cos(phi(i-1)), 0.0e0 ),
573 CALL caxpy( m-p-i+1, cmplx( -z2*z3*z4*sin(phi(i-1)),
574 $ 0.0e0 ), x22(i-1,i), ldx22, x21(i,i), ldx21 )
577 theta(i) = atan2( scnrm2( m-p-i+1, x21(i,i), ldx21 ),
578 $ scnrm2( p-i+1, x11(i,i), ldx11 ) )
580 CALL clacgv( p-i+1, x11(i,i), ldx11 )
581 CALL clacgv( m-p-i+1, x21(i,i), ldx21 )
583 CALL clarfgp( p-i+1, x11(i,i), x11(i,i+1), ldx11, taup1(i) )
585 IF ( i .EQ. m-p )
THEN
586 CALL clarfgp( m-p-i+1, x21(i,i), x21(i,i), ldx21,
589 CALL clarfgp( m-p-i+1, x21(i,i), x21(i,i+1), ldx21,
594 CALL clarf(
'R', q-i, p-i+1, x11(i,i), ldx11, taup1(i),
595 $ x11(i+1,i), ldx11, work )
596 CALL clarf(
'R', m-q-i+1, p-i+1, x11(i,i), ldx11, taup1(i),
597 $ x12(i,i), ldx12, work )
598 CALL clarf(
'R', q-i, m-p-i+1, x21(i,i), ldx21, taup2(i),
599 $ x21(i+1,i), ldx21, work )
600 CALL clarf(
'R', m-q-i+1, m-p-i+1, x21(i,i), ldx21,
601 $ taup2(i), x22(i,i), ldx22, work )
603 CALL clacgv( p-i+1, x11(i,i), ldx11 )
604 CALL clacgv( m-p-i+1, x21(i,i), ldx21 )
607 CALL cscal( q-i, cmplx( -z1*z3*sin(theta(i)), 0.0e0 ),
609 CALL caxpy( q-i, cmplx( z2*z3*cos(theta(i)), 0.0e0 ),
610 $ x21(i+1,i), 1, x11(i+1,i), 1 )
612 CALL cscal( m-q-i+1, cmplx( -z1*z4*sin(theta(i)), 0.0e0 ),
614 CALL caxpy( m-q-i+1, cmplx( z2*z4*cos(theta(i)), 0.0e0 ),
615 $ x22(i,i), 1, x12(i,i), 1 )
618 $ phi(i) = atan2( scnrm2( q-i, x11(i+1,i), 1 ),
619 $ scnrm2( m-q-i+1, x12(i,i), 1 ) )
622 CALL clarfgp( q-i, x11(i+1,i), x11(i+2,i), 1, tauq1(i) )
625 CALL clarfgp( m-q-i+1, x12(i,i), x12(i+1,i), 1, tauq2(i) )
629 CALL clarf(
'L', q-i, p-i, x11(i+1,i), 1,
630 $ conjg(tauq1(i)), x11(i+1,i+1), ldx11, work )
631 CALL clarf(
'L', q-i, m-p-i, x11(i+1,i), 1,
632 $ conjg(tauq1(i)), x21(i+1,i+1), ldx21, work )
634 CALL clarf(
'L', m-q-i+1, p-i, x12(i,i), 1, conjg(tauq2(i)),
635 $ x12(i,i+1), ldx12, work )
637 IF ( m-p .GT. i )
THEN
638 CALL clarf(
'L', m-q-i+1, m-p-i, x12(i,i), 1,
639 $ conjg(tauq2(i)), x22(i,i+1), ldx22, work )
647 CALL cscal( m-q-i+1, cmplx( -z1*z4, 0.0e0 ), x12(i,i), 1 )
648 CALL clarfgp( m-q-i+1, x12(i,i), x12(i+1,i), 1, tauq2(i) )
652 CALL clarf(
'L', m-q-i+1, p-i, x12(i,i), 1,
653 $ conjg(tauq2(i)), x12(i,i+1), ldx12, work )
656 $
CALL clarf(
'L', m-q-i+1, m-p-q, x12(i,i), 1,
657 $ conjg(tauq2(i)), x22(i,q+1), ldx22, work )
665 CALL cscal( m-p-q-i+1, cmplx( z2*z4, 0.0e0 ),
667 CALL clarfgp( m-p-q-i+1, x22(p+i,q+i), x22(p+i+1,q+i), 1,
670 IF ( m-p-q .NE. i )
THEN
671 CALL clarf(
'L', m-p-q-i+1, m-p-q-i, x22(p+i,q+i), 1,
672 $ conjg(tauq2(p+i)), x22(p+i,q+i+1), ldx22,
subroutine xerbla(srname, info)
subroutine caxpy(n, ca, cx, incx, cy, incy)
CAXPY
subroutine clacgv(n, x, incx)
CLACGV conjugates a complex vector.
subroutine clarf(side, m, n, v, incv, tau, c, ldc, work)
CLARF applies an elementary reflector to a general rectangular matrix.
subroutine clarfgp(n, alpha, x, incx, tau)
CLARFGP generates an elementary reflector (Householder matrix) with non-negative beta.
subroutine cscal(n, ca, cx, incx)
CSCAL
subroutine cunbdb(trans, signs, m, p, q, x11, ldx11, x12, ldx12, x21, ldx21, x22, ldx22, theta, phi, taup1, taup2, tauq1, tauq2, work, lwork, info)
CUNBDB