210 SUBROUTINE cunbdb4( M, P, Q, X11, LDX11, X21, LDX21, THETA, PHI,
211 $ TAUP1, TAUP2, TAUQ1, PHANTOM, WORK, LWORK,
219 INTEGER INFO, LWORK, M, P, Q, LDX11, LDX21
222 REAL PHI(*), THETA(*)
223 COMPLEX PHANTOM(*), TAUP1(*), TAUP2(*), TAUQ1(*),
224 $ work(*), x11(ldx11,*), x21(ldx21,*)
230 COMPLEX NEGONE, ONE, ZERO
231 PARAMETER ( NEGONE = (-1.0e0,0.0e0), one = (1.0e0,0.0e0),
232 $ zero = (0.0e0,0.0e0) )
236 INTEGER CHILDINFO, I, ILARF, IORBDB5, J, LLARF,
237 $ lorbdb5, lworkmin, lworkopt
245 REAL SCNRM2, SROUNDUP_LWORK
246 EXTERNAL SCNRM2, SROUNDUP_LWORK
249 INTRINSIC atan2, cos, max, sin, sqrt
256 lquery = lwork .EQ. -1
260 ELSE IF( p .LT. m-q .OR. m-p .LT. m-q )
THEN
262 ELSE IF( q .LT. m-q .OR. q .GT. m )
THEN
264 ELSE IF( ldx11 .LT. max( 1, p ) )
THEN
266 ELSE IF( ldx21 .LT. max( 1, m-p ) )
THEN
272 IF( info .EQ. 0 )
THEN
274 llarf = max( q-1, p-1, m-p-1 )
277 lworkopt = ilarf + llarf - 1
278 lworkopt = max( lworkopt, iorbdb5 + lorbdb5 - 1 )
280 work(1) = sroundup_lwork(lworkopt)
281 IF( lwork .LT. lworkmin .AND. .NOT.lquery )
THEN
285 IF( info .NE. 0 )
THEN
286 CALL xerbla(
'CUNBDB4', -info )
288 ELSE IF( lquery )
THEN
300 CALL cunbdb5( p, m-p, q, phantom(1), 1, phantom(p+1), 1,
301 $ x11, ldx11, x21, ldx21, work(iorbdb5),
302 $ lorbdb5, childinfo )
303 CALL cscal( p, negone, phantom(1), 1 )
304 CALL clarfgp( p, phantom(1), phantom(2), 1, taup1(1) )
305 CALL clarfgp( m-p, phantom(p+1), phantom(p+2), 1, taup2(1) )
306 theta(i) = atan2( real( phantom(1) ), real( phantom(p+1) ) )
311 CALL clarf(
'L', p, q, phantom(1), 1, conjg(taup1(1)), x11,
312 $ ldx11, work(ilarf) )
313 CALL clarf(
'L', m-p, q, phantom(p+1), 1, conjg(taup2(1)),
314 $ x21, ldx21, work(ilarf) )
316 CALL cunbdb5( p-i+1, m-p-i+1, q-i+1, x11(i,i-1), 1,
317 $ x21(i,i-1), 1, x11(i,i), ldx11, x21(i,i),
318 $ ldx21, work(iorbdb5), lorbdb5, childinfo )
319 CALL cscal( p-i+1, negone, x11(i,i-1), 1 )
320 CALL clarfgp( p-i+1, x11(i,i-1), x11(i+1,i-1), 1, taup1(i) )
321 CALL clarfgp( m-p-i+1, x21(i,i-1), x21(i+1,i-1), 1,
323 theta(i) = atan2( real( x11(i,i-1) ), real( x21(i,i-1) ) )
328 CALL clarf(
'L', p-i+1, q-i+1, x11(i,i-1), 1,
329 $ conjg(taup1(i)), x11(i,i), ldx11, work(ilarf) )
330 CALL clarf(
'L', m-p-i+1, q-i+1, x21(i,i-1), 1,
331 $ conjg(taup2(i)), x21(i,i), ldx21, work(ilarf) )
334 CALL csrot( q-i+1, x11(i,i), ldx11, x21(i,i), ldx21, s, -c )
335 CALL clacgv( q-i+1, x21(i,i), ldx21 )
336 CALL clarfgp( q-i+1, x21(i,i), x21(i,i+1), ldx21, tauq1(i) )
339 CALL clarf(
'R', p-i, q-i+1, x21(i,i), ldx21, tauq1(i),
340 $ x11(i+1,i), ldx11, work(ilarf) )
341 CALL clarf(
'R', m-p-i, q-i+1, x21(i,i), ldx21, tauq1(i),
342 $ x21(i+1,i), ldx21, work(ilarf) )
343 CALL clacgv( q-i+1, x21(i,i), ldx21 )
344 IF( i .LT. m-q )
THEN
345 s = sqrt( scnrm2( p-i, x11(i+1,i), 1 )**2
346 $ + scnrm2( m-p-i, x21(i+1,i), 1 )**2 )
347 phi(i) = atan2( s, c )
355 CALL clacgv( q-i+1, x11(i,i), ldx11 )
356 CALL clarfgp( q-i+1, x11(i,i), x11(i,i+1), ldx11, tauq1(i) )
358 CALL clarf(
'R', p-i, q-i+1, x11(i,i), ldx11, tauq1(i),
359 $ x11(i+1,i), ldx11, work(ilarf) )
360 CALL clarf(
'R', q-p, q-i+1, x11(i,i), ldx11, tauq1(i),
361 $ x21(m-q+1,i), ldx21, work(ilarf) )
362 CALL clacgv( q-i+1, x11(i,i), ldx11 )
368 CALL clacgv( q-i+1, x21(m-q+i-p,i), ldx21 )
369 CALL clarfgp( q-i+1, x21(m-q+i-p,i), x21(m-q+i-p,i+1), ldx21,
372 CALL clarf(
'R', q-i, q-i+1, x21(m-q+i-p,i), ldx21, tauq1(i),
373 $ x21(m-q+i-p+1,i), ldx21, work(ilarf) )
374 CALL clacgv( q-i+1, x21(m-q+i-p,i), ldx21 )
subroutine xerbla(srname, info)
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 csrot(n, cx, incx, cy, incy, c, s)
CSROT
subroutine cscal(n, ca, cx, incx)
CSCAL
subroutine cunbdb4(m, p, q, x11, ldx11, x21, ldx21, theta, phi, taup1, taup2, tauq1, phantom, work, lwork, info)
CUNBDB4
subroutine cunbdb5(m1, m2, n, x1, incx1, x2, incx2, q1, ldq1, q2, ldq2, work, lwork, info)
CUNBDB5