208 SUBROUTINE dorbdb4( M, P, Q, X11, LDX11, X21, LDX21, THETA,
210 $ TAUP1, TAUP2, TAUQ1, PHANTOM, WORK, LWORK,
218 INTEGER INFO, LWORK, M, P, Q, LDX11, LDX21
221 DOUBLE PRECISION PHI(*), THETA(*)
222 DOUBLE PRECISION PHANTOM(*), TAUP1(*), TAUP2(*), TAUQ1(*),
223 $ WORK(*), X11(LDX11,*), X21(LDX21,*)
229 DOUBLE PRECISION NEGONE, ONE, ZERO
230 PARAMETER ( NEGONE = -1.0d0, one = 1.0d0, zero = 0.0d0 )
233 DOUBLE PRECISION C, S
234 INTEGER CHILDINFO, I, ILARF, IORBDB5, J, LLARF,
235 $ LORBDB5, LWORKMIN, LWORKOPT
243 DOUBLE PRECISION DNRM2
247 INTRINSIC atan2, cos, max, sin, sqrt
254 lquery = lwork .EQ. -1
258 ELSE IF( p .LT. m-q .OR. m-p .LT. m-q )
THEN
260 ELSE IF( q .LT. m-q .OR. q .GT. m )
THEN
262 ELSE IF( ldx11 .LT. max( 1, p ) )
THEN
264 ELSE IF( ldx21 .LT. max( 1, m-p ) )
THEN
270 IF( info .EQ. 0 )
THEN
272 llarf = max( q-1, p-1, m-p-1 )
275 lworkopt = ilarf + llarf - 1
276 lworkopt = max( lworkopt, iorbdb5 + lorbdb5 - 1 )
279 IF( lwork .LT. lworkmin .AND. .NOT.lquery )
THEN
283 IF( info .NE. 0 )
THEN
284 CALL xerbla(
'DORBDB4', -info )
286 ELSE IF( lquery )
THEN
298 CALL dorbdb5( p, m-p, q, phantom(1), 1, phantom(p+1), 1,
299 $ x11, ldx11, x21, ldx21, work(iorbdb5),
300 $ lorbdb5, childinfo )
301 CALL dscal( p, negone, phantom(1), 1 )
302 CALL dlarfgp( p, phantom(1), phantom(2), 1, taup1(1) )
303 CALL dlarfgp( m-p, phantom(p+1), phantom(p+2), 1,
305 theta(i) = atan2( phantom(1), phantom(p+1) )
308 CALL dlarf1f(
'L', p, q, phantom(1), 1, taup1(1), x11,
309 $ ldx11, work(ilarf) )
310 CALL dlarf1f(
'L', m-p, q, phantom(p+1), 1, taup2(1),
311 $ x21, ldx21, work(ilarf) )
313 CALL dorbdb5( p-i+1, m-p-i+1, q-i+1, x11(i,i-1), 1,
314 $ x21(i,i-1), 1, x11(i,i), ldx11, x21(i,i),
315 $ ldx21, work(iorbdb5), lorbdb5, childinfo )
316 CALL dscal( p-i+1, negone, x11(i,i-1), 1 )
317 CALL dlarfgp( p-i+1, x11(i,i-1), x11(i+1,i-1), 1,
319 CALL dlarfgp( m-p-i+1, x21(i,i-1), x21(i+1,i-1), 1,
321 theta(i) = atan2( x11(i,i-1), x21(i,i-1) )
324 CALL dlarf1f(
'L', p-i+1, q-i+1, x11(i,i-1), 1, taup1(i),
325 $ x11(i,i), ldx11, work(ilarf) )
326 CALL dlarf1f(
'L', m-p-i+1, q-i+1, x21(i,i-1), 1,
327 $ taup2(i), x21(i,i), ldx21, work(ilarf) )
330 CALL drot( q-i+1, x11(i,i), ldx11, x21(i,i), ldx21, s, -c )
331 CALL dlarfgp( q-i+1, x21(i,i), x21(i,i+1), ldx21, tauq1(i) )
333 CALL dlarf1f(
'R', p-i, q-i+1, x21(i,i), ldx21, tauq1(i),
334 $ x11(i+1,i), ldx11, work(ilarf) )
335 CALL dlarf1f(
'R', m-p-i, q-i+1, x21(i,i), ldx21, tauq1(i),
336 $ x21(i+1,i), ldx21, work(ilarf) )
337 IF( i .LT. m-q )
THEN
338 s = sqrt( dnrm2( p-i, x11(i+1,i), 1 )**2
339 $ + dnrm2( m-p-i, x21(i+1,i), 1 )**2 )
340 phi(i) = atan2( s, c )
348 CALL dlarfgp( q-i+1, x11(i,i), x11(i,i+1), ldx11, tauq1(i) )
349 CALL dlarf1f(
'R', p-i, q-i+1, x11(i,i), ldx11, tauq1(i),
350 $ x11(i+1,i), ldx11, work(ilarf) )
351 CALL dlarf1f(
'R', q-p, q-i+1, x11(i,i), ldx11, tauq1(i),
352 $ x21(m-q+1,i), ldx21, work(ilarf) )
358 CALL dlarfgp( q-i+1, x21(m-q+i-p,i), x21(m-q+i-p,i+1),
361 CALL dlarf1f(
'R', q-i, q-i+1, x21(m-q+i-p,i), ldx21,
363 $ x21(m-q+i-p+1,i), ldx21, work(ilarf) )