LAPACK 3.3.1
Linear Algebra PACKage

cget51.f

Go to the documentation of this file.
00001       SUBROUTINE CGET51( ITYPE, N, A, LDA, B, LDB, U, LDU, V, LDV, WORK,
00002      $                   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       INTEGER            ITYPE, LDA, LDB, LDU, LDV, N
00010       REAL               RESULT
00011 *     ..
00012 *     .. Array Arguments ..
00013       REAL               RWORK( * )
00014       COMPLEX            A( LDA, * ), B( LDB, * ), U( LDU, * ),
00015      $                   V( LDV, * ), WORK( * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *       CGET51  generally checks a decomposition of the form
00022 *
00023 *               A = U B V*
00024 *
00025 *       where * means conjugate transpose and U and V are unitary.
00026 *
00027 *       Specifically, if ITYPE=1
00028 *
00029 *               RESULT = | A - U B V* | / ( |A| n ulp )
00030 *
00031 *       If ITYPE=2, then:
00032 *
00033 *               RESULT = | A - B | / ( |A| n ulp )
00034 *
00035 *       If ITYPE=3, then:
00036 *
00037 *               RESULT = | I - UU* | / ( n ulp )
00038 *
00039 *  Arguments
00040 *  =========
00041 *
00042 *  ITYPE   (input) INTEGER
00043 *          Specifies the type of tests to be performed.
00044 *          =1: RESULT = | A - U B V* | / ( |A| n ulp )
00045 *          =2: RESULT = | A - B | / ( |A| n ulp )
00046 *          =3: RESULT = | I - UU* | / ( n ulp )
00047 *
00048 *  N       (input) INTEGER
00049 *          The size of the matrix.  If it is zero, CGET51 does nothing.
00050 *          It must be at least zero.
00051 *
00052 *  A       (input) COMPLEX array, dimension (LDA, N)
00053 *          The original (unfactored) matrix.
00054 *
00055 *  LDA     (input) INTEGER
00056 *          The leading dimension of A.  It must be at least 1
00057 *          and at least N.
00058 *
00059 *  B       (input) COMPLEX array, dimension (LDB, N)
00060 *          The factored matrix.
00061 *
00062 *  LDB     (input) INTEGER
00063 *          The leading dimension of B.  It must be at least 1
00064 *          and at least N.
00065 *
00066 *  U       (input) COMPLEX array, dimension (LDU, N)
00067 *          The unitary matrix on the left-hand side in the
00068 *          decomposition.
00069 *          Not referenced if ITYPE=2
00070 *
00071 *  LDU     (input) INTEGER
00072 *          The leading dimension of U.  LDU must be at least N and
00073 *          at least 1.
00074 *
00075 *  V       (input) COMPLEX array, dimension (LDV, N)
00076 *          The unitary matrix on the left-hand side in the
00077 *          decomposition.
00078 *          Not referenced if ITYPE=2
00079 *
00080 *  LDV     (input) INTEGER
00081 *          The leading dimension of V.  LDV must be at least N and
00082 *          at least 1.
00083 *
00084 *  WORK    (workspace) COMPLEX array, dimension (2*N**2)
00085 *
00086 *  RWORK   (workspace) REAL array, dimension (N)
00087 *
00088 *  RESULT  (output) REAL
00089 *          The values computed by the test specified by ITYPE.  The
00090 *          value is currently limited to 1/ulp, to avoid overflow.
00091 *          Errors are flagged by RESULT=10/ulp.
00092 *
00093 *  =====================================================================
00094 *
00095 *     .. Parameters ..
00096       REAL               ZERO, ONE, TEN
00097       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0, TEN = 10.0E+0 )
00098       COMPLEX            CZERO, CONE
00099       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00100      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00101 *     ..
00102 *     .. Local Scalars ..
00103       INTEGER            JCOL, JDIAG, JROW
00104       REAL               ANORM, ULP, UNFL, WNORM
00105 *     ..
00106 *     .. External Functions ..
00107       REAL               CLANGE, SLAMCH
00108       EXTERNAL           CLANGE, SLAMCH
00109 *     ..
00110 *     .. External Subroutines ..
00111       EXTERNAL           CGEMM, CLACPY
00112 *     ..
00113 *     .. Intrinsic Functions ..
00114       INTRINSIC          MAX, MIN, REAL
00115 *     ..
00116 *     .. Executable Statements ..
00117 *
00118       RESULT = ZERO
00119       IF( N.LE.0 )
00120      $   RETURN
00121 *
00122 *     Constants
00123 *
00124       UNFL = SLAMCH( 'Safe minimum' )
00125       ULP = SLAMCH( 'Epsilon' )*SLAMCH( 'Base' )
00126 *
00127 *     Some Error Checks
00128 *
00129       IF( ITYPE.LT.1 .OR. ITYPE.GT.3 ) THEN
00130          RESULT = TEN / ULP
00131          RETURN
00132       END IF
00133 *
00134       IF( ITYPE.LE.2 ) THEN
00135 *
00136 *        Tests scaled by the norm(A)
00137 *
00138          ANORM = MAX( CLANGE( '1', N, N, A, LDA, RWORK ), UNFL )
00139 *
00140          IF( ITYPE.EQ.1 ) THEN
00141 *
00142 *           ITYPE=1: Compute W = A - UBV'
00143 *
00144             CALL CLACPY( ' ', N, N, A, LDA, WORK, N )
00145             CALL CGEMM( 'N', 'N', N, N, N, CONE, U, LDU, B, LDB, CZERO,
00146      $                  WORK( N**2+1 ), N )
00147 *
00148             CALL CGEMM( 'N', 'C', N, N, N, -CONE, WORK( N**2+1 ), N, V,
00149      $                  LDV, CONE, WORK, N )
00150 *
00151          ELSE
00152 *
00153 *           ITYPE=2: Compute W = A - B
00154 *
00155             CALL CLACPY( ' ', N, N, B, LDB, WORK, N )
00156 *
00157             DO 20 JCOL = 1, N
00158                DO 10 JROW = 1, N
00159                   WORK( JROW+N*( JCOL-1 ) ) = WORK( JROW+N*( JCOL-1 ) )
00160      $                - A( JROW, JCOL )
00161    10          CONTINUE
00162    20       CONTINUE
00163          END IF
00164 *
00165 *        Compute norm(W)/ ( ulp*norm(A) )
00166 *
00167          WNORM = CLANGE( '1', N, N, WORK, N, RWORK )
00168 *
00169          IF( ANORM.GT.WNORM ) THEN
00170             RESULT = ( WNORM / ANORM ) / ( N*ULP )
00171          ELSE
00172             IF( ANORM.LT.ONE ) THEN
00173                RESULT = ( MIN( WNORM, N*ANORM ) / ANORM ) / ( N*ULP )
00174             ELSE
00175                RESULT = MIN( WNORM / ANORM, REAL( N ) ) / ( N*ULP )
00176             END IF
00177          END IF
00178 *
00179       ELSE
00180 *
00181 *        Tests not scaled by norm(A)
00182 *
00183 *        ITYPE=3: Compute  UU' - I
00184 *
00185          CALL CGEMM( 'N', 'C', N, N, N, CONE, U, LDU, U, LDU, CZERO,
00186      $               WORK, N )
00187 *
00188          DO 30 JDIAG = 1, N
00189             WORK( ( N+1 )*( JDIAG-1 )+1 ) = WORK( ( N+1 )*( JDIAG-1 )+
00190      $         1 ) - CONE
00191    30    CONTINUE
00192 *
00193          RESULT = MIN( CLANGE( '1', N, N, WORK, N, RWORK ),
00194      $            REAL( N ) ) / ( N*ULP )
00195       END IF
00196 *
00197       RETURN
00198 *
00199 *     End of CGET51
00200 *
00201       END
 All Files Functions