LAPACK 3.3.1
Linear Algebra PACKage

cchkgk.f

Go to the documentation of this file.
00001       SUBROUTINE CCHKGK( NIN, NOUT )
00002 *
00003 *  -- LAPACK test routine (version 3.1) --
00004 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00005 *     November 2006
00006 *
00007 *     .. Scalar Arguments ..
00008       INTEGER            NIN, NOUT
00009 *     ..
00010 *
00011 *  Purpose
00012 *  =======
00013 *
00014 *  CCHKGK tests CGGBAK, a routine for backward balancing  of
00015 *  a matrix pair (A, B).
00016 *
00017 *  Arguments
00018 *  =========
00019 *
00020 *  NIN     (input) INTEGER
00021 *          The logical unit number for input.  NIN > 0.
00022 *
00023 *  NOUT    (input) INTEGER
00024 *          The logical unit number for output.  NOUT > 0.
00025 *
00026 *  =====================================================================
00027 *
00028 *     .. Parameters ..
00029       INTEGER            LDA, LDB, LDVL, LDVR
00030       PARAMETER          ( LDA = 50, LDB = 50, LDVL = 50, LDVR = 50 )
00031       INTEGER            LDE, LDF, LDWORK, LRWORK
00032       PARAMETER          ( LDE = 50, LDF = 50, LDWORK = 50,
00033      $                   LRWORK = 6*50 )
00034       REAL               ZERO
00035       PARAMETER          ( ZERO = 0.0E+0 )
00036       COMPLEX            CZERO, CONE
00037       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00038      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00039 *     ..
00040 *     .. Local Scalars ..
00041       INTEGER            I, IHI, ILO, INFO, J, KNT, M, N, NINFO
00042       REAL               ANORM, BNORM, EPS, RMAX, VMAX
00043       COMPLEX            CDUM
00044 *     ..
00045 *     .. Local Arrays ..
00046       INTEGER            LMAX( 4 )
00047       REAL               LSCALE( LDA ), RSCALE( LDA ), RWORK( LRWORK )
00048       COMPLEX            A( LDA, LDA ), AF( LDA, LDA ), B( LDB, LDB ),
00049      $                   BF( LDB, LDB ), E( LDE, LDE ), F( LDF, LDF ),
00050      $                   VL( LDVL, LDVL ), VLF( LDVL, LDVL ),
00051      $                   VR( LDVR, LDVR ), VRF( LDVR, LDVR ),
00052      $                   WORK( LDWORK, LDWORK )
00053 *     ..
00054 *     .. External Functions ..
00055       REAL               CLANGE, SLAMCH
00056       EXTERNAL           CLANGE, SLAMCH
00057 *     ..
00058 *     .. External Subroutines ..
00059       EXTERNAL           CGEMM, CGGBAK, CGGBAL, CLACPY
00060 *     ..
00061 *     .. Intrinsic Functions ..
00062       INTRINSIC          ABS, AIMAG, MAX, REAL
00063 *     ..
00064 *     .. Statement Functions ..
00065       REAL               CABS1
00066 *     ..
00067 *     .. Statement Function definitions ..
00068       CABS1( CDUM ) = ABS( REAL( CDUM ) ) + ABS( AIMAG( CDUM ) )
00069 *     ..
00070 *     .. Executable Statements ..
00071 *
00072       LMAX( 1 ) = 0
00073       LMAX( 2 ) = 0
00074       LMAX( 3 ) = 0
00075       LMAX( 4 ) = 0
00076       NINFO = 0
00077       KNT = 0
00078       RMAX = ZERO
00079 *
00080       EPS = SLAMCH( 'Precision' )
00081 *
00082    10 CONTINUE
00083       READ( NIN, FMT = * )N, M
00084       IF( N.EQ.0 )
00085      $   GO TO 100
00086 *
00087       DO 20 I = 1, N
00088          READ( NIN, FMT = * )( A( I, J ), J = 1, N )
00089    20 CONTINUE
00090 *
00091       DO 30 I = 1, N
00092          READ( NIN, FMT = * )( B( I, J ), J = 1, N )
00093    30 CONTINUE
00094 *
00095       DO 40 I = 1, N
00096          READ( NIN, FMT = * )( VL( I, J ), J = 1, M )
00097    40 CONTINUE
00098 *
00099       DO 50 I = 1, N
00100          READ( NIN, FMT = * )( VR( I, J ), J = 1, M )
00101    50 CONTINUE
00102 *
00103       KNT = KNT + 1
00104 *
00105       ANORM = CLANGE( 'M', N, N, A, LDA, RWORK )
00106       BNORM = CLANGE( 'M', N, N, B, LDB, RWORK )
00107 *
00108       CALL CLACPY( 'FULL', N, N, A, LDA, AF, LDA )
00109       CALL CLACPY( 'FULL', N, N, B, LDB, BF, LDB )
00110 *
00111       CALL CGGBAL( 'B', N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE,
00112      $             RWORK, INFO )
00113       IF( INFO.NE.0 ) THEN
00114          NINFO = NINFO + 1
00115          LMAX( 1 ) = KNT
00116       END IF
00117 *
00118       CALL CLACPY( 'FULL', N, M, VL, LDVL, VLF, LDVL )
00119       CALL CLACPY( 'FULL', N, M, VR, LDVR, VRF, LDVR )
00120 *
00121       CALL CGGBAK( 'B', 'L', N, ILO, IHI, LSCALE, RSCALE, M, VL, LDVL,
00122      $             INFO )
00123       IF( INFO.NE.0 ) THEN
00124          NINFO = NINFO + 1
00125          LMAX( 2 ) = KNT
00126       END IF
00127 *
00128       CALL CGGBAK( 'B', 'R', N, ILO, IHI, LSCALE, RSCALE, M, VR, LDVR,
00129      $             INFO )
00130       IF( INFO.NE.0 ) THEN
00131          NINFO = NINFO + 1
00132          LMAX( 3 ) = KNT
00133       END IF
00134 *
00135 *     Test of CGGBAK
00136 *
00137 *     Check tilde(VL)'*A*tilde(VR) - VL'*tilde(A)*VR
00138 *     where tilde(A) denotes the transformed matrix.
00139 *
00140       CALL CGEMM( 'N', 'N', N, M, N, CONE, AF, LDA, VR, LDVR, CZERO,
00141      $            WORK, LDWORK )
00142       CALL CGEMM( 'C', 'N', M, M, N, CONE, VL, LDVL, WORK, LDWORK,
00143      $            CZERO, E, LDE )
00144 *
00145       CALL CGEMM( 'N', 'N', N, M, N, CONE, A, LDA, VRF, LDVR, CZERO,
00146      $            WORK, LDWORK )
00147       CALL CGEMM( 'C', 'N', M, M, N, CONE, VLF, LDVL, WORK, LDWORK,
00148      $            CZERO, F, LDF )
00149 *
00150       VMAX = ZERO
00151       DO 70 J = 1, M
00152          DO 60 I = 1, M
00153             VMAX = MAX( VMAX, CABS1( E( I, J )-F( I, J ) ) )
00154    60    CONTINUE
00155    70 CONTINUE
00156       VMAX = VMAX / ( EPS*MAX( ANORM, BNORM ) )
00157       IF( VMAX.GT.RMAX ) THEN
00158          LMAX( 4 ) = KNT
00159          RMAX = VMAX
00160       END IF
00161 *
00162 *     Check tilde(VL)'*B*tilde(VR) - VL'*tilde(B)*VR
00163 *
00164       CALL CGEMM( 'N', 'N', N, M, N, CONE, BF, LDB, VR, LDVR, CZERO,
00165      $            WORK, LDWORK )
00166       CALL CGEMM( 'C', 'N', M, M, N, CONE, VL, LDVL, WORK, LDWORK,
00167      $            CZERO, E, LDE )
00168 *
00169       CALL CGEMM( 'n', 'n', N, M, N, CONE, B, LDB, VRF, LDVR, CZERO,
00170      $            WORK, LDWORK )
00171       CALL CGEMM( 'C', 'N', M, M, N, CONE, VLF, LDVL, WORK, LDWORK,
00172      $            CZERO, F, LDF )
00173 *
00174       VMAX = ZERO
00175       DO 90 J = 1, M
00176          DO 80 I = 1, M
00177             VMAX = MAX( VMAX, CABS1( E( I, J )-F( I, J ) ) )
00178    80    CONTINUE
00179    90 CONTINUE
00180       VMAX = VMAX / ( EPS*MAX( ANORM, BNORM ) )
00181       IF( VMAX.GT.RMAX ) THEN
00182          LMAX( 4 ) = KNT
00183          RMAX = VMAX
00184       END IF
00185 *
00186       GO TO 10
00187 *
00188   100 CONTINUE
00189 *
00190       WRITE( NOUT, FMT = 9999 )
00191  9999 FORMAT( 1X, '.. test output of CGGBAK .. ' )
00192 *
00193       WRITE( NOUT, FMT = 9998 )RMAX
00194  9998 FORMAT( ' value of largest test error                  =', E12.3 )
00195       WRITE( NOUT, FMT = 9997 )LMAX( 1 )
00196  9997 FORMAT( ' example number where CGGBAL info is not 0    =', I4 )
00197       WRITE( NOUT, FMT = 9996 )LMAX( 2 )
00198  9996 FORMAT( ' example number where CGGBAK(L) info is not 0 =', I4 )
00199       WRITE( NOUT, FMT = 9995 )LMAX( 3 )
00200  9995 FORMAT( ' example number where CGGBAK(R) info is not 0 =', I4 )
00201       WRITE( NOUT, FMT = 9994 )LMAX( 4 )
00202  9994 FORMAT( ' example number having largest error          =', I4 )
00203       WRITE( NOUT, FMT = 9992 )NINFO
00204  9992 FORMAT( ' number of examples where info is not 0       =', I4 )
00205       WRITE( NOUT, FMT = 9991 )KNT
00206  9991 FORMAT( ' total number of examples tested              =', I4 )
00207 *
00208       RETURN
00209 *
00210 *     End of CCHKGK
00211 *
00212       END
 All Files Functions