282 SUBROUTINE sorbdb( 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 REAL 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 EXTERNAL SNRM2, LSAME
324 INTRINSIC atan2, cos, max, sin
331 colmajor = .NOT. lsame( trans,
'T' )
332 IF( .NOT. lsame( signs,
'O' ) )
THEN
343 lquery = lwork .EQ. -1
347 ELSE IF( p .LT. 0 .OR. p .GT. m )
THEN
349 ELSE IF( q .LT. 0 .OR. q .GT. p .OR. q .GT. m-p .OR.
352 ELSE IF( colmajor .AND. ldx11 .LT. max( 1, p ) )
THEN
354 ELSE IF( .NOT.colmajor .AND. ldx11 .LT. max( 1, q ) )
THEN
356 ELSE IF( colmajor .AND. ldx12 .LT. max( 1, p ) )
THEN
358 ELSE IF( .NOT.colmajor .AND. ldx12 .LT. max( 1, m-q ) )
THEN
360 ELSE IF( colmajor .AND. ldx21 .LT. max( 1, m-p ) )
THEN
362 ELSE IF( .NOT.colmajor .AND. ldx21 .LT. max( 1, q ) )
THEN
364 ELSE IF( colmajor .AND. ldx22 .LT. max( 1, m-p ) )
THEN
366 ELSE IF( .NOT.colmajor .AND. ldx22 .LT. max( 1, m-q ) )
THEN
372 IF( info .EQ. 0 )
THEN
375 work(1) = real( lworkopt )
376 IF( lwork .LT. lworkmin .AND. .NOT. lquery )
THEN
380 IF( info .NE. 0 )
THEN
381 CALL xerbla(
'xORBDB', -info )
383 ELSE IF( lquery )
THEN
396 CALL sscal( p-i+1, z1, x11(i,i), 1 )
398 CALL sscal( p-i+1, z1*cos(phi(i-1)), x11(i,i), 1 )
399 CALL saxpy( p-i+1, -z1*z3*z4*sin(phi(i-1)), x12(i,
404 CALL sscal( m-p-i+1, z2, x21(i,i), 1 )
406 CALL sscal( m-p-i+1, z2*cos(phi(i-1)), x21(i,i), 1 )
407 CALL saxpy( m-p-i+1, -z2*z3*z4*sin(phi(i-1)), x22(i,
412 theta(i) = atan2( snrm2( m-p-i+1, x21(i,i), 1 ),
413 $ snrm2( p-i+1, x11(i,i), 1 ) )
416 CALL slarfgp( p-i+1, x11(i,i), x11(i+1,i), 1,
418 ELSE IF( p .EQ. i )
THEN
419 CALL slarfgp( p-i+1, x11(i,i), x11(i,i), 1, taup1(i) )
421 IF ( m-p .GT. i )
THEN
422 CALL slarfgp( m-p-i+1, x21(i,i), x21(i+1,i), 1,
424 ELSE IF ( m-p .EQ. i )
THEN
425 CALL slarfgp( m-p-i+1, x21(i,i), x21(i,i), 1,
430 CALL slarf1f(
'L', p-i+1, q-i, x11(i,i), 1, taup1(i),
431 $ x11(i,i+1), ldx11, work )
433 IF ( m-q+1 .GT. i )
THEN
434 CALL slarf1f(
'L', p-i+1, m-q-i+1, x11(i,i), 1,
435 $ taup1(i), x12(i,i), ldx12, work )
438 CALL slarf1f(
'L', m-p-i+1, q-i, x21(i,i), 1,
439 $ taup2(i), x21(i,i+1), ldx21, work )
441 IF ( m-q+1 .GT. i )
THEN
442 CALL slarf1f(
'L', m-p-i+1, m-q-i+1, x21(i,i), 1,
443 $ taup2(i), x22(i,i), ldx22, work )
447 CALL sscal( q-i, -z1*z3*sin(theta(i)), x11(i,i+1),
449 CALL saxpy( q-i, z2*z3*cos(theta(i)), x21(i,i+1),
451 $ x11(i,i+1), ldx11 )
453 CALL sscal( m-q-i+1, -z1*z4*sin(theta(i)), x12(i,i),
455 CALL saxpy( m-q-i+1, z2*z4*cos(theta(i)), x22(i,i),
460 $ phi(i) = atan2( snrm2( q-i, x11(i,i+1), ldx11 ),
461 $ snrm2( m-q-i+1, x12(i,i), ldx12 ) )
464 IF ( q-i .EQ. 1 )
THEN
465 CALL slarfgp( q-i, x11(i,i+1), x11(i,i+1), ldx11,
468 CALL slarfgp( q-i, x11(i,i+1), x11(i,i+2), ldx11,
472 IF ( q+i-1 .LT. m )
THEN
473 IF ( m-q .EQ. i )
THEN
474 CALL slarfgp( m-q-i+1, x12(i,i), x12(i,i), ldx12,
477 CALL slarfgp( m-q-i+1, x12(i,i), x12(i,i+1), ldx12,
483 CALL slarf1f(
'R', p-i, q-i, x11(i,i+1), ldx11,
484 $ tauq1(i), x11(i+1,i+1), ldx11, work )
485 CALL slarf1f(
'R', m-p-i, q-i, x11(i,i+1), ldx11,
486 $ tauq1(i), x21(i+1,i+1), ldx21, work )
489 CALL slarf1f(
'R', p-i, m-q-i+1, x12(i,i), ldx12,
490 $ tauq2(i), x12(i+1,i), ldx12, work )
492 IF ( m-p .GT. i )
THEN
493 CALL slarf1f(
'R', m-p-i, m-q-i+1, x12(i,i), ldx12,
494 $ tauq2(i), x22(i+1,i), ldx22, work )
503 CALL sscal( m-q-i+1, -z1*z4, x12(i,i), ldx12 )
504 IF ( i .GE. m-q )
THEN
505 CALL slarfgp( m-q-i+1, x12(i,i), x12(i,i), ldx12,
508 CALL slarfgp( m-q-i+1, x12(i,i), x12(i,i+1), ldx12,
513 CALL slarf1f(
'R', p-i, m-q-i+1, x12(i,i), ldx12,
514 $ tauq2(i), x12(i+1,i), ldx12, work )
517 $
CALL slarf1f(
'R', m-p-q, m-q-i+1, x12(i,i), ldx12,
518 $ tauq2(i), x22(q+1,i), ldx22, work )
526 CALL sscal( m-p-q-i+1, z2*z4, x22(q+i,p+i), ldx22 )
527 IF ( i .EQ. m-p-q )
THEN
528 CALL slarfgp( m-p-q-i+1, x22(q+i,p+i), x22(q+i,p+i),
529 $ ldx22, tauq2(p+i) )
531 CALL slarfgp( m-p-q-i+1, x22(q+i,p+i), x22(q+i,p+i+1),
532 $ ldx22, tauq2(p+i) )
534 IF ( i .LT. m-p-q )
THEN
535 CALL slarf1f(
'R', m-p-q-i, m-p-q-i+1, x22(q+i,p+i),
536 $ ldx22, tauq2(p+i), x22(q+i+1,p+i),
549 CALL sscal( p-i+1, z1, x11(i,i), ldx11 )
551 CALL sscal( p-i+1, z1*cos(phi(i-1)), x11(i,i), ldx11 )
552 CALL saxpy( p-i+1, -z1*z3*z4*sin(phi(i-1)), x12(i-1,
554 $ ldx12, x11(i,i), ldx11 )
557 CALL sscal( m-p-i+1, z2, x21(i,i), ldx21 )
559 CALL sscal( m-p-i+1, z2*cos(phi(i-1)), x21(i,i),
561 CALL saxpy( m-p-i+1, -z2*z3*z4*sin(phi(i-1)), x22(i-1,
563 $ ldx22, x21(i,i), ldx21 )
566 theta(i) = atan2( snrm2( m-p-i+1, x21(i,i), ldx21 ),
567 $ snrm2( p-i+1, x11(i,i), ldx11 ) )
569 CALL slarfgp( p-i+1, x11(i,i), x11(i,i+1), ldx11,
571 IF ( i .EQ. m-p )
THEN
572 CALL slarfgp( m-p-i+1, x21(i,i), x21(i,i), ldx21,
575 CALL slarfgp( m-p-i+1, x21(i,i), x21(i,i+1), ldx21,
580 CALL slarf1f(
'R', q-i, p-i+1, x11(i,i), ldx11,
581 $ taup1(i), x11(i+1,i), ldx11, work )
583 IF ( m-q+1 .GT. i )
THEN
584 CALL slarf1f(
'R', m-q-i+1, p-i+1, x11(i,i), ldx11,
585 $ taup1(i), x12(i,i), ldx12, work )
588 CALL slarf1f(
'R', q-i, m-p-i+1, x21(i,i), ldx21,
589 $ taup2(i), x21(i+1,i), ldx21, work )
591 IF ( m-q+1 .GT. i )
THEN
592 CALL slarf1f(
'R', m-q-i+1, m-p-i+1, x21(i,i), ldx21,
593 $ taup2(i), x22(i,i), ldx22, work )
597 CALL sscal( q-i, -z1*z3*sin(theta(i)), x11(i+1,i), 1 )
598 CALL saxpy( q-i, z2*z3*cos(theta(i)), x21(i+1,i), 1,
601 CALL sscal( m-q-i+1, -z1*z4*sin(theta(i)), x12(i,i), 1 )
602 CALL saxpy( m-q-i+1, z2*z4*cos(theta(i)), x22(i,i), 1,
606 $ phi(i) = atan2( snrm2( q-i, x11(i+1,i), 1 ),
607 $ snrm2( m-q-i+1, x12(i,i), 1 ) )
610 IF ( q-i .EQ. 1)
THEN
611 CALL slarfgp( q-i, x11(i+1,i), x11(i+1,i), 1,
614 CALL slarfgp( q-i, x11(i+1,i), x11(i+2,i), 1,
618 IF ( m-q .GT. i )
THEN
619 CALL slarfgp( m-q-i+1, x12(i,i), x12(i+1,i), 1,
622 CALL slarfgp( m-q-i+1, x12(i,i), x12(i,i), 1,
627 CALL slarf1f(
'L', q-i, p-i, x11(i+1,i), 1, tauq1(i),
628 $ x11(i+1,i+1), ldx11, work )
629 CALL slarf1f(
'L', q-i, m-p-i, x11(i+1,i), 1,
630 $ tauq1(i), x21(i+1,i+1), ldx21, work )
632 CALL slarf1f(
'L', m-q-i+1, p-i, x12(i,i), 1, tauq2(i),
633 $ x12(i,i+1), ldx12, work )
634 IF ( m-p-i .GT. 0 )
THEN
635 CALL slarf1f(
'L', m-q-i+1, m-p-i, x12(i,i), 1,
636 $ tauq2(i), x22(i,i+1), ldx22, work )
645 CALL sscal( m-q-i+1, -z1*z4, x12(i,i), 1 )
646 CALL slarfgp( m-q-i+1, x12(i,i), x12(i+1,i), 1,
650 CALL slarf1f(
'L', m-q-i+1, p-i, x12(i,i), 1,
651 $ tauq2(i), x12(i,i+1), ldx12, work )
654 $
CALL slarf1f(
'L', m-q-i+1, m-p-q, x12(i,i), 1,
655 $ tauq2(i), x22(i,q+1), ldx22, work )
663 CALL sscal( m-p-q-i+1, z2*z4, x22(p+i,q+i), 1 )
664 IF ( m-p-q .EQ. i )
THEN
665 CALL slarfgp( m-p-q-i+1, x22(p+i,q+i), x22(p+i,q+i),
669 CALL slarfgp( m-p-q-i+1, x22(p+i,q+i), x22(p+i+1,q+i),
672 CALL slarf1f(
'L', m-p-q-i+1, m-p-q-i, x22(p+i,q+i),
673 $ 1, tauq2(p+i), x22(p+i,q+i+1), ldx22,