LAPACK  3.10.1
LAPACK: Linear Algebra PACKage
cunt01.f
Go to the documentation of this file.
1 *> \brief \b CUNT01
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 CUNT01( ROWCOL, M, N, U, LDU, WORK, LWORK, RWORK,
12 * RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER ROWCOL
16 * INTEGER LDU, LWORK, M, N
17 * REAL RESID
18 * ..
19 * .. Array Arguments ..
20 * REAL RWORK( * )
21 * COMPLEX U( LDU, * ), WORK( * )
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> CUNT01 checks that the matrix U is unitary by computing the ratio
31 *>
32 *> RESID = norm( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
33 *> or
34 *> RESID = norm( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.
35 *>
36 *> Alternatively, if there isn't sufficient workspace to form
37 *> I - U*U' or I - U'*U, the ratio is computed as
38 *>
39 *> RESID = abs( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
40 *> or
41 *> RESID = abs( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.
42 *>
43 *> where EPS is the machine precision. ROWCOL is used only if m = n;
44 *> if m > n, ROWCOL is assumed to be 'C', and if m < n, ROWCOL is
45 *> assumed to be 'R'.
46 *> \endverbatim
47 *
48 * Arguments:
49 * ==========
50 *
51 *> \param[in] ROWCOL
52 *> \verbatim
53 *> ROWCOL is CHARACTER
54 *> Specifies whether the rows or columns of U should be checked
55 *> for orthogonality. Used only if M = N.
56 *> = 'R': Check for orthogonal rows of U
57 *> = 'C': Check for orthogonal columns of U
58 *> \endverbatim
59 *>
60 *> \param[in] M
61 *> \verbatim
62 *> M is INTEGER
63 *> The number of rows of the matrix U.
64 *> \endverbatim
65 *>
66 *> \param[in] N
67 *> \verbatim
68 *> N is INTEGER
69 *> The number of columns of the matrix U.
70 *> \endverbatim
71 *>
72 *> \param[in] U
73 *> \verbatim
74 *> U is COMPLEX array, dimension (LDU,N)
75 *> The unitary matrix U. U is checked for orthogonal columns
76 *> if m > n or if m = n and ROWCOL = 'C'. U is checked for
77 *> orthogonal rows if m < n or if m = n and ROWCOL = 'R'.
78 *> \endverbatim
79 *>
80 *> \param[in] LDU
81 *> \verbatim
82 *> LDU is INTEGER
83 *> The leading dimension of the array U. LDU >= max(1,M).
84 *> \endverbatim
85 *>
86 *> \param[out] WORK
87 *> \verbatim
88 *> WORK is COMPLEX array, dimension (LWORK)
89 *> \endverbatim
90 *>
91 *> \param[in] LWORK
92 *> \verbatim
93 *> LWORK is INTEGER
94 *> The length of the array WORK. For best performance, LWORK
95 *> should be at least N*N if ROWCOL = 'C' or M*M if
96 *> ROWCOL = 'R', but the test will be done even if LWORK is 0.
97 *> \endverbatim
98 *>
99 *> \param[out] RWORK
100 *> \verbatim
101 *> RWORK is REAL array, dimension (min(M,N))
102 *> Used only if LWORK is large enough to use the Level 3 BLAS
103 *> code.
104 *> \endverbatim
105 *>
106 *> \param[out] RESID
107 *> \verbatim
108 *> RESID is REAL
109 *> RESID = norm( I - U * U' ) / ( n * EPS ), if ROWCOL = 'R', or
110 *> RESID = norm( I - U' * U ) / ( m * EPS ), if ROWCOL = 'C'.
111 *> \endverbatim
112 *
113 * Authors:
114 * ========
115 *
116 *> \author Univ. of Tennessee
117 *> \author Univ. of California Berkeley
118 *> \author Univ. of Colorado Denver
119 *> \author NAG Ltd.
120 *
121 *> \ingroup complex_eig
122 *
123 * =====================================================================
124  SUBROUTINE cunt01( ROWCOL, M, N, U, LDU, WORK, LWORK, RWORK,
125  $ RESID )
126 *
127 * -- LAPACK test routine --
128 * -- LAPACK is a software package provided by Univ. of Tennessee, --
129 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
130 *
131 * .. Scalar Arguments ..
132  CHARACTER ROWCOL
133  INTEGER LDU, LWORK, M, N
134  REAL RESID
135 * ..
136 * .. Array Arguments ..
137  REAL RWORK( * )
138  COMPLEX U( LDU, * ), WORK( * )
139 * ..
140 *
141 * =====================================================================
142 *
143 * .. Parameters ..
144  REAL ZERO, ONE
145  parameter( zero = 0.0e+0, one = 1.0e+0 )
146 * ..
147 * .. Local Scalars ..
148  CHARACTER TRANSU
149  INTEGER I, J, K, LDWORK, MNMIN
150  REAL EPS
151  COMPLEX TMP, ZDUM
152 * ..
153 * .. External Functions ..
154  LOGICAL LSAME
155  REAL CLANSY, SLAMCH
156  COMPLEX CDOTC
157  EXTERNAL lsame, clansy, slamch, cdotc
158 * ..
159 * .. External Subroutines ..
160  EXTERNAL cherk, claset
161 * ..
162 * .. Intrinsic Functions ..
163  INTRINSIC abs, aimag, cmplx, max, min, real
164 * ..
165 * .. Statement Functions ..
166  REAL CABS1
167 * ..
168 * .. Statement Function definitions ..
169  cabs1( zdum ) = abs( real( zdum ) ) + abs( aimag( zdum ) )
170 * ..
171 * .. Executable Statements ..
172 *
173  resid = zero
174 *
175 * Quick return if possible
176 *
177  IF( m.LE.0 .OR. n.LE.0 )
178  $ RETURN
179 *
180  eps = slamch( 'Precision' )
181  IF( m.LT.n .OR. ( m.EQ.n .AND. lsame( rowcol, 'R' ) ) ) THEN
182  transu = 'N'
183  k = n
184  ELSE
185  transu = 'C'
186  k = m
187  END IF
188  mnmin = min( m, n )
189 *
190  IF( ( mnmin+1 )*mnmin.LE.lwork ) THEN
191  ldwork = mnmin
192  ELSE
193  ldwork = 0
194  END IF
195  IF( ldwork.GT.0 ) THEN
196 *
197 * Compute I - U*U' or I - U'*U.
198 *
199  CALL claset( 'Upper', mnmin, mnmin, cmplx( zero ),
200  $ cmplx( one ), work, ldwork )
201  CALL cherk( 'Upper', transu, mnmin, k, -one, u, ldu, one, work,
202  $ ldwork )
203 *
204 * Compute norm( I - U*U' ) / ( K * EPS ) .
205 *
206  resid = clansy( '1', 'Upper', mnmin, work, ldwork, rwork )
207  resid = ( resid / real( k ) ) / eps
208  ELSE IF( transu.EQ.'C' ) THEN
209 *
210 * Find the maximum element in abs( I - U'*U ) / ( m * EPS )
211 *
212  DO 20 j = 1, n
213  DO 10 i = 1, j
214  IF( i.NE.j ) THEN
215  tmp = zero
216  ELSE
217  tmp = one
218  END IF
219  tmp = tmp - cdotc( m, u( 1, i ), 1, u( 1, j ), 1 )
220  resid = max( resid, cabs1( tmp ) )
221  10 CONTINUE
222  20 CONTINUE
223  resid = ( resid / real( m ) ) / eps
224  ELSE
225 *
226 * Find the maximum element in abs( I - U*U' ) / ( n * EPS )
227 *
228  DO 40 j = 1, m
229  DO 30 i = 1, j
230  IF( i.NE.j ) THEN
231  tmp = zero
232  ELSE
233  tmp = one
234  END IF
235  tmp = tmp - cdotc( n, u( j, 1 ), ldu, u( i, 1 ), ldu )
236  resid = max( resid, cabs1( tmp ) )
237  30 CONTINUE
238  40 CONTINUE
239  resid = ( resid / real( n ) ) / eps
240  END IF
241  RETURN
242 *
243 * End of CUNT01
244 *
245  END
subroutine cherk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
CHERK
Definition: cherk.f:173
subroutine cunt01(ROWCOL, M, N, U, LDU, WORK, LWORK, RWORK, RESID)
CUNT01
Definition: cunt01.f:126
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values.
Definition: claset.f:106