LAPACK 3.3.1
Linear Algebra PACKage
|
00001 SUBROUTINE SQLT01( M, N, A, AF, Q, L, 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 * November 2006 00007 * 00008 * .. Scalar Arguments .. 00009 INTEGER LDA, LWORK, M, N 00010 * .. 00011 * .. Array Arguments .. 00012 REAL A( LDA, * ), AF( LDA, * ), L( LDA, * ), 00013 $ Q( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ), 00014 $ WORK( LWORK ) 00015 * .. 00016 * 00017 * Purpose 00018 * ======= 00019 * 00020 * SQLT01 tests SGEQLF, which computes the QL factorization of an m-by-n 00021 * matrix A, and partially tests SORGQL which forms the m-by-m 00022 * orthogonal matrix Q. 00023 * 00024 * SQLT01 compares L 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) REAL array, dimension (LDA,N) 00036 * The m-by-n matrix A. 00037 * 00038 * AF (output) REAL array, dimension (LDA,N) 00039 * Details of the QL factorization of A, as returned by SGEQLF. 00040 * See SGEQLF for further details. 00041 * 00042 * Q (output) REAL array, dimension (LDA,M) 00043 * The m-by-m orthogonal matrix Q. 00044 * 00045 * L (workspace) REAL 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) REAL array, dimension (min(M,N)) 00052 * The scalar factors of the elementary reflectors, as returned 00053 * by SGEQLF. 00054 * 00055 * WORK (workspace) REAL 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( L - 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 REAL ROGUE 00073 PARAMETER ( ROGUE = -1.0E+10 ) 00074 * .. 00075 * .. Local Scalars .. 00076 INTEGER INFO, MINMN 00077 REAL ANORM, EPS, RESID 00078 * .. 00079 * .. External Functions .. 00080 REAL SLAMCH, SLANGE, SLANSY 00081 EXTERNAL SLAMCH, SLANGE, SLANSY 00082 * .. 00083 * .. External Subroutines .. 00084 EXTERNAL SGEMM, SGEQLF, SLACPY, SLASET, SORGQL, SSYRK 00085 * .. 00086 * .. Intrinsic Functions .. 00087 INTRINSIC 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 SLACPY( 'Full', M, N, A, LDA, AF, LDA ) 00103 * 00104 * Factorize the matrix A in the array AF. 00105 * 00106 SRNAMT = 'SGEQLF' 00107 CALL SGEQLF( M, N, AF, LDA, TAU, WORK, LWORK, INFO ) 00108 * 00109 * Copy details of Q 00110 * 00111 CALL SLASET( 'Full', M, M, ROGUE, ROGUE, Q, LDA ) 00112 IF( M.GE.N ) THEN 00113 IF( N.LT.M .AND. N.GT.0 ) 00114 $ CALL SLACPY( 'Full', M-N, N, AF, LDA, Q( 1, M-N+1 ), LDA ) 00115 IF( N.GT.1 ) 00116 $ CALL SLACPY( 'Upper', N-1, N-1, AF( M-N+1, 2 ), LDA, 00117 $ Q( M-N+1, M-N+2 ), LDA ) 00118 ELSE 00119 IF( M.GT.1 ) 00120 $ CALL SLACPY( 'Upper', M-1, M-1, AF( 1, N-M+2 ), LDA, 00121 $ Q( 1, 2 ), LDA ) 00122 END IF 00123 * 00124 * Generate the m-by-m matrix Q 00125 * 00126 SRNAMT = 'SORGQL' 00127 CALL SORGQL( M, M, MINMN, Q, LDA, TAU, WORK, LWORK, INFO ) 00128 * 00129 * Copy L 00130 * 00131 CALL SLASET( 'Full', M, N, ZERO, ZERO, L, LDA ) 00132 IF( M.GE.N ) THEN 00133 IF( N.GT.0 ) 00134 $ CALL SLACPY( 'Lower', N, N, AF( M-N+1, 1 ), LDA, 00135 $ L( M-N+1, 1 ), LDA ) 00136 ELSE 00137 IF( N.GT.M .AND. M.GT.0 ) 00138 $ CALL SLACPY( 'Full', M, N-M, AF, LDA, L, LDA ) 00139 IF( M.GT.0 ) 00140 $ CALL SLACPY( 'Lower', M, M, AF( 1, N-M+1 ), LDA, 00141 $ L( 1, N-M+1 ), LDA ) 00142 END IF 00143 * 00144 * Compute L - Q'*A 00145 * 00146 CALL SGEMM( 'Transpose', 'No transpose', M, N, M, -ONE, Q, LDA, A, 00147 $ LDA, ONE, L, LDA ) 00148 * 00149 * Compute norm( L - Q'*A ) / ( M * norm(A) * EPS ) . 00150 * 00151 ANORM = SLANGE( '1', M, N, A, LDA, RWORK ) 00152 RESID = SLANGE( '1', M, N, L, LDA, RWORK ) 00153 IF( ANORM.GT.ZERO ) THEN 00154 RESULT( 1 ) = ( ( RESID / REAL( MAX( 1, M ) ) ) / ANORM ) / EPS 00155 ELSE 00156 RESULT( 1 ) = ZERO 00157 END IF 00158 * 00159 * Compute I - Q'*Q 00160 * 00161 CALL SLASET( 'Full', M, M, ZERO, ONE, L, LDA ) 00162 CALL SSYRK( 'Upper', 'Transpose', M, M, -ONE, Q, LDA, ONE, L, 00163 $ LDA ) 00164 * 00165 * Compute norm( I - Q'*Q ) / ( M * EPS ) . 00166 * 00167 RESID = SLANSY( '1', 'Upper', M, L, LDA, RWORK ) 00168 * 00169 RESULT( 2 ) = ( RESID / REAL( MAX( 1, M ) ) ) / EPS 00170 * 00171 RETURN 00172 * 00173 * End of SQLT01 00174 * 00175 END