1*> \brief \b CSYT01_ROOK
2*
3*  =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6*            http://www.netlib.org/lapack/explore-html/
7*
8*  Definition:
9*  ===========
10*
11*       SUBROUTINE CSYT01_ROOK( UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC,
12*                          RWORK, RESID )
13*
14*       .. Scalar Arguments ..
15*       CHARACTER          UPLO
16*       INTEGER            LDA, LDAFAC, LDC, N
17*       REAL               RESID
18*       ..
19*       .. Array Arguments ..
20*       INTEGER            IPIV( * )
21*       REAL               RWORK( * )
22*       COMPLEX            A( LDA, * ), AFAC( LDAFAC, * ), C( LDC, * )
23*       ..
24*
25*
26*> \par Purpose:
27*  =============
28*>
29*> \verbatim
30*>
31*> CSYT01_ROOK reconstructs a complex symmetric indefinite matrix A from its
32*> block L*D*L' or U*D*U' factorization and computes the residual
33*>    norm( C - A ) / ( N * norm(A) * EPS ),
34*> where C is the reconstructed matrix, EPS is the machine epsilon,
35*> L' is the transpose of L, and U' is the transpose of U.
36*> \endverbatim
37*
38*  Arguments:
39*  ==========
40*
41*> \param[in] UPLO
42*> \verbatim
43*>          UPLO is CHARACTER*1
44*>          Specifies whether the upper or lower triangular part of the
45*>          complex symmetric matrix A is stored:
46*>          = 'U':  Upper triangular
47*>          = 'L':  Lower triangular
48*> \endverbatim
49*>
50*> \param[in] N
51*> \verbatim
52*>          N is INTEGER
53*>          The number of rows and columns of the matrix A.  N >= 0.
54*> \endverbatim
55*>
56*> \param[in] A
57*> \verbatim
58*>          A is COMPLEX array, dimension (LDA,N)
59*>          The original complex symmetric matrix A.
60*> \endverbatim
61*>
62*> \param[in] LDA
63*> \verbatim
64*>          LDA is INTEGER
65*>          The leading dimension of the array A.  LDA >= max(1,N)
66*> \endverbatim
67*>
68*> \param[in] AFAC
69*> \verbatim
70*>          AFAC is COMPLEX array, dimension (LDAFAC,N)
71*>          The factored form of the matrix A.  AFAC contains the block
72*>          diagonal matrix D and the multipliers used to obtain the
73*>          factor L or U from the block L*D*L' or U*D*U' factorization
74*>          as computed by CSYTRF_ROOK.
75*> \endverbatim
76*>
77*> \param[in] LDAFAC
78*> \verbatim
79*>          LDAFAC is INTEGER
80*>          The leading dimension of the array AFAC.  LDAFAC >= max(1,N).
81*> \endverbatim
82*>
83*> \param[in] IPIV
84*> \verbatim
85*>          IPIV is INTEGER array, dimension (N)
86*>          The pivot indices from CSYTRF_ROOK.
87*> \endverbatim
88*>
89*> \param[out] C
90*> \verbatim
91*>          C is COMPLEX array, dimension (LDC,N)
92*> \endverbatim
93*>
94*> \param[in] LDC
95*> \verbatim
96*>          LDC is INTEGER
97*>          The leading dimension of the array C.  LDC >= max(1,N).
98*> \endverbatim
99*>
100*> \param[out] RWORK
101*> \verbatim
102*>          RWORK is REAL array, dimension (N)
103*> \endverbatim
104*>
105*> \param[out] RESID
106*> \verbatim
107*>          RESID is REAL
108*>          If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS )
109*>          If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS )
110*> \endverbatim
111*
112*  Authors:
113*  ========
114*
115*> \author Univ. of Tennessee
116*> \author Univ. of California Berkeley
117*> \author Univ. of Colorado Denver
118*> \author NAG Ltd.
119*
120*> \ingroup complex_lin
121*
122*  =====================================================================
123      SUBROUTINE CSYT01_ROOK( UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C,
124     $                    LDC, RWORK, RESID )
125*
126*  -- LAPACK test routine --
127*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
128*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
129*
130*     .. Scalar Arguments ..
131      CHARACTER          UPLO
132      INTEGER            LDA, LDAFAC, LDC, N
133      REAL               RESID
134*     ..
135*     .. Array Arguments ..
136      INTEGER            IPIV( * )
137      REAL               RWORK( * )
138      COMPLEX            A( LDA, * ), AFAC( LDAFAC, * ), C( LDC, * )
139*     ..
140*
141*  =====================================================================
142*
143*     .. Parameters ..
144      REAL               ZERO, ONE
145      PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
146      COMPLEX            CZERO, CONE
147      PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
148     $                   CONE = ( 1.0E+0, 0.0E+0 ) )
149*     ..
150*     .. Local Scalars ..
151      INTEGER            I, INFO, J
152      REAL               ANORM, EPS
153*     ..
154*     .. External Functions ..
155      LOGICAL            LSAME
156      REAL               CLANSY, SLAMCH
157      EXTERNAL           LSAME, CLANSY, SLAMCH
158*     ..
159*     .. External Subroutines ..
160      EXTERNAL           CLASET, CLAVSY_ROOK
161*     ..
162*     .. Intrinsic Functions ..
163      INTRINSIC          REAL
164*     ..
165*     .. Executable Statements ..
166*
167*     Quick exit if N = 0.
168*
169      IF( N.LE.0 ) THEN
170         RESID = ZERO
171         RETURN
172      END IF
173*
174*     Determine EPS and the norm of A.
175*
176      EPS = SLAMCH( 'Epsilon' )
177      ANORM = CLANSY( '1', UPLO, N, A, LDA, RWORK )
178*
179*     Initialize C to the identity matrix.
180*
181      CALL CLASET( 'Full', N, N, CZERO, CONE, C, LDC )
182*
183*     Call CLAVSY_ROOK to form the product D * U' (or D * L' ).
184*
185      CALL CLAVSY_ROOK( UPLO, 'Transpose', 'Non-unit', N, N, AFAC,
186     $              LDAFAC, IPIV, C, LDC, INFO )
187*
188*     Call CLAVSY_ROOK again to multiply by U (or L ).
189*
190      CALL CLAVSY_ROOK( UPLO, 'No transpose', 'Unit', N, N, AFAC,
191     $              LDAFAC, IPIV, C, LDC, INFO )
192*
193*     Compute the difference  C - A .
194*
195      IF( LSAME( UPLO, 'U' ) ) THEN
196         DO 20 J = 1, N
197            DO 10 I = 1, J
198               C( I, J ) = C( I, J ) - A( I, J )
199   10       CONTINUE
200   20    CONTINUE
201      ELSE
202         DO 40 J = 1, N
203            DO 30 I = J, N
204               C( I, J ) = C( I, J ) - A( I, J )
205   30       CONTINUE
206   40    CONTINUE
207      END IF
208*
209*     Compute norm( C - A ) / ( N * norm(A) * EPS )
210*
211      RESID = CLANSY( '1', UPLO, N, C, LDC, RWORK )
212*
213      IF( ANORM.LE.ZERO ) THEN
214         IF( RESID.NE.ZERO )
215     $      RESID = ONE / EPS
216      ELSE
217         RESID = ( ( RESID/REAL( N ) )/ANORM ) / EPS
218      END IF
219*
220      RETURN
221*
222*     End of CSYT01_ROOK
223*
224      END
225