1 *> \brief \b STGSY2 solves the generalized Sylvester equation (unblocked algorithm).
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download STGSY2 + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/stgsy2.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/stgsy2.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/stgsy2.f">
21 * SUBROUTINE STGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
22 * LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
25 * .. Scalar Arguments ..
27 * INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N,
29 * REAL RDSCAL, RDSUM, SCALE
31 * .. Array Arguments ..
33 * REAL A( LDA, * ), B( LDB, * ), C( LDC, * ),
34 * $ D( LDD, * ), E( LDE, * ), F( LDF, * )
43 *> STGSY2 solves the generalized Sylvester equation:
45 *> A * R - L * B = scale * C (1)
46 *> D * R - L * E = scale * F,
48 *> using Level 1 and 2 BLAS. where R and L are unknown M-by-N matrices,
49 *> (A, D), (B, E) and (C, F) are given matrix pairs of size M-by-M,
50 *> N-by-N and M-by-N, respectively, with real entries. (A, D) and (B, E)
51 *> must be in generalized Schur canonical form, i.e. A, B are upper
52 *> quasi triangular and D, E are upper triangular. The solution (R, L)
53 *> overwrites (C, F). 0 <= SCALE <= 1 is an output scaling factor
54 *> chosen to avoid overflow.
56 *> In matrix notation solving equation (1) corresponds to solve
57 *> Z*x = scale*b, where Z is defined as
59 *> Z = [ kron(In, A) -kron(B**T, Im) ] (2)
60 *> [ kron(In, D) -kron(E**T, Im) ],
62 *> Ik is the identity matrix of size k and X**T is the transpose of X.
63 *> kron(X, Y) is the Kronecker product between the matrices X and Y.
64 *> In the process of solving (1), we solve a number of such systems
65 *> where Dim(In), Dim(In) = 1 or 2.
67 *> If TRANS = 'T', solve the transposed system Z**T*y = scale*b for y,
68 *> which is equivalent to solve for R and L in
70 *> A**T * R + D**T * L = scale * C (3)
71 *> R * B**T + L * E**T = scale * -F
73 *> This case is used to compute an estimate of Dif[(A, D), (B, E)] =
74 *> sigma_min(Z) using reverse communicaton with SLACON.
76 *> STGSY2 also (IJOB >= 1) contributes to the computation in STGSYL
77 *> of an upper bound on the separation between to matrix pairs. Then
78 *> the input (A, D), (B, E) are sub-pencils of the matrix pair in
79 *> STGSYL. See STGSYL for details.
87 *> TRANS is CHARACTER*1
88 *> = 'N', solve the generalized Sylvester equation (1).
89 *> = 'T': solve the 'transposed' system (3).
95 *> Specifies what kind of functionality to be performed.
96 *> = 0: solve (1) only.
97 *> = 1: A contribution from this subsystem to a Frobenius
98 *> norm-based estimate of the separation between two matrix
99 *> pairs is computed. (look ahead strategy is used).
100 *> = 2: A contribution from this subsystem to a Frobenius
101 *> norm-based estimate of the separation between two matrix
102 *> pairs is computed. (SGECON on sub-systems is used.)
103 *> Not referenced if TRANS = 'T'.
109 *> On entry, M specifies the order of A and D, and the row
110 *> dimension of C, F, R and L.
116 *> On entry, N specifies the order of B and E, and the column
117 *> dimension of C, F, R and L.
122 *> A is REAL array, dimension (LDA, M)
123 *> On entry, A contains an upper quasi triangular matrix.
129 *> The leading dimension of the matrix A. LDA >= max(1, M).
134 *> B is REAL array, dimension (LDB, N)
135 *> On entry, B contains an upper quasi triangular matrix.
141 *> The leading dimension of the matrix B. LDB >= max(1, N).
146 *> C is REAL array, dimension (LDC, N)
147 *> On entry, C contains the right-hand-side of the first matrix
149 *> On exit, if IJOB = 0, C has been overwritten by the
156 *> The leading dimension of the matrix C. LDC >= max(1, M).
161 *> D is REAL array, dimension (LDD, M)
162 *> On entry, D contains an upper triangular matrix.
168 *> The leading dimension of the matrix D. LDD >= max(1, M).
173 *> E is REAL array, dimension (LDE, N)
174 *> On entry, E contains an upper triangular matrix.
180 *> The leading dimension of the matrix E. LDE >= max(1, N).
185 *> F is REAL array, dimension (LDF, N)
186 *> On entry, F contains the right-hand-side of the second matrix
188 *> On exit, if IJOB = 0, F has been overwritten by the
195 *> The leading dimension of the matrix F. LDF >= max(1, M).
201 *> On exit, 0 <= SCALE <= 1. If 0 < SCALE < 1, the solutions
202 *> R and L (C and F on entry) will hold the solutions to a
203 *> slightly perturbed system but the input matrices A, B, D and
204 *> E have not been changed. If SCALE = 0, R and L will hold the
205 *> solutions to the homogeneous system with C = F = 0. Normally,
209 *> \param[in,out] RDSUM
212 *> On entry, the sum of squares of computed contributions to
213 *> the Dif-estimate under computation by STGSYL, where the
214 *> scaling factor RDSCAL (see below) has been factored out.
215 *> On exit, the corresponding sum of squares updated with the
216 *> contributions from the current sub-system.
217 *> If TRANS = 'T' RDSUM is not touched.
218 *> NOTE: RDSUM only makes sense when STGSY2 is called by STGSYL.
221 *> \param[in,out] RDSCAL
224 *> On entry, scaling factor used to prevent overflow in RDSUM.
225 *> On exit, RDSCAL is updated w.r.t. the current contributions
227 *> If TRANS = 'T', RDSCAL is not touched.
228 *> NOTE: RDSCAL only makes sense when STGSY2 is called by
234 *> IWORK is INTEGER array, dimension (M+N+2)
240 *> On exit, the number of subsystems (of size 2-by-2, 4-by-4 and
241 *> 8-by-8) solved by this routine.
247 *> On exit, if INFO is set to
248 *> =0: Successful exit
249 *> <0: If INFO = -i, the i-th argument had an illegal value.
250 *> >0: The matrix pairs (A, D) and (B, E) have common or very
251 *> close eigenvalues.
257 *> \author Univ. of Tennessee
258 *> \author Univ. of California Berkeley
259 *> \author Univ. of Colorado Denver
262 *> \date November 2015
264 *> \ingroup realSYauxiliary
266 *> \par Contributors:
269 *> Bo Kagstrom and Peter Poromaa, Department of Computing Science,
270 *> Umea University, S-901 87 Umea, Sweden.
272 * =====================================================================
273 SUBROUTINE STGSY2( TRANS, IJOB, M, N, A, LDA, B, LDB, C, LDC, D,
274 $ LDD, E, LDE, F, LDF, SCALE, RDSUM, RDSCAL,
277 * -- LAPACK auxiliary routine (version 3.6.0) --
278 * -- LAPACK is a software package provided by Univ. of Tennessee, --
279 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
282 * .. Scalar Arguments ..
284 INTEGER IJOB, INFO, LDA, LDB, LDC, LDD, LDE, LDF, M, N,
286 REAL RDSCAL, RDSUM, SCALE
288 * .. Array Arguments ..
290 REAL A( LDA, * ), B( LDB, * ), C( LDC, * ),
291 $ D( LDD, * ), E( LDE, * ), F( LDF, * )
294 * =====================================================================
295 * Replaced various illegal calls to SCOPY by calls to SLASET.
296 * Sven Hammarling, 27/5/02.
300 PARAMETER ( LDZ = 8 )
302 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
304 * .. Local Scalars ..
306 INTEGER I, IE, IERR, II, IS, ISP1, J, JE, JJ, JS, JSP1,
307 $ K, MB, NB, P, Q, ZDIM
311 INTEGER IPIV( LDZ ), JPIV( LDZ )
312 REAL RHS( LDZ ), Z( LDZ, LDZ )
314 * .. External Functions ..
318 * .. External Subroutines ..
319 EXTERNAL SAXPY, SCOPY, SGEMM, SGEMV, SGER, SGESC2,
320 $ SGETC2, SSCAL, SLASET, SLATDF, XERBLA
322 * .. Intrinsic Functions ..
325 * .. Executable Statements ..
327 * Decode and test input parameters
331 NOTRAN = LSAME( TRANS, 'N' )
332 IF( .NOT.NOTRAN .AND. .NOT.LSAME( TRANS, 'T' ) ) THEN
334 ELSE IF( NOTRAN ) THEN
335 IF( ( IJOB.LT.0 ) .OR. ( IJOB.GT.2 ) ) THEN
342 ELSE IF( N.LE.0 ) THEN
344 ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
346 ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
348 ELSE IF( LDC.LT.MAX( 1, M ) ) THEN
350 ELSE IF( LDD.LT.MAX( 1, M ) ) THEN
352 ELSE IF( LDE.LT.MAX( 1, N ) ) THEN
354 ELSE IF( LDF.LT.MAX( 1, M ) ) THEN
359 CALL XERBLA( 'STGSY2', -INFO )
363 * Determine block structure of A
375 IF( A( I+1, I ).NE.ZERO ) THEN
384 * Determine block structure of B
395 IF( B( J+1, J ).NE.ZERO ) THEN
407 * Solve (I, J) - subsystem
408 * A(I, I) * R(I, J) - L(I, J) * B(J, J) = C(I, J)
409 * D(I, I) * R(I, J) - L(I, J) * E(J, J) = F(I, J)
410 * for I = P, P - 1, ..., 1; J = 1, 2, ..., Q
417 JE = IWORK( J+1 ) - 1
423 IE = IWORK( I+1 ) - 1
427 IF( ( MB.EQ.1 ) .AND. ( NB.EQ.1 ) ) THEN
429 * Build a 2-by-2 system Z * x = RHS
431 Z( 1, 1 ) = A( IS, IS )
432 Z( 2, 1 ) = D( IS, IS )
433 Z( 1, 2 ) = -B( JS, JS )
434 Z( 2, 2 ) = -E( JS, JS )
436 * Set up right hand side(s)
438 RHS( 1 ) = C( IS, JS )
439 RHS( 2 ) = F( IS, JS )
443 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
448 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV,
450 IF( SCALOC.NE.ONE ) THEN
452 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
453 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
458 CALL SLATDF( IJOB, ZDIM, Z, LDZ, RHS, RDSUM,
459 $ RDSCAL, IPIV, JPIV )
462 * Unpack solution vector(s)
464 C( IS, JS ) = RHS( 1 )
465 F( IS, JS ) = RHS( 2 )
467 * Substitute R(I, J) and L(I, J) into remaining
472 CALL SAXPY( IS-1, ALPHA, A( 1, IS ), 1, C( 1, JS ),
474 CALL SAXPY( IS-1, ALPHA, D( 1, IS ), 1, F( 1, JS ),
478 CALL SAXPY( N-JE, RHS( 2 ), B( JS, JE+1 ), LDB,
479 $ C( IS, JE+1 ), LDC )
480 CALL SAXPY( N-JE, RHS( 2 ), E( JS, JE+1 ), LDE,
481 $ F( IS, JE+1 ), LDF )
484 ELSE IF( ( MB.EQ.1 ) .AND. ( NB.EQ.2 ) ) THEN
486 * Build a 4-by-4 system Z * x = RHS
488 Z( 1, 1 ) = A( IS, IS )
490 Z( 3, 1 ) = D( IS, IS )
494 Z( 2, 2 ) = A( IS, IS )
496 Z( 4, 2 ) = D( IS, IS )
498 Z( 1, 3 ) = -B( JS, JS )
499 Z( 2, 3 ) = -B( JS, JSP1 )
500 Z( 3, 3 ) = -E( JS, JS )
501 Z( 4, 3 ) = -E( JS, JSP1 )
503 Z( 1, 4 ) = -B( JSP1, JS )
504 Z( 2, 4 ) = -B( JSP1, JSP1 )
506 Z( 4, 4 ) = -E( JSP1, JSP1 )
508 * Set up right hand side(s)
510 RHS( 1 ) = C( IS, JS )
511 RHS( 2 ) = C( IS, JSP1 )
512 RHS( 3 ) = F( IS, JS )
513 RHS( 4 ) = F( IS, JSP1 )
517 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
522 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV,
524 IF( SCALOC.NE.ONE ) THEN
526 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
527 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
532 CALL SLATDF( IJOB, ZDIM, Z, LDZ, RHS, RDSUM,
533 $ RDSCAL, IPIV, JPIV )
536 * Unpack solution vector(s)
538 C( IS, JS ) = RHS( 1 )
539 C( IS, JSP1 ) = RHS( 2 )
540 F( IS, JS ) = RHS( 3 )
541 F( IS, JSP1 ) = RHS( 4 )
543 * Substitute R(I, J) and L(I, J) into remaining
547 CALL SGER( IS-1, NB, -ONE, A( 1, IS ), 1, RHS( 1 ),
548 $ 1, C( 1, JS ), LDC )
549 CALL SGER( IS-1, NB, -ONE, D( 1, IS ), 1, RHS( 1 ),
550 $ 1, F( 1, JS ), LDF )
553 CALL SAXPY( N-JE, RHS( 3 ), B( JS, JE+1 ), LDB,
554 $ C( IS, JE+1 ), LDC )
555 CALL SAXPY( N-JE, RHS( 3 ), E( JS, JE+1 ), LDE,
556 $ F( IS, JE+1 ), LDF )
557 CALL SAXPY( N-JE, RHS( 4 ), B( JSP1, JE+1 ), LDB,
558 $ C( IS, JE+1 ), LDC )
559 CALL SAXPY( N-JE, RHS( 4 ), E( JSP1, JE+1 ), LDE,
560 $ F( IS, JE+1 ), LDF )
563 ELSE IF( ( MB.EQ.2 ) .AND. ( NB.EQ.1 ) ) THEN
565 * Build a 4-by-4 system Z * x = RHS
567 Z( 1, 1 ) = A( IS, IS )
568 Z( 2, 1 ) = A( ISP1, IS )
569 Z( 3, 1 ) = D( IS, IS )
572 Z( 1, 2 ) = A( IS, ISP1 )
573 Z( 2, 2 ) = A( ISP1, ISP1 )
574 Z( 3, 2 ) = D( IS, ISP1 )
575 Z( 4, 2 ) = D( ISP1, ISP1 )
577 Z( 1, 3 ) = -B( JS, JS )
579 Z( 3, 3 ) = -E( JS, JS )
583 Z( 2, 4 ) = -B( JS, JS )
585 Z( 4, 4 ) = -E( JS, JS )
587 * Set up right hand side(s)
589 RHS( 1 ) = C( IS, JS )
590 RHS( 2 ) = C( ISP1, JS )
591 RHS( 3 ) = F( IS, JS )
592 RHS( 4 ) = F( ISP1, JS )
596 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
600 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV,
602 IF( SCALOC.NE.ONE ) THEN
604 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
605 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
610 CALL SLATDF( IJOB, ZDIM, Z, LDZ, RHS, RDSUM,
611 $ RDSCAL, IPIV, JPIV )
614 * Unpack solution vector(s)
616 C( IS, JS ) = RHS( 1 )
617 C( ISP1, JS ) = RHS( 2 )
618 F( IS, JS ) = RHS( 3 )
619 F( ISP1, JS ) = RHS( 4 )
621 * Substitute R(I, J) and L(I, J) into remaining
625 CALL SGEMV( 'N', IS-1, MB, -ONE, A( 1, IS ), LDA,
626 $ RHS( 1 ), 1, ONE, C( 1, JS ), 1 )
627 CALL SGEMV( 'N', IS-1, MB, -ONE, D( 1, IS ), LDD,
628 $ RHS( 1 ), 1, ONE, F( 1, JS ), 1 )
631 CALL SGER( MB, N-JE, ONE, RHS( 3 ), 1,
632 $ B( JS, JE+1 ), LDB, C( IS, JE+1 ), LDC )
633 CALL SGER( MB, N-JE, ONE, RHS( 3 ), 1,
634 $ E( JS, JE+1 ), LDE, F( IS, JE+1 ), LDF )
637 ELSE IF( ( MB.EQ.2 ) .AND. ( NB.EQ.2 ) ) THEN
639 * Build an 8-by-8 system Z * x = RHS
641 CALL SLASET( 'F', LDZ, LDZ, ZERO, ZERO, Z, LDZ )
643 Z( 1, 1 ) = A( IS, IS )
644 Z( 2, 1 ) = A( ISP1, IS )
645 Z( 5, 1 ) = D( IS, IS )
647 Z( 1, 2 ) = A( IS, ISP1 )
648 Z( 2, 2 ) = A( ISP1, ISP1 )
649 Z( 5, 2 ) = D( IS, ISP1 )
650 Z( 6, 2 ) = D( ISP1, ISP1 )
652 Z( 3, 3 ) = A( IS, IS )
653 Z( 4, 3 ) = A( ISP1, IS )
654 Z( 7, 3 ) = D( IS, IS )
656 Z( 3, 4 ) = A( IS, ISP1 )
657 Z( 4, 4 ) = A( ISP1, ISP1 )
658 Z( 7, 4 ) = D( IS, ISP1 )
659 Z( 8, 4 ) = D( ISP1, ISP1 )
661 Z( 1, 5 ) = -B( JS, JS )
662 Z( 3, 5 ) = -B( JS, JSP1 )
663 Z( 5, 5 ) = -E( JS, JS )
664 Z( 7, 5 ) = -E( JS, JSP1 )
666 Z( 2, 6 ) = -B( JS, JS )
667 Z( 4, 6 ) = -B( JS, JSP1 )
668 Z( 6, 6 ) = -E( JS, JS )
669 Z( 8, 6 ) = -E( JS, JSP1 )
671 Z( 1, 7 ) = -B( JSP1, JS )
672 Z( 3, 7 ) = -B( JSP1, JSP1 )
673 Z( 7, 7 ) = -E( JSP1, JSP1 )
675 Z( 2, 8 ) = -B( JSP1, JS )
676 Z( 4, 8 ) = -B( JSP1, JSP1 )
677 Z( 8, 8 ) = -E( JSP1, JSP1 )
679 * Set up right hand side(s)
684 CALL SCOPY( MB, C( IS, JS+JJ ), 1, RHS( K ), 1 )
685 CALL SCOPY( MB, F( IS, JS+JJ ), 1, RHS( II ), 1 )
692 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
696 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV,
698 IF( SCALOC.NE.ONE ) THEN
700 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
701 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
706 CALL SLATDF( IJOB, ZDIM, Z, LDZ, RHS, RDSUM,
707 $ RDSCAL, IPIV, JPIV )
710 * Unpack solution vector(s)
714 DO 100 JJ = 0, NB - 1
715 CALL SCOPY( MB, RHS( K ), 1, C( IS, JS+JJ ), 1 )
716 CALL SCOPY( MB, RHS( II ), 1, F( IS, JS+JJ ), 1 )
721 * Substitute R(I, J) and L(I, J) into remaining
725 CALL SGEMM( 'N', 'N', IS-1, NB, MB, -ONE,
726 $ A( 1, IS ), LDA, RHS( 1 ), MB, ONE,
728 CALL SGEMM( 'N', 'N', IS-1, NB, MB, -ONE,
729 $ D( 1, IS ), LDD, RHS( 1 ), MB, ONE,
734 CALL SGEMM( 'N', 'N', MB, N-JE, NB, ONE, RHS( K ),
735 $ MB, B( JS, JE+1 ), LDB, ONE,
736 $ C( IS, JE+1 ), LDC )
737 CALL SGEMM( 'N', 'N', MB, N-JE, NB, ONE, RHS( K ),
738 $ MB, E( JS, JE+1 ), LDE, ONE,
739 $ F( IS, JE+1 ), LDF )
748 * Solve (I, J) - subsystem
749 * A(I, I)**T * R(I, J) + D(I, I)**T * L(J, J) = C(I, J)
750 * R(I, I) * B(J, J) + L(I, J) * E(J, J) = -F(I, J)
751 * for I = 1, 2, ..., P, J = Q, Q - 1, ..., 1
759 IE = IWORK( I+1 ) - 1
761 DO 190 J = Q, P + 2, -1
765 JE = IWORK( J+1 ) - 1
768 IF( ( MB.EQ.1 ) .AND. ( NB.EQ.1 ) ) THEN
770 * Build a 2-by-2 system Z**T * x = RHS
772 Z( 1, 1 ) = A( IS, IS )
773 Z( 2, 1 ) = -B( JS, JS )
774 Z( 1, 2 ) = D( IS, IS )
775 Z( 2, 2 ) = -E( JS, JS )
777 * Set up right hand side(s)
779 RHS( 1 ) = C( IS, JS )
780 RHS( 2 ) = F( IS, JS )
782 * Solve Z**T * x = RHS
784 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
788 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV, SCALOC )
789 IF( SCALOC.NE.ONE ) THEN
791 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
792 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
797 * Unpack solution vector(s)
799 C( IS, JS ) = RHS( 1 )
800 F( IS, JS ) = RHS( 2 )
802 * Substitute R(I, J) and L(I, J) into remaining
807 CALL SAXPY( JS-1, ALPHA, B( 1, JS ), 1, F( IS, 1 ),
810 CALL SAXPY( JS-1, ALPHA, E( 1, JS ), 1, F( IS, 1 ),
815 CALL SAXPY( M-IE, ALPHA, A( IS, IE+1 ), LDA,
818 CALL SAXPY( M-IE, ALPHA, D( IS, IE+1 ), LDD,
822 ELSE IF( ( MB.EQ.1 ) .AND. ( NB.EQ.2 ) ) THEN
824 * Build a 4-by-4 system Z**T * x = RHS
826 Z( 1, 1 ) = A( IS, IS )
828 Z( 3, 1 ) = -B( JS, JS )
829 Z( 4, 1 ) = -B( JSP1, JS )
832 Z( 2, 2 ) = A( IS, IS )
833 Z( 3, 2 ) = -B( JS, JSP1 )
834 Z( 4, 2 ) = -B( JSP1, JSP1 )
836 Z( 1, 3 ) = D( IS, IS )
838 Z( 3, 3 ) = -E( JS, JS )
842 Z( 2, 4 ) = D( IS, IS )
843 Z( 3, 4 ) = -E( JS, JSP1 )
844 Z( 4, 4 ) = -E( JSP1, JSP1 )
846 * Set up right hand side(s)
848 RHS( 1 ) = C( IS, JS )
849 RHS( 2 ) = C( IS, JSP1 )
850 RHS( 3 ) = F( IS, JS )
851 RHS( 4 ) = F( IS, JSP1 )
853 * Solve Z**T * x = RHS
855 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
858 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV, SCALOC )
859 IF( SCALOC.NE.ONE ) THEN
861 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
862 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
867 * Unpack solution vector(s)
869 C( IS, JS ) = RHS( 1 )
870 C( IS, JSP1 ) = RHS( 2 )
871 F( IS, JS ) = RHS( 3 )
872 F( IS, JSP1 ) = RHS( 4 )
874 * Substitute R(I, J) and L(I, J) into remaining
878 CALL SAXPY( JS-1, RHS( 1 ), B( 1, JS ), 1,
880 CALL SAXPY( JS-1, RHS( 2 ), B( 1, JSP1 ), 1,
882 CALL SAXPY( JS-1, RHS( 3 ), E( 1, JS ), 1,
884 CALL SAXPY( JS-1, RHS( 4 ), E( 1, JSP1 ), 1,
888 CALL SGER( M-IE, NB, -ONE, A( IS, IE+1 ), LDA,
889 $ RHS( 1 ), 1, C( IE+1, JS ), LDC )
890 CALL SGER( M-IE, NB, -ONE, D( IS, IE+1 ), LDD,
891 $ RHS( 3 ), 1, C( IE+1, JS ), LDC )
894 ELSE IF( ( MB.EQ.2 ) .AND. ( NB.EQ.1 ) ) THEN
896 * Build a 4-by-4 system Z**T * x = RHS
898 Z( 1, 1 ) = A( IS, IS )
899 Z( 2, 1 ) = A( IS, ISP1 )
900 Z( 3, 1 ) = -B( JS, JS )
903 Z( 1, 2 ) = A( ISP1, IS )
904 Z( 2, 2 ) = A( ISP1, ISP1 )
906 Z( 4, 2 ) = -B( JS, JS )
908 Z( 1, 3 ) = D( IS, IS )
909 Z( 2, 3 ) = D( IS, ISP1 )
910 Z( 3, 3 ) = -E( JS, JS )
914 Z( 2, 4 ) = D( ISP1, ISP1 )
916 Z( 4, 4 ) = -E( JS, JS )
918 * Set up right hand side(s)
920 RHS( 1 ) = C( IS, JS )
921 RHS( 2 ) = C( ISP1, JS )
922 RHS( 3 ) = F( IS, JS )
923 RHS( 4 ) = F( ISP1, JS )
925 * Solve Z**T * x = RHS
927 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
931 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV, SCALOC )
932 IF( SCALOC.NE.ONE ) THEN
934 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
935 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
940 * Unpack solution vector(s)
942 C( IS, JS ) = RHS( 1 )
943 C( ISP1, JS ) = RHS( 2 )
944 F( IS, JS ) = RHS( 3 )
945 F( ISP1, JS ) = RHS( 4 )
947 * Substitute R(I, J) and L(I, J) into remaining
951 CALL SGER( MB, JS-1, ONE, RHS( 1 ), 1, B( 1, JS ),
952 $ 1, F( IS, 1 ), LDF )
953 CALL SGER( MB, JS-1, ONE, RHS( 3 ), 1, E( 1, JS ),
954 $ 1, F( IS, 1 ), LDF )
957 CALL SGEMV( 'T', MB, M-IE, -ONE, A( IS, IE+1 ),
958 $ LDA, RHS( 1 ), 1, ONE, C( IE+1, JS ),
960 CALL SGEMV( 'T', MB, M-IE, -ONE, D( IS, IE+1 ),
961 $ LDD, RHS( 3 ), 1, ONE, C( IE+1, JS ),
965 ELSE IF( ( MB.EQ.2 ) .AND. ( NB.EQ.2 ) ) THEN
967 * Build an 8-by-8 system Z**T * x = RHS
969 CALL SLASET( 'F', LDZ, LDZ, ZERO, ZERO, Z, LDZ )
971 Z( 1, 1 ) = A( IS, IS )
972 Z( 2, 1 ) = A( IS, ISP1 )
973 Z( 5, 1 ) = -B( JS, JS )
974 Z( 7, 1 ) = -B( JSP1, JS )
976 Z( 1, 2 ) = A( ISP1, IS )
977 Z( 2, 2 ) = A( ISP1, ISP1 )
978 Z( 6, 2 ) = -B( JS, JS )
979 Z( 8, 2 ) = -B( JSP1, JS )
981 Z( 3, 3 ) = A( IS, IS )
982 Z( 4, 3 ) = A( IS, ISP1 )
983 Z( 5, 3 ) = -B( JS, JSP1 )
984 Z( 7, 3 ) = -B( JSP1, JSP1 )
986 Z( 3, 4 ) = A( ISP1, IS )
987 Z( 4, 4 ) = A( ISP1, ISP1 )
988 Z( 6, 4 ) = -B( JS, JSP1 )
989 Z( 8, 4 ) = -B( JSP1, JSP1 )
991 Z( 1, 5 ) = D( IS, IS )
992 Z( 2, 5 ) = D( IS, ISP1 )
993 Z( 5, 5 ) = -E( JS, JS )
995 Z( 2, 6 ) = D( ISP1, ISP1 )
996 Z( 6, 6 ) = -E( JS, JS )
998 Z( 3, 7 ) = D( IS, IS )
999 Z( 4, 7 ) = D( IS, ISP1 )
1000 Z( 5, 7 ) = -E( JS, JSP1 )
1001 Z( 7, 7 ) = -E( JSP1, JSP1 )
1003 Z( 4, 8 ) = D( ISP1, ISP1 )
1004 Z( 6, 8 ) = -E( JS, JSP1 )
1005 Z( 8, 8 ) = -E( JSP1, JSP1 )
1007 * Set up right hand side(s)
1011 DO 160 JJ = 0, NB - 1
1012 CALL SCOPY( MB, C( IS, JS+JJ ), 1, RHS( K ), 1 )
1013 CALL SCOPY( MB, F( IS, JS+JJ ), 1, RHS( II ), 1 )
1019 * Solve Z**T * x = RHS
1021 CALL SGETC2( ZDIM, Z, LDZ, IPIV, JPIV, IERR )
1025 CALL SGESC2( ZDIM, Z, LDZ, RHS, IPIV, JPIV, SCALOC )
1026 IF( SCALOC.NE.ONE ) THEN
1028 CALL SSCAL( M, SCALOC, C( 1, K ), 1 )
1029 CALL SSCAL( M, SCALOC, F( 1, K ), 1 )
1031 SCALE = SCALE*SCALOC
1034 * Unpack solution vector(s)
1038 DO 180 JJ = 0, NB - 1
1039 CALL SCOPY( MB, RHS( K ), 1, C( IS, JS+JJ ), 1 )
1040 CALL SCOPY( MB, RHS( II ), 1, F( IS, JS+JJ ), 1 )
1045 * Substitute R(I, J) and L(I, J) into remaining
1049 CALL SGEMM( 'N', 'T', MB, JS-1, NB, ONE,
1050 $ C( IS, JS ), LDC, B( 1, JS ), LDB, ONE,
1052 CALL SGEMM( 'N', 'T', MB, JS-1, NB, ONE,
1053 $ F( IS, JS ), LDF, E( 1, JS ), LDE, ONE,
1057 CALL SGEMM( 'T', 'N', M-IE, NB, MB, -ONE,
1058 $ A( IS, IE+1 ), LDA, C( IS, JS ), LDC,
1059 $ ONE, C( IE+1, JS ), LDC )
1060 CALL SGEMM( 'T', 'N', M-IE, NB, MB, -ONE,
1061 $ D( IS, IE+1 ), LDD, F( IS, JS ), LDF,
1062 $ ONE, C( IE+1, JS ), LDC )