LAPACK 3.3.1 Linear Algebra PACKage

# cget22.f

Go to the documentation of this file.
```00001       SUBROUTINE CGET22( TRANSA, TRANSE, TRANSW, N, A, LDA, E, LDE, W,
00002      \$                   WORK, RWORK, RESULT )
00003 *
00004 *  -- LAPACK test routine (version 3.1) --
00005 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00006 *     November 2006
00007 *
00008 *     .. Scalar Arguments ..
00009       CHARACTER          TRANSA, TRANSE, TRANSW
00010       INTEGER            LDA, LDE, N
00011 *     ..
00012 *     .. Array Arguments ..
00013       REAL               RESULT( 2 ), RWORK( * )
00014       COMPLEX            A( LDA, * ), E( LDE, * ), W( * ), WORK( * )
00015 *     ..
00016 *
00017 *  Purpose
00018 *  =======
00019 *
00020 *  CGET22 does an eigenvector check.
00021 *
00022 *  The basic test is:
00023 *
00024 *     RESULT(1) = | A E  -  E W | / ( |A| |E| ulp )
00025 *
00026 *  using the 1-norm.  It also tests the normalization of E:
00027 *
00028 *     RESULT(2) = max | m-norm(E(j)) - 1 | / ( n ulp )
00029 *                  j
00030 *
00031 *  where E(j) is the j-th eigenvector, and m-norm is the max-norm of a
00032 *  vector.  The max-norm of a complex n-vector x in this case is the
00033 *  maximum of |re(x(i)| + |im(x(i)| over i = 1, ..., n.
00034 *
00035 *  Arguments
00036 *  ==========
00037 *
00038 *  TRANSA  (input) CHARACTER*1
00039 *          Specifies whether or not A is transposed.
00040 *          = 'N':  No transpose
00041 *          = 'T':  Transpose
00042 *          = 'C':  Conjugate transpose
00043 *
00044 *  TRANSE  (input) CHARACTER*1
00045 *          Specifies whether or not E is transposed.
00046 *          = 'N':  No transpose, eigenvectors are in columns of E
00047 *          = 'T':  Transpose, eigenvectors are in rows of E
00048 *          = 'C':  Conjugate transpose, eigenvectors are in rows of E
00049 *
00050 *  TRANSW  (input) CHARACTER*1
00051 *          Specifies whether or not W is transposed.
00052 *          = 'N':  No transpose
00053 *          = 'T':  Transpose, same as TRANSW = 'N'
00054 *          = 'C':  Conjugate transpose, use -WI(j) instead of WI(j)
00055 *
00056 *  N       (input) INTEGER
00057 *          The order of the matrix A.  N >= 0.
00058 *
00059 *  A       (input) COMPLEX array, dimension (LDA,N)
00060 *          The matrix whose eigenvectors are in E.
00061 *
00062 *  LDA     (input) INTEGER
00063 *          The leading dimension of the array A.  LDA >= max(1,N).
00064 *
00065 *  E       (input) COMPLEX array, dimension (LDE,N)
00066 *          The matrix of eigenvectors. If TRANSE = 'N', the eigenvectors
00067 *          are stored in the columns of E, if TRANSE = 'T' or 'C', the
00068 *          eigenvectors are stored in the rows of E.
00069 *
00070 *  LDE     (input) INTEGER
00071 *          The leading dimension of the array E.  LDE >= max(1,N).
00072 *
00073 *  W       (input) COMPLEX array, dimension (N)
00074 *          The eigenvalues of A.
00075 *
00076 *  WORK    (workspace) COMPLEX array, dimension (N*N)
00077 *
00078 *  RWORK   (workspace) REAL array, dimension (N)
00079 *
00080 *  RESULT  (output) REAL array, dimension (2)
00081 *          RESULT(1) = | A E  -  E W | / ( |A| |E| ulp )
00082 *          RESULT(2) = max | m-norm(E(j)) - 1 | / ( n ulp )
00083 *                       j
00084 *  =====================================================================
00085 *
00086 *     .. Parameters ..
00087       REAL               ZERO, ONE
00088       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00089       COMPLEX            CZERO, CONE
00090       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00091      \$                   CONE = ( 1.0E+0, 0.0E+0 ) )
00092 *     ..
00093 *     .. Local Scalars ..
00094       CHARACTER          NORMA, NORME
00095       INTEGER            ITRNSE, ITRNSW, J, JCOL, JOFF, JROW, JVEC
00096       REAL               ANORM, ENORM, ENRMAX, ENRMIN, ERRNRM, TEMP1,
00097      \$                   ULP, UNFL
00098       COMPLEX            WTEMP
00099 *     ..
00100 *     .. External Functions ..
00101       LOGICAL            LSAME
00102       REAL               CLANGE, SLAMCH
00103       EXTERNAL           LSAME, CLANGE, SLAMCH
00104 *     ..
00105 *     .. External Subroutines ..
00106       EXTERNAL           CGEMM, CLASET
00107 *     ..
00108 *     .. Intrinsic Functions ..
00109       INTRINSIC          ABS, AIMAG, CONJG, MAX, MIN, REAL
00110 *     ..
00111 *     .. Executable Statements ..
00112 *
00113 *     Initialize RESULT (in case N=0)
00114 *
00115       RESULT( 1 ) = ZERO
00116       RESULT( 2 ) = ZERO
00117       IF( N.LE.0 )
00118      \$   RETURN
00119 *
00120       UNFL = SLAMCH( 'Safe minimum' )
00121       ULP = SLAMCH( 'Precision' )
00122 *
00123       ITRNSE = 0
00124       ITRNSW = 0
00125       NORMA = 'O'
00126       NORME = 'O'
00127 *
00128       IF( LSAME( TRANSA, 'T' ) .OR. LSAME( TRANSA, 'C' ) ) THEN
00129          NORMA = 'I'
00130       END IF
00131 *
00132       IF( LSAME( TRANSE, 'T' ) ) THEN
00133          ITRNSE = 1
00134          NORME = 'I'
00135       ELSE IF( LSAME( TRANSE, 'C' ) ) THEN
00136          ITRNSE = 2
00137          NORME = 'I'
00138       END IF
00139 *
00140       IF( LSAME( TRANSW, 'C' ) ) THEN
00141          ITRNSW = 1
00142       END IF
00143 *
00144 *     Normalization of E:
00145 *
00146       ENRMIN = ONE / ULP
00147       ENRMAX = ZERO
00148       IF( ITRNSE.EQ.0 ) THEN
00149          DO 20 JVEC = 1, N
00150             TEMP1 = ZERO
00151             DO 10 J = 1, N
00152                TEMP1 = MAX( TEMP1, ABS( REAL( E( J, JVEC ) ) )+
00153      \$                 ABS( AIMAG( E( J, JVEC ) ) ) )
00154    10       CONTINUE
00155             ENRMIN = MIN( ENRMIN, TEMP1 )
00156             ENRMAX = MAX( ENRMAX, TEMP1 )
00157    20    CONTINUE
00158       ELSE
00159          DO 30 JVEC = 1, N
00160             RWORK( JVEC ) = ZERO
00161    30    CONTINUE
00162 *
00163          DO 50 J = 1, N
00164             DO 40 JVEC = 1, N
00165                RWORK( JVEC ) = MAX( RWORK( JVEC ),
00166      \$                         ABS( REAL( E( JVEC, J ) ) )+
00167      \$                         ABS( AIMAG( E( JVEC, J ) ) ) )
00168    40       CONTINUE
00169    50    CONTINUE
00170 *
00171          DO 60 JVEC = 1, N
00172             ENRMIN = MIN( ENRMIN, RWORK( JVEC ) )
00173             ENRMAX = MAX( ENRMAX, RWORK( JVEC ) )
00174    60    CONTINUE
00175       END IF
00176 *
00177 *     Norm of A:
00178 *
00179       ANORM = MAX( CLANGE( NORMA, N, N, A, LDA, RWORK ), UNFL )
00180 *
00181 *     Norm of E:
00182 *
00183       ENORM = MAX( CLANGE( NORME, N, N, E, LDE, RWORK ), ULP )
00184 *
00185 *     Norm of error:
00186 *
00187 *     Error =  AE - EW
00188 *
00189       CALL CLASET( 'Full', N, N, CZERO, CZERO, WORK, N )
00190 *
00191       JOFF = 0
00192       DO 100 JCOL = 1, N
00193          IF( ITRNSW.EQ.0 ) THEN
00194             WTEMP = W( JCOL )
00195          ELSE
00196             WTEMP = CONJG( W( JCOL ) )
00197          END IF
00198 *
00199          IF( ITRNSE.EQ.0 ) THEN
00200             DO 70 JROW = 1, N
00201                WORK( JOFF+JROW ) = E( JROW, JCOL )*WTEMP
00202    70       CONTINUE
00203          ELSE IF( ITRNSE.EQ.1 ) THEN
00204             DO 80 JROW = 1, N
00205                WORK( JOFF+JROW ) = E( JCOL, JROW )*WTEMP
00206    80       CONTINUE
00207          ELSE
00208             DO 90 JROW = 1, N
00209                WORK( JOFF+JROW ) = CONJG( E( JCOL, JROW ) )*WTEMP
00210    90       CONTINUE
00211          END IF
00212          JOFF = JOFF + N
00213   100 CONTINUE
00214 *
00215       CALL CGEMM( TRANSA, TRANSE, N, N, N, CONE, A, LDA, E, LDE, -CONE,
00216      \$            WORK, N )
00217 *
00218       ERRNRM = CLANGE( 'One', N, N, WORK, N, RWORK ) / ENORM
00219 *
00220 *     Compute RESULT(1) (avoiding under/overflow)
00221 *
00222       IF( ANORM.GT.ERRNRM ) THEN
00223          RESULT( 1 ) = ( ERRNRM / ANORM ) / ULP
00224       ELSE
00225          IF( ANORM.LT.ONE ) THEN
00226             RESULT( 1 ) = ( MIN( ERRNRM, ANORM ) / ANORM ) / ULP
00227          ELSE
00228             RESULT( 1 ) = MIN( ERRNRM / ANORM, ONE ) / ULP
00229          END IF
00230       END IF
00231 *
00232 *     Compute RESULT(2) : the normalization error in E.
00233 *
00234       RESULT( 2 ) = MAX( ABS( ENRMAX-ONE ), ABS( ENRMIN-ONE ) ) /
00235      \$              ( REAL( N )*ULP )
00236 *
00237       RETURN
00238 *
00239 *     End of CGET22
00240 *
00241       END
```