LAPACK 3.3.0
|
00001 SUBROUTINE CQRT01P( M, N, A, AF, Q, R, LDA, TAU, WORK, LWORK, 00002 $ RWORK, RESULT ) 00003 * 00004 * -- LAPACK test routine (version 3.1) -- 00005 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. 00006 * June 2010 00007 * 00008 * .. Scalar Arguments .. 00009 INTEGER LDA, LWORK, M, N 00010 * .. 00011 * .. Array Arguments .. 00012 REAL RESULT( * ), RWORK( * ) 00013 COMPLEX A( LDA, * ), AF( LDA, * ), Q( LDA, * ), 00014 $ R( LDA, * ), TAU( * ), WORK( LWORK ) 00015 * .. 00016 * 00017 * Purpose 00018 * ======= 00019 * 00020 * CQRT01P tests CGEQRFP, which computes the QR factorization of an m-by-n 00021 * matrix A, and partially tests CUNGQR which forms the m-by-m 00022 * orthogonal matrix Q. 00023 * 00024 * CQRT01P compares R with Q'*A, and checks that Q is orthogonal. 00025 * 00026 * Arguments 00027 * ========= 00028 * 00029 * M (input) INTEGER 00030 * The number of rows of the matrix A. M >= 0. 00031 * 00032 * N (input) INTEGER 00033 * The number of columns of the matrix A. N >= 0. 00034 * 00035 * A (input) COMPLEX array, dimension (LDA,N) 00036 * The m-by-n matrix A. 00037 * 00038 * AF (output) COMPLEX array, dimension (LDA,N) 00039 * Details of the QR factorization of A, as returned by CGEQRFP. 00040 * See CGEQRFP for further details. 00041 * 00042 * Q (output) COMPLEX array, dimension (LDA,M) 00043 * The m-by-m orthogonal matrix Q. 00044 * 00045 * R (workspace) COMPLEX array, dimension (LDA,max(M,N)) 00046 * 00047 * LDA (input) INTEGER 00048 * The leading dimension of the arrays A, AF, Q and R. 00049 * LDA >= max(M,N). 00050 * 00051 * TAU (output) COMPLEX array, dimension (min(M,N)) 00052 * The scalar factors of the elementary reflectors, as returned 00053 * by CGEQRFP. 00054 * 00055 * WORK (workspace) COMPLEX array, dimension (LWORK) 00056 * 00057 * LWORK (input) INTEGER 00058 * The dimension of the array WORK. 00059 * 00060 * RWORK (workspace) REAL array, dimension (M) 00061 * 00062 * RESULT (output) REAL array, dimension (2) 00063 * The test ratios: 00064 * RESULT(1) = norm( R - Q'*A ) / ( M * norm(A) * EPS ) 00065 * RESULT(2) = norm( I - Q'*Q ) / ( M * EPS ) 00066 * 00067 * ===================================================================== 00068 * 00069 * .. Parameters .. 00070 REAL ZERO, ONE 00071 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00072 COMPLEX ROGUE 00073 PARAMETER ( ROGUE = ( -1.0E+10, -1.0E+10 ) ) 00074 * .. 00075 * .. Local Scalars .. 00076 INTEGER INFO, MINMN 00077 REAL ANORM, EPS, RESID 00078 * .. 00079 * .. External Functions .. 00080 REAL CLANGE, CLANSY, SLAMCH 00081 EXTERNAL CLANGE, CLANSY, SLAMCH 00082 * .. 00083 * .. External Subroutines .. 00084 EXTERNAL CGEMM, CGEQRFP, CHERK, CLACPY, CLASET, CUNGQR 00085 * .. 00086 * .. Intrinsic Functions .. 00087 INTRINSIC CMPLX, MAX, MIN, REAL 00088 * .. 00089 * .. Scalars in Common .. 00090 CHARACTER*32 SRNAMT 00091 * .. 00092 * .. Common blocks .. 00093 COMMON / SRNAMC / SRNAMT 00094 * .. 00095 * .. Executable Statements .. 00096 * 00097 MINMN = MIN( M, N ) 00098 EPS = SLAMCH( 'Epsilon' ) 00099 * 00100 * Copy the matrix A to the array AF. 00101 * 00102 CALL CLACPY( 'Full', M, N, A, LDA, AF, LDA ) 00103 * 00104 * Factorize the matrix A in the array AF. 00105 * 00106 SRNAMT = 'CGEQRFP' 00107 CALL CGEQRFP( M, N, AF, LDA, TAU, WORK, LWORK, INFO ) 00108 * 00109 * Copy details of Q 00110 * 00111 CALL CLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA ) 00112 CALL CLACPY( 'Lower', M-1, N, AF( 2, 1 ), LDA, Q( 2, 1 ), LDA ) 00113 * 00114 * Generate the m-by-m matrix Q 00115 * 00116 SRNAMT = 'CUNGQR' 00117 CALL CUNGQR( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO ) 00118 * 00119 * Copy R 00120 * 00121 CALL CLASET( 'Full', M, N, CMPLX( ZERO ), CMPLX( ZERO ), R, LDA ) 00122 CALL CLACPY( 'Upper', M, N, AF, LDA, R, LDA ) 00123 * 00124 * Compute R - Q'*A 00125 * 00126 CALL CGEMM( 'Conjugate transpose', 'No transpose', M, N, M, 00127 $ CMPLX( -ONE ), Q, LDA, A, LDA, CMPLX( ONE ), R, LDA ) 00128 * 00129 * Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) . 00130 * 00131 ANORM = CLANGE( '1', M, N, A, LDA, RWORK ) 00132 RESID = CLANGE( '1', M, N, R, LDA, RWORK ) 00133 IF( ANORM.GT.ZERO ) THEN 00134 RESULT( 1 ) = ( ( RESID / REAL( MAX( 1, M ) ) ) / ANORM ) / EPS 00135 ELSE 00136 RESULT( 1 ) = ZERO 00137 END IF 00138 * 00139 * Compute I - Q'*Q 00140 * 00141 CALL CLASET( 'Full', M, M, CMPLX( ZERO ), CMPLX( ONE ), R, LDA ) 00142 CALL CHERK( 'Upper', 'Conjugate transpose', M, M, -ONE, Q, LDA, 00143 $ ONE, R, LDA ) 00144 * 00145 * Compute norm( I - Q'*Q ) / ( M * EPS ) . 00146 * 00147 RESID = CLANSY( '1', 'Upper', M, R, LDA, RWORK ) 00148 * 00149 RESULT( 2 ) = ( RESID / REAL( MAX( 1, M ) ) ) / EPS 00150 * 00151 RETURN 00152 * 00153 * End of CQRT01P 00154 * 00155 END