LAPACK  3.4.1
LAPACK: Linear Algebra PACKage
sgrqts.f
Go to the documentation of this file.
00001 *> \brief \b SGRQTS
00002 *
00003 *  =========== DOCUMENTATION ===========
00004 *
00005 * Online html documentation available at 
00006 *            http://www.netlib.org/lapack/explore-html/ 
00007 *
00008 *  Definition:
00009 *  ===========
00010 *
00011 *       SUBROUTINE SGRQTS( M, P, N, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
00012 *                          BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
00013 * 
00014 *       .. Scalar Arguments ..
00015 *       INTEGER            LDA, LDB, LWORK, M, P, N
00016 *       ..
00017 *       .. Array Arguments ..
00018 *       REAL               A( LDA, * ), AF( LDA, * ), R( LDA, * ),
00019 *      $                   Q( LDA, * ),
00020 *      $                   B( LDB, * ), BF( LDB, * ), T( LDB, * ),
00021 *      $                   Z( LDB, * ), BWK( LDB, * ),
00022 *      $                   TAUA( * ), TAUB( * ),
00023 *      $                   RESULT( 4 ), RWORK( * ), WORK( LWORK )
00024 *       ..
00025 *  
00026 *
00027 *> \par Purpose:
00028 *  =============
00029 *>
00030 *> \verbatim
00031 *>
00032 *> SGRQTS tests SGGRQF, which computes the GRQ factorization of an
00033 *> M-by-N matrix A and a P-by-N matrix B: A = R*Q and B = Z*T*Q.
00034 *> \endverbatim
00035 *
00036 *  Arguments:
00037 *  ==========
00038 *
00039 *> \param[in] M
00040 *> \verbatim
00041 *>          M is INTEGER
00042 *>          The number of rows of the matrix A.  M >= 0.
00043 *> \endverbatim
00044 *>
00045 *> \param[in] P
00046 *> \verbatim
00047 *>          P is INTEGER
00048 *>          The number of rows of the matrix B.  P >= 0.
00049 *> \endverbatim
00050 *>
00051 *> \param[in] N
00052 *> \verbatim
00053 *>          N is INTEGER
00054 *>          The number of columns of the matrices A and B.  N >= 0.
00055 *> \endverbatim
00056 *>
00057 *> \param[in] A
00058 *> \verbatim
00059 *>          A is REAL array, dimension (LDA,N)
00060 *>          The M-by-N matrix A.
00061 *> \endverbatim
00062 *>
00063 *> \param[out] AF
00064 *> \verbatim
00065 *>          AF is REAL array, dimension (LDA,N)
00066 *>          Details of the GRQ factorization of A and B, as returned
00067 *>          by SGGRQF, see SGGRQF for further details.
00068 *> \endverbatim
00069 *>
00070 *> \param[out] Q
00071 *> \verbatim
00072 *>          Q is REAL array, dimension (LDA,N)
00073 *>          The N-by-N orthogonal matrix Q.
00074 *> \endverbatim
00075 *>
00076 *> \param[out] R
00077 *> \verbatim
00078 *>          R is REAL array, dimension (LDA,MAX(M,N))
00079 *> \endverbatim
00080 *>
00081 *> \param[in] LDA
00082 *> \verbatim
00083 *>          LDA is INTEGER
00084 *>          The leading dimension of the arrays A, AF, R and Q.
00085 *>          LDA >= max(M,N).
00086 *> \endverbatim
00087 *>
00088 *> \param[out] TAUA
00089 *> \verbatim
00090 *>          TAUA is REAL array, dimension (min(M,N))
00091 *>          The scalar factors of the elementary reflectors, as returned
00092 *>          by SGGQRC.
00093 *> \endverbatim
00094 *>
00095 *> \param[in] B
00096 *> \verbatim
00097 *>          B is REAL array, dimension (LDB,N)
00098 *>          On entry, the P-by-N matrix A.
00099 *> \endverbatim
00100 *>
00101 *> \param[out] BF
00102 *> \verbatim
00103 *>          BF is REAL array, dimension (LDB,N)
00104 *>          Details of the GQR factorization of A and B, as returned
00105 *>          by SGGRQF, see SGGRQF for further details.
00106 *> \endverbatim
00107 *>
00108 *> \param[out] Z
00109 *> \verbatim
00110 *>          Z is REAL array, dimension (LDB,P)
00111 *>          The P-by-P orthogonal matrix Z.
00112 *> \endverbatim
00113 *>
00114 *> \param[out] T
00115 *> \verbatim
00116 *>          T is REAL array, dimension (LDB,max(P,N))
00117 *> \endverbatim
00118 *>
00119 *> \param[out] BWK
00120 *> \verbatim
00121 *>          BWK is REAL array, dimension (LDB,N)
00122 *> \endverbatim
00123 *>
00124 *> \param[in] LDB
00125 *> \verbatim
00126 *>          LDB is INTEGER
00127 *>          The leading dimension of the arrays B, BF, Z and T.
00128 *>          LDB >= max(P,N).
00129 *> \endverbatim
00130 *>
00131 *> \param[out] TAUB
00132 *> \verbatim
00133 *>          TAUB is REAL array, dimension (min(P,N))
00134 *>          The scalar factors of the elementary reflectors, as returned
00135 *>          by SGGRQF.
00136 *> \endverbatim
00137 *>
00138 *> \param[out] WORK
00139 *> \verbatim
00140 *>          WORK is REAL array, dimension (LWORK)
00141 *> \endverbatim
00142 *>
00143 *> \param[in] LWORK
00144 *> \verbatim
00145 *>          LWORK is INTEGER
00146 *>          The dimension of the array WORK, LWORK >= max(M,P,N)**2.
00147 *> \endverbatim
00148 *>
00149 *> \param[out] RWORK
00150 *> \verbatim
00151 *>          RWORK is REAL array, dimension (M)
00152 *> \endverbatim
00153 *>
00154 *> \param[out] RESULT
00155 *> \verbatim
00156 *>          RESULT is REAL array, dimension (4)
00157 *>          The test ratios:
00158 *>            RESULT(1) = norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP)
00159 *>            RESULT(2) = norm( T*Q - Z'*B ) / (MAX(P,N)*norm(B)*ULP)
00160 *>            RESULT(3) = norm( I - Q'*Q ) / ( N*ULP )
00161 *>            RESULT(4) = norm( I - Z'*Z ) / ( P*ULP )
00162 *> \endverbatim
00163 *
00164 *  Authors:
00165 *  ========
00166 *
00167 *> \author Univ. of Tennessee 
00168 *> \author Univ. of California Berkeley 
00169 *> \author Univ. of Colorado Denver 
00170 *> \author NAG Ltd. 
00171 *
00172 *> \date November 2011
00173 *
00174 *> \ingroup single_eig
00175 *
00176 *  =====================================================================
00177       SUBROUTINE SGRQTS( M, P, N, A, AF, Q, R, LDA, TAUA, B, BF, Z, T,
00178      $                   BWK, LDB, TAUB, WORK, LWORK, RWORK, RESULT )
00179 *
00180 *  -- LAPACK test routine (version 3.4.0) --
00181 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00182 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00183 *     November 2011
00184 *
00185 *     .. Scalar Arguments ..
00186       INTEGER            LDA, LDB, LWORK, M, P, N
00187 *     ..
00188 *     .. Array Arguments ..
00189       REAL               A( LDA, * ), AF( LDA, * ), R( LDA, * ),
00190      $                   Q( LDA, * ),
00191      $                   B( LDB, * ), BF( LDB, * ), T( LDB, * ),
00192      $                   Z( LDB, * ), BWK( LDB, * ),
00193      $                   TAUA( * ), TAUB( * ),
00194      $                   RESULT( 4 ), RWORK( * ), WORK( LWORK )
00195 *     ..
00196 *
00197 *  =====================================================================
00198 *
00199 *     .. Parameters ..
00200       REAL               ZERO, ONE
00201       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00202       REAL               ROGUE
00203       PARAMETER          ( ROGUE = -1.0E+10 )
00204 *     ..
00205 *     .. Local Scalars ..
00206       INTEGER            INFO
00207       REAL               ANORM, BNORM, ULP, UNFL, RESID
00208 *     ..
00209 *     .. External Functions ..
00210       REAL               SLAMCH, SLANGE, SLANSY
00211       EXTERNAL           SLAMCH, SLANGE, SLANSY
00212 *     ..
00213 *     .. External Subroutines ..
00214       EXTERNAL           SGEMM, SGGRQF, SLACPY, SLASET, SORGQR,
00215      $                   SORGRQ, SSYRK
00216 *     ..
00217 *     .. Intrinsic Functions ..
00218       INTRINSIC          MAX, MIN, REAL
00219 *     ..
00220 *     .. Executable Statements ..
00221 *
00222       ULP = SLAMCH( 'Precision' )
00223       UNFL = SLAMCH( 'Safe minimum' )
00224 *
00225 *     Copy the matrix A to the array AF.
00226 *
00227       CALL SLACPY( 'Full', M, N, A, LDA, AF, LDA )
00228       CALL SLACPY( 'Full', P, N, B, LDB, BF, LDB )
00229 *
00230       ANORM = MAX( SLANGE( '1', M, N, A, LDA, RWORK ), UNFL )
00231       BNORM = MAX( SLANGE( '1', P, N, B, LDB, RWORK ), UNFL )
00232 *
00233 *     Factorize the matrices A and B in the arrays AF and BF.
00234 *
00235       CALL SGGRQF( M, P, N, AF, LDA, TAUA, BF, LDB, TAUB, WORK,
00236      $             LWORK, INFO )
00237 *
00238 *     Generate the N-by-N matrix Q
00239 *
00240       CALL SLASET( 'Full', N, N, ROGUE, ROGUE, Q, LDA )
00241       IF( M.LE.N ) THEN
00242          IF( M.GT.0 .AND. M.LT.N )
00243      $      CALL SLACPY( 'Full', M, N-M, AF, LDA, Q( N-M+1, 1 ), LDA )
00244          IF( M.GT.1 )
00245      $      CALL SLACPY( 'Lower', M-1, M-1, AF( 2, N-M+1 ), LDA,
00246      $                   Q( N-M+2, N-M+1 ), LDA )
00247       ELSE
00248          IF( N.GT.1 )
00249      $      CALL SLACPY( 'Lower', N-1, N-1, AF( M-N+2, 1 ), LDA,
00250      $                   Q( 2, 1 ), LDA )
00251       END IF
00252       CALL SORGRQ( N, N, MIN( M, N ), Q, LDA, TAUA, WORK, LWORK, INFO )
00253 *
00254 *     Generate the P-by-P matrix Z
00255 *
00256       CALL SLASET( 'Full', P, P, ROGUE, ROGUE, Z, LDB )
00257       IF( P.GT.1 )
00258      $   CALL SLACPY( 'Lower', P-1, N, BF( 2,1 ), LDB, Z( 2,1 ), LDB )
00259       CALL SORGQR( P, P, MIN( P,N ), Z, LDB, TAUB, WORK, LWORK, INFO )
00260 *
00261 *     Copy R
00262 *
00263       CALL SLASET( 'Full', M, N, ZERO, ZERO, R, LDA )
00264       IF( M.LE.N )THEN
00265          CALL SLACPY( 'Upper', M, M, AF( 1, N-M+1 ), LDA, R( 1, N-M+1 ),
00266      $                LDA )
00267       ELSE
00268          CALL SLACPY( 'Full', M-N, N, AF, LDA, R, LDA )
00269          CALL SLACPY( 'Upper', N, N, AF( M-N+1, 1 ), LDA, R( M-N+1, 1 ),
00270      $                LDA )
00271       END IF
00272 *
00273 *     Copy T
00274 *
00275       CALL SLASET( 'Full', P, N, ZERO, ZERO, T, LDB )
00276       CALL SLACPY( 'Upper', P, N, BF, LDB, T, LDB )
00277 *
00278 *     Compute R - A*Q'
00279 *
00280       CALL SGEMM( 'No transpose', 'Transpose', M, N, N, -ONE, A, LDA, Q,
00281      $            LDA, ONE, R, LDA )
00282 *
00283 *     Compute norm( R - A*Q' ) / ( MAX(M,N)*norm(A)*ULP ) .
00284 *
00285       RESID = SLANGE( '1', M, N, R, LDA, RWORK )
00286       IF( ANORM.GT.ZERO ) THEN
00287          RESULT( 1 ) = ( ( RESID / REAL(MAX(1,M,N) ) ) / ANORM ) / ULP
00288       ELSE
00289          RESULT( 1 ) = ZERO
00290       END IF
00291 *
00292 *     Compute T*Q - Z'*B
00293 *
00294       CALL SGEMM( 'Transpose', 'No transpose', P, N, P, ONE, Z, LDB, B,
00295      $            LDB, ZERO, BWK, LDB )
00296       CALL SGEMM( 'No transpose', 'No transpose', P, N, N, ONE, T, LDB,
00297      $            Q, LDA, -ONE, BWK, LDB )
00298 *
00299 *     Compute norm( T*Q - Z'*B ) / ( MAX(P,N)*norm(A)*ULP ) .
00300 *
00301       RESID = SLANGE( '1', P, N, BWK, LDB, RWORK )
00302       IF( BNORM.GT.ZERO ) THEN
00303          RESULT( 2 ) = ( ( RESID / REAL( MAX( 1,P,M ) ) )/BNORM ) / ULP
00304       ELSE
00305          RESULT( 2 ) = ZERO
00306       END IF
00307 *
00308 *     Compute I - Q*Q'
00309 *
00310       CALL SLASET( 'Full', N, N, ZERO, ONE, R, LDA )
00311       CALL SSYRK( 'Upper', 'No Transpose', N, N, -ONE, Q, LDA, ONE, R,
00312      $            LDA )
00313 *
00314 *     Compute norm( I - Q'*Q ) / ( N * ULP ) .
00315 *
00316       RESID = SLANSY( '1', 'Upper', N, R, LDA, RWORK )
00317       RESULT( 3 ) = ( RESID / REAL( MAX( 1,N ) ) ) / ULP
00318 *
00319 *     Compute I - Z'*Z
00320 *
00321       CALL SLASET( 'Full', P, P, ZERO, ONE, T, LDB )
00322       CALL SSYRK( 'Upper', 'Transpose', P, P, -ONE, Z, LDB, ONE, T,
00323      $            LDB )
00324 *
00325 *     Compute norm( I - Z'*Z ) / ( P*ULP ) .
00326 *
00327       RESID = SLANSY( '1', 'Upper', P, T, LDB, RWORK )
00328       RESULT( 4 ) = ( RESID / REAL( MAX( 1,P ) ) ) / ULP
00329 *
00330       RETURN
00331 *
00332 *     End of SGRQTS
00333 *
00334       END
 All Files Functions