1*> \brief \b ZGET54
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 ZGET54( N, A, LDA, B, LDB, S, LDS, T, LDT, U, LDU, V,
12*                          LDV, WORK, RESULT )
13*
14*       .. Scalar Arguments ..
15*       INTEGER            LDA, LDB, LDS, LDT, LDU, LDV, N
16*       DOUBLE PRECISION   RESULT
17*       ..
18*       .. Array Arguments ..
19*       COMPLEX*16         A( LDA, * ), B( LDB, * ), S( LDS, * ),
20*      $                   T( LDT, * ), U( LDU, * ), V( LDV, * ),
21*      $                   WORK( * )
22*       ..
23*
24*
25*> \par Purpose:
26*  =============
27*>
28*> \verbatim
29*>
30*> ZGET54 checks a generalized decomposition of the form
31*>
32*>          A = U*S*V'  and B = U*T* V'
33*>
34*> where ' means conjugate transpose and U and V are unitary.
35*>
36*> Specifically,
37*>
38*>   RESULT = ||( A - U*S*V', B - U*T*V' )|| / (||( A, B )||*n*ulp )
39*> \endverbatim
40*
41*  Arguments:
42*  ==========
43*
44*> \param[in] N
45*> \verbatim
46*>          N is INTEGER
47*>          The size of the matrix.  If it is zero, DGET54 does nothing.
48*>          It must be at least zero.
49*> \endverbatim
50*>
51*> \param[in] A
52*> \verbatim
53*>          A is COMPLEX*16 array, dimension (LDA, N)
54*>          The original (unfactored) matrix A.
55*> \endverbatim
56*>
57*> \param[in] LDA
58*> \verbatim
59*>          LDA is INTEGER
60*>          The leading dimension of A.  It must be at least 1
61*>          and at least N.
62*> \endverbatim
63*>
64*> \param[in] B
65*> \verbatim
66*>          B is COMPLEX*16 array, dimension (LDB, N)
67*>          The original (unfactored) matrix B.
68*> \endverbatim
69*>
70*> \param[in] LDB
71*> \verbatim
72*>          LDB is INTEGER
73*>          The leading dimension of B.  It must be at least 1
74*>          and at least N.
75*> \endverbatim
76*>
77*> \param[in] S
78*> \verbatim
79*>          S is COMPLEX*16 array, dimension (LDS, N)
80*>          The factored matrix S.
81*> \endverbatim
82*>
83*> \param[in] LDS
84*> \verbatim
85*>          LDS is INTEGER
86*>          The leading dimension of S.  It must be at least 1
87*>          and at least N.
88*> \endverbatim
89*>
90*> \param[in] T
91*> \verbatim
92*>          T is COMPLEX*16 array, dimension (LDT, N)
93*>          The factored matrix T.
94*> \endverbatim
95*>
96*> \param[in] LDT
97*> \verbatim
98*>          LDT is INTEGER
99*>          The leading dimension of T.  It must be at least 1
100*>          and at least N.
101*> \endverbatim
102*>
103*> \param[in] U
104*> \verbatim
105*>          U is COMPLEX*16 array, dimension (LDU, N)
106*>          The orthogonal matrix on the left-hand side in the
107*>          decomposition.
108*> \endverbatim
109*>
110*> \param[in] LDU
111*> \verbatim
112*>          LDU is INTEGER
113*>          The leading dimension of U.  LDU must be at least N and
114*>          at least 1.
115*> \endverbatim
116*>
117*> \param[in] V
118*> \verbatim
119*>          V is COMPLEX*16 array, dimension (LDV, N)
120*>          The orthogonal matrix on the left-hand side in the
121*>          decomposition.
122*> \endverbatim
123*>
124*> \param[in] LDV
125*> \verbatim
126*>          LDV is INTEGER
127*>          The leading dimension of V.  LDV must be at least N and
128*>          at least 1.
129*> \endverbatim
130*>
131*> \param[out] WORK
132*> \verbatim
133*>          WORK is COMPLEX*16 array, dimension (3*N**2)
134*> \endverbatim
135*>
136*> \param[out] RESULT
137*> \verbatim
138*>          RESULT is DOUBLE PRECISION
139*>          The value RESULT, It is currently limited to 1/ulp, to
140*>          avoid overflow. Errors are flagged by RESULT=10/ulp.
141*> \endverbatim
142*
143*  Authors:
144*  ========
145*
146*> \author Univ. of Tennessee
147*> \author Univ. of California Berkeley
148*> \author Univ. of Colorado Denver
149*> \author NAG Ltd.
150*
151*> \date November 2011
152*
153*> \ingroup complex16_eig
154*
155*  =====================================================================
156      SUBROUTINE ZGET54( N, A, LDA, B, LDB, S, LDS, T, LDT, U, LDU, V,
157     $                   LDV, WORK, RESULT )
158*
159*  -- LAPACK test routine (version 3.4.0) --
160*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
161*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
162*     November 2011
163*
164*     .. Scalar Arguments ..
165      INTEGER            LDA, LDB, LDS, LDT, LDU, LDV, N
166      DOUBLE PRECISION   RESULT
167*     ..
168*     .. Array Arguments ..
169      COMPLEX*16         A( LDA, * ), B( LDB, * ), S( LDS, * ),
170     $                   T( LDT, * ), U( LDU, * ), V( LDV, * ),
171     $                   WORK( * )
172*     ..
173*
174*  =====================================================================
175*
176*     .. Parameters ..
177      DOUBLE PRECISION   ZERO, ONE
178      PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
179      COMPLEX*16         CZERO, CONE
180      PARAMETER          ( CZERO = ( 0.0D+0, 0.0D+0 ),
181     $                   CONE = ( 1.0D+0, 0.0D+0 ) )
182*     ..
183*     .. Local Scalars ..
184      DOUBLE PRECISION   ABNORM, ULP, UNFL, WNORM
185*     ..
186*     .. Local Arrays ..
187      DOUBLE PRECISION   DUM( 1 )
188*     ..
189*     .. External Functions ..
190      DOUBLE PRECISION   DLAMCH, ZLANGE
191      EXTERNAL           DLAMCH, ZLANGE
192*     ..
193*     .. External Subroutines ..
194      EXTERNAL           ZGEMM, ZLACPY
195*     ..
196*     .. Intrinsic Functions ..
197      INTRINSIC          DBLE, MAX, MIN
198*     ..
199*     .. Executable Statements ..
200*
201      RESULT = ZERO
202      IF( N.LE.0 )
203     $   RETURN
204*
205*     Constants
206*
207      UNFL = DLAMCH( 'Safe minimum' )
208      ULP = DLAMCH( 'Epsilon' )*DLAMCH( 'Base' )
209*
210*     compute the norm of (A,B)
211*
212      CALL ZLACPY( 'Full', N, N, A, LDA, WORK, N )
213      CALL ZLACPY( 'Full', N, N, B, LDB, WORK( N*N+1 ), N )
214      ABNORM = MAX( ZLANGE( '1', N, 2*N, WORK, N, DUM ), UNFL )
215*
216*     Compute W1 = A - U*S*V', and put in the array WORK(1:N*N)
217*
218      CALL ZLACPY( ' ', N, N, A, LDA, WORK, N )
219      CALL ZGEMM( 'N', 'N', N, N, N, CONE, U, LDU, S, LDS, CZERO,
220     $            WORK( N*N+1 ), N )
221*
222      CALL ZGEMM( 'N', 'C', N, N, N, -CONE, WORK( N*N+1 ), N, V, LDV,
223     $            CONE, WORK, N )
224*
225*     Compute W2 = B - U*T*V', and put in the workarray W(N*N+1:2*N*N)
226*
227      CALL ZLACPY( ' ', N, N, B, LDB, WORK( N*N+1 ), N )
228      CALL ZGEMM( 'N', 'N', N, N, N, CONE, U, LDU, T, LDT, CZERO,
229     $            WORK( 2*N*N+1 ), N )
230*
231      CALL ZGEMM( 'N', 'C', N, N, N, -CONE, WORK( 2*N*N+1 ), N, V, LDV,
232     $            CONE, WORK( N*N+1 ), N )
233*
234*     Compute norm(W)/ ( ulp*norm((A,B)) )
235*
236      WNORM = ZLANGE( '1', N, 2*N, WORK, N, DUM )
237*
238      IF( ABNORM.GT.WNORM ) THEN
239         RESULT = ( WNORM / ABNORM ) / ( 2*N*ULP )
240      ELSE
241         IF( ABNORM.LT.ONE ) THEN
242            RESULT = ( MIN( WNORM, 2*N*ABNORM ) / ABNORM ) / ( 2*N*ULP )
243         ELSE
244            RESULT = MIN( WNORM / ABNORM, DBLE( 2*N ) ) / ( 2*N*ULP )
245         END IF
246      END IF
247*
248      RETURN
249*
250*     End of ZGET54
251*
252      END
253