LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine cunt01 ( character  ROWCOL,
integer  M,
integer  N,
complex, dimension( ldu, * )  U,
integer  LDU,
complex, dimension( * )  WORK,
integer  LWORK,
real, dimension( * )  RWORK,
real  RESID 
)

CUNT01

Purpose:
 CUNT01 checks that the matrix U is unitary by computing the ratio

    RESID = norm( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
 or
    RESID = norm( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.

 Alternatively, if there isn't sufficient workspace to form
 I - U*U' or I - U'*U, the ratio is computed as

    RESID = abs( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
 or
    RESID = abs( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.

 where EPS is the machine precision.  ROWCOL is used only if m = n;
 if m > n, ROWCOL is assumed to be 'C', and if m < n, ROWCOL is
 assumed to be 'R'.
Parameters
[in]ROWCOL
          ROWCOL is CHARACTER
          Specifies whether the rows or columns of U should be checked
          for orthogonality.  Used only if M = N.
          = 'R':  Check for orthogonal rows of U
          = 'C':  Check for orthogonal columns of U
[in]M
          M is INTEGER
          The number of rows of the matrix U.
[in]N
          N is INTEGER
          The number of columns of the matrix U.
[in]U
          U is COMPLEX array, dimension (LDU,N)
          The unitary matrix U.  U is checked for orthogonal columns
          if m > n or if m = n and ROWCOL = 'C'.  U is checked for
          orthogonal rows if m < n or if m = n and ROWCOL = 'R'.
[in]LDU
          LDU is INTEGER
          The leading dimension of the array U.  LDU >= max(1,M).
[out]WORK
          WORK is COMPLEX array, dimension (LWORK)
[in]LWORK
          LWORK is INTEGER
          The length of the array WORK.  For best performance, LWORK
          should be at least N*N if ROWCOL = 'C' or M*M if
          ROWCOL = 'R', but the test will be done even if LWORK is 0.
[out]RWORK
          RWORK is REAL array, dimension (min(M,N))
          Used only if LWORK is large enough to use the Level 3 BLAS
          code.
[out]RESID
          RESID is REAL
          RESID = norm( I - U * U' ) / ( n * EPS ), if ROWCOL = 'R', or
          RESID = norm( I - U' * U ) / ( m * EPS ), if ROWCOL = 'C'.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011

Definition at line 128 of file cunt01.f.

128 *
129 * -- LAPACK test routine (version 3.4.0) --
130 * -- LAPACK is a software package provided by Univ. of Tennessee, --
131 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
132 * November 2011
133 *
134 * .. Scalar Arguments ..
135  CHARACTER rowcol
136  INTEGER ldu, lwork, m, n
137  REAL resid
138 * ..
139 * .. Array Arguments ..
140  REAL rwork( * )
141  COMPLEX u( ldu, * ), work( * )
142 * ..
143 *
144 * =====================================================================
145 *
146 * .. Parameters ..
147  REAL zero, one
148  parameter ( zero = 0.0e+0, one = 1.0e+0 )
149 * ..
150 * .. Local Scalars ..
151  CHARACTER transu
152  INTEGER i, j, k, ldwork, mnmin
153  REAL eps
154  COMPLEX tmp, zdum
155 * ..
156 * .. External Functions ..
157  LOGICAL lsame
158  REAL clansy, slamch
159  COMPLEX cdotc
160  EXTERNAL lsame, clansy, slamch, cdotc
161 * ..
162 * .. External Subroutines ..
163  EXTERNAL cherk, claset
164 * ..
165 * .. Intrinsic Functions ..
166  INTRINSIC abs, aimag, cmplx, max, min, real
167 * ..
168 * .. Statement Functions ..
169  REAL cabs1
170 * ..
171 * .. Statement Function definitions ..
172  cabs1( zdum ) = abs( REAL( ZDUM ) ) + abs( aimag( zdum ) )
173 * ..
174 * .. Executable Statements ..
175 *
176  resid = zero
177 *
178 * Quick return if possible
179 *
180  IF( m.LE.0 .OR. n.LE.0 )
181  $ RETURN
182 *
183  eps = slamch( 'Precision' )
184  IF( m.LT.n .OR. ( m.EQ.n .AND. lsame( rowcol, 'R' ) ) ) THEN
185  transu = 'N'
186  k = n
187  ELSE
188  transu = 'C'
189  k = m
190  END IF
191  mnmin = min( m, n )
192 *
193  IF( ( mnmin+1 )*mnmin.LE.lwork ) THEN
194  ldwork = mnmin
195  ELSE
196  ldwork = 0
197  END IF
198  IF( ldwork.GT.0 ) THEN
199 *
200 * Compute I - U*U' or I - U'*U.
201 *
202  CALL claset( 'Upper', mnmin, mnmin, cmplx( zero ),
203  $ cmplx( one ), work, ldwork )
204  CALL cherk( 'Upper', transu, mnmin, k, -one, u, ldu, one, work,
205  $ ldwork )
206 *
207 * Compute norm( I - U*U' ) / ( K * EPS ) .
208 *
209  resid = clansy( '1', 'Upper', mnmin, work, ldwork, rwork )
210  resid = ( resid / REAL( K ) ) / eps
211  ELSE IF( transu.EQ.'C' ) THEN
212 *
213 * Find the maximum element in abs( I - U'*U ) / ( m * EPS )
214 *
215  DO 20 j = 1, n
216  DO 10 i = 1, j
217  IF( i.NE.j ) THEN
218  tmp = zero
219  ELSE
220  tmp = one
221  END IF
222  tmp = tmp - cdotc( m, u( 1, i ), 1, u( 1, j ), 1 )
223  resid = max( resid, cabs1( tmp ) )
224  10 CONTINUE
225  20 CONTINUE
226  resid = ( resid / REAL( M ) ) / eps
227  ELSE
228 *
229 * Find the maximum element in abs( I - U*U' ) / ( n * EPS )
230 *
231  DO 40 j = 1, m
232  DO 30 i = 1, j
233  IF( i.NE.j ) THEN
234  tmp = zero
235  ELSE
236  tmp = one
237  END IF
238  tmp = tmp - cdotc( n, u( j, 1 ), ldu, u( i, 1 ), ldu )
239  resid = max( resid, cabs1( tmp ) )
240  30 CONTINUE
241  40 CONTINUE
242  resid = ( resid / REAL( N ) ) / eps
243  END IF
244  RETURN
245 *
246 * End of CUNT01
247 *
subroutine cherk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
CHERK
Definition: cherk.f:175
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:108
complex function cdotc(N, CX, INCX, CY, INCY)
CDOTC
Definition: cdotc.f:54
real function clansy(NORM, UPLO, N, A, LDA, WORK)
CLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a complex symmetric matrix.
Definition: clansy.f:125
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55

Here is the call graph for this function:

Here is the caller graph for this function: