LAPACK  3.4.0
LAPACK: Linear Algebra PACKage
sqrt05.f
Go to the documentation of this file.
00001 *> \brief \b SQRT05
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 SQRT05(M,N,L,NB,RESULT)
00012 * 
00013 *       .. Scalar Arguments ..
00014 *       INTEGER LWORK, M, N, L, NB, LDT
00015 *       .. Return values ..
00016 *       REAL RESULT(6)
00017 *  
00018 *
00019 *> \par Purpose:
00020 *  =============
00021 *>
00022 *> \verbatim
00023 *>
00024 *> SQRT05 tests STPQRT and STPMQRT.
00025 *> \endverbatim
00026 *
00027 *  Arguments:
00028 *  ==========
00029 *
00030 *> \param[in] M
00031 *> \verbatim
00032 *>          M is INTEGER
00033 *>          Number of rows in lower part of the test matrix.
00034 *> \endverbatim
00035 *>
00036 *> \param[in] N
00037 *> \verbatim
00038 *>          N is INTEGER
00039 *>          Number of columns in test matrix.
00040 *> \endverbatim
00041 *>
00042 *> \param[in] L
00043 *> \verbatim
00044 *>          L is INTEGER
00045 *>          The number of rows of the upper trapezoidal part the
00046 *>          lower test matrix.  0 <= L <= M.
00047 *> \endverbatim
00048 *>          
00049 *> \param[in] NB
00050 *> \verbatim
00051 *>          NB is INTEGER
00052 *>          Block size of test matrix.  NB <= N.
00053 *> \endverbatim
00054 *>
00055 *> \param[out] RESULT
00056 *> \verbatim
00057 *>          RESULT is REAL array, dimension (6)
00058 *>          Results of each of the six tests below.
00059 *>
00060 *>          RESULT(1) = | A - Q R |
00061 *>          RESULT(2) = | I - Q^H Q |
00062 *>          RESULT(3) = | Q C - Q C |
00063 *>          RESULT(4) = | Q^H C - Q^H C |
00064 *>          RESULT(5) = | C Q - C Q | 
00065 *>          RESULT(6) = | C Q^H - C Q^H |
00066 *> \endverbatim
00067 *
00068 *  Authors:
00069 *  ========
00070 *
00071 *> \author Univ. of Tennessee 
00072 *> \author Univ. of California Berkeley 
00073 *> \author Univ. of Colorado Denver 
00074 *> \author NAG Ltd. 
00075 *
00076 *> \date November 2011
00077 *
00078 *> \ingroup single_lin
00079 *
00080 *  =====================================================================
00081       SUBROUTINE SQRT05(M,N,L,NB,RESULT)
00082 *
00083 *  -- LAPACK test routine (version 3.4.0) --
00084 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00085 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00086 *     November 2011
00087 *
00088 *     .. Scalar Arguments ..
00089       INTEGER LWORK, M, N, L, NB, LDT
00090 *     .. Return values ..
00091       REAL RESULT(6)
00092 *
00093 *  =====================================================================
00094 *      
00095 *     ..
00096 *     .. Local allocatable arrays 
00097       REAL, ALLOCATABLE :: AF(:,:), Q(:,:),
00098      $  R(:,:), RWORK(:), WORK( : ), T(:,:), 
00099      $  CF(:,:), DF(:,:), A(:,:), C(:,:), D(:,:)
00100 *
00101 *     .. Parameters ..
00102       REAL ZERO, ONE
00103       PARAMETER( ZERO = 0.0, ONE = 1.0 )
00104 *     ..
00105 *     .. Local Scalars ..
00106       INTEGER INFO, J, K, M2
00107       REAL   ANORM, EPS, RESID, CNORM, DNORM
00108 *     ..
00109 *     .. Local Arrays ..
00110       INTEGER            ISEED( 4 )
00111 *     ..
00112 *     .. External Functions ..
00113       REAL SLAMCH 
00114       REAL SLANGE, SLANSY
00115       LOGICAL  LSAME
00116       EXTERNAL SLAMCH, SLANGE, SLANSY, LSAME
00117 *     ..
00118 *     .. Data statements ..
00119       DATA ISEED / 1988, 1989, 1990, 1991 /
00120 *      
00121       EPS = SLAMCH( 'Epsilon' )
00122       K = N
00123       M2 = M+N
00124       LWORK = M2*M2*NB
00125 *
00126 *     Dynamically allocate all arrays
00127 *
00128       ALLOCATE(A(M2,N),AF(M2,N),Q(M2,M2),R(M2,M2),RWORK(M2),
00129      $           WORK(LWORK),T(NB,N),C(M2,N),CF(M2,N), 
00130      $           D(N,M2),DF(N,M2) )
00131 *
00132 *     Put random stuff into A
00133 *
00134       LDT=NB
00135       CALL SLASET( 'Full', M2, N, ZERO, ZERO, A, M2 )
00136       DO J=1,N
00137          CALL SLARNV( 2, ISEED, J, A( 1, J ) )
00138          CALL SLARNV( 2, ISEED, M-L, A( MIN(N+M,N+1), J ) )
00139          CALL SLARNV( 2, ISEED, MIN(J,L), A( MIN(N+M,N+M-L+1), J ) )
00140       END DO
00141 *
00142 *     Copy the matrix A to the array AF.
00143 *
00144       CALL SLACPY( 'Full', M2, N, A, M2, AF, M2 )
00145 *
00146 *     Factor the matrix A in the array AF.
00147 *
00148       CALL STPQRT( M,N,L,NB,AF,M2,AF(N+1,1),M2,T,LDT,WORK,INFO)
00149 *
00150 *     Generate the (M+N)-by-(M+N) matrix Q by applying H to I
00151 *
00152       CALL SLASET( 'Full', M2, M2, ZERO, ONE, Q, M2 )
00153       CALL SGEMQRT( 'R', 'N', M2, M2, K, NB, AF, M2, T, LDT, Q, M2,
00154      $              WORK, INFO )
00155 *
00156 *     Copy R
00157 *
00158       CALL SLASET( 'Full', M2, N, ZERO, ZERO, R, M2 )
00159       CALL SLACPY( 'Upper', M2, N, AF, M2, R, M2 )
00160 *
00161 *     Compute |R - Q'*A| / |A| and store in RESULT(1)
00162 *
00163       CALL SGEMM( 'T', 'N', M2, N, M2, -ONE, Q, M2, A, M2, ONE, R, M2 )
00164       ANORM = SLANGE( '1', M2, N, A, M2, RWORK )
00165       RESID = SLANGE( '1', M2, N, R, M2, RWORK )
00166       IF( ANORM.GT.ZERO ) THEN
00167          RESULT( 1 ) = RESID / (EPS*ANORM*MAX(1,M2))
00168       ELSE
00169          RESULT( 1 ) = ZERO
00170       END IF
00171 *
00172 *     Compute |I - Q'*Q| and store in RESULT(2)
00173 *
00174       CALL SLASET( 'Full', M2, M2, ZERO, ONE, R, M2 )
00175       CALL SSYRK( 'U', 'C', M2, M2, -ONE, Q, M2, ONE, 
00176      $            R, M2 )
00177       RESID = SLANSY( '1', 'Upper', M2, R, M2, RWORK )
00178       RESULT( 2 ) = RESID / (EPS*MAX(1,M2))
00179 *
00180 *     Generate random m-by-n matrix C and a copy CF
00181 *
00182       DO J=1,N
00183          CALL SLARNV( 2, ISEED, M2, C( 1, J ) )
00184       END DO
00185       CNORM = SLANGE( '1', M2, N, C, M2, RWORK)
00186       CALL SLACPY( 'Full', M2, N, C, M2, CF, M2 )
00187 *
00188 *     Apply Q to C as Q*C
00189 *
00190       CALL STPMQRT( 'L','N', M,N,K,L,NB,AF(N+1,1),M2,T,LDT,CF,M2,
00191      $               CF(N+1,1),M2,WORK,INFO)
00192 *
00193 *     Compute |Q*C - Q*C| / |C|
00194 *
00195       CALL SGEMM( 'N', 'N', M2, N, M2, -ONE, Q, M2, C, M2, ONE, CF, M2 )
00196       RESID = SLANGE( '1', M2, N, CF, M2, RWORK )
00197       IF( CNORM.GT.ZERO ) THEN
00198          RESULT( 3 ) = RESID / (EPS*MAX(1,M2)*CNORM)
00199       ELSE
00200          RESULT( 3 ) = ZERO
00201       END IF
00202 *
00203 *     Copy C into CF again
00204 *
00205       CALL SLACPY( 'Full', M2, N, C, M2, CF, M2 )
00206 *
00207 *     Apply Q to C as QT*C
00208 *
00209       CALL STPMQRT( 'L','T',M,N,K,L,NB,AF(N+1,1),M2,T,LDT,CF,M2,
00210      $              CF(N+1,1),M2,WORK,INFO) 
00211 *
00212 *     Compute |QT*C - QT*C| / |C|
00213 *
00214       CALL SGEMM('T','N',M2,N,M2,-ONE,Q,M2,C,M2,ONE,CF,M2)
00215       RESID = SLANGE( '1', M2, N, CF, M2, RWORK )
00216       IF( CNORM.GT.ZERO ) THEN
00217          RESULT( 4 ) = RESID / (EPS*MAX(1,M2)*CNORM)
00218       ELSE
00219          RESULT( 4 ) = ZERO
00220       END IF     
00221 *
00222 *     Generate random n-by-m matrix D and a copy DF
00223 *
00224       DO J=1,M2
00225          CALL SLARNV( 2, ISEED, N, D( 1, J ) )
00226       END DO
00227       DNORM = SLANGE( '1', N, M2, D, N, RWORK)
00228       CALL SLACPY( 'Full', N, M2, D, N, DF, N )
00229 *
00230 *     Apply Q to D as D*Q
00231 *
00232       CALL STPMQRT('R','N',N,M,N,L,NB,AF(N+1,1),M2,T,LDT,DF,N,
00233      $             DF(1,N+1),N,WORK,INFO)
00234 *
00235 *     Compute |D*Q - D*Q| / |D|
00236 *
00237       CALL SGEMM('N','N',N,M2,M2,-ONE,D,N,Q,M2,ONE,DF,N)
00238       RESID = SLANGE('1',N, M2,DF,N,RWORK )
00239       IF( CNORM.GT.ZERO ) THEN
00240          RESULT( 5 ) = RESID / (EPS*MAX(1,M2)*DNORM)
00241       ELSE
00242          RESULT( 5 ) = ZERO
00243       END IF
00244 *
00245 *     Copy D into DF again
00246 *
00247       CALL SLACPY('Full',N,M2,D,N,DF,N )
00248 *
00249 *     Apply Q to D as D*QT
00250 *
00251       CALL STPMQRT('R','T',N,M,N,L,NB,AF(N+1,1),M2,T,LDT,DF,N,
00252      $             DF(1,N+1),N,WORK,INFO)     
00253        
00254 *
00255 *     Compute |D*QT - D*QT| / |D|
00256 *
00257       CALL SGEMM( 'N', 'T', N, M2, M2, -ONE, D, N, Q, M2, ONE, DF, N )
00258       RESID = SLANGE( '1', N, M2, DF, N, RWORK )
00259       IF( CNORM.GT.ZERO ) THEN
00260          RESULT( 6 ) = RESID / (EPS*MAX(1,M2)*DNORM)
00261       ELSE
00262          RESULT( 6 ) = ZERO
00263       END IF
00264 *
00265 *     Deallocate all arrays
00266 *
00267       DEALLOCATE ( A, AF, Q, R, RWORK, WORK, T, C, D, CF, DF)
00268       RETURN
00269       END
00270 
 All Files Functions