![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SPOT01 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 SPOT01( UPLO, N, A, LDA, AFAC, LDAFAC, RWORK, RESID ) 00012 * 00013 * .. Scalar Arguments .. 00014 * CHARACTER UPLO 00015 * INTEGER LDA, LDAFAC, N 00016 * REAL RESID 00017 * .. 00018 * .. Array Arguments .. 00019 * REAL A( LDA, * ), AFAC( LDAFAC, * ), RWORK( * ) 00020 * .. 00021 * 00022 * 00023 *> \par Purpose: 00024 * ============= 00025 *> 00026 *> \verbatim 00027 *> 00028 *> SPOT01 reconstructs a symmetric positive definite matrix A from 00029 *> its L*L' or U'*U factorization and computes the residual 00030 *> norm( L*L' - A ) / ( N * norm(A) * EPS ) or 00031 *> norm( U'*U - A ) / ( N * norm(A) * EPS ), 00032 *> where EPS is the machine epsilon. 00033 *> \endverbatim 00034 * 00035 * Arguments: 00036 * ========== 00037 * 00038 *> \param[in] UPLO 00039 *> \verbatim 00040 *> UPLO is CHARACTER*1 00041 *> Specifies whether the upper or lower triangular part of the 00042 *> symmetric matrix A is stored: 00043 *> = 'U': Upper triangular 00044 *> = 'L': Lower triangular 00045 *> \endverbatim 00046 *> 00047 *> \param[in] N 00048 *> \verbatim 00049 *> N is INTEGER 00050 *> The number of rows and columns of the matrix A. N >= 0. 00051 *> \endverbatim 00052 *> 00053 *> \param[in] A 00054 *> \verbatim 00055 *> A is REAL array, dimension (LDA,N) 00056 *> The original symmetric matrix A. 00057 *> \endverbatim 00058 *> 00059 *> \param[in] LDA 00060 *> \verbatim 00061 *> LDA is INTEGER 00062 *> The leading dimension of the array A. LDA >= max(1,N) 00063 *> \endverbatim 00064 *> 00065 *> \param[in,out] AFAC 00066 *> \verbatim 00067 *> AFAC is REAL array, dimension (LDAFAC,N) 00068 *> On entry, the factor L or U from the L*L' or U'*U 00069 *> factorization of A. 00070 *> Overwritten with the reconstructed matrix, and then with the 00071 *> difference L*L' - A (or U'*U - A). 00072 *> \endverbatim 00073 *> 00074 *> \param[in] LDAFAC 00075 *> \verbatim 00076 *> LDAFAC is INTEGER 00077 *> The leading dimension of the array AFAC. LDAFAC >= max(1,N). 00078 *> \endverbatim 00079 *> 00080 *> \param[out] RWORK 00081 *> \verbatim 00082 *> RWORK is REAL array, dimension (N) 00083 *> \endverbatim 00084 *> 00085 *> \param[out] RESID 00086 *> \verbatim 00087 *> RESID is REAL 00088 *> If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS ) 00089 *> If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS ) 00090 *> \endverbatim 00091 * 00092 * Authors: 00093 * ======== 00094 * 00095 *> \author Univ. of Tennessee 00096 *> \author Univ. of California Berkeley 00097 *> \author Univ. of Colorado Denver 00098 *> \author NAG Ltd. 00099 * 00100 *> \date November 2011 00101 * 00102 *> \ingroup single_lin 00103 * 00104 * ===================================================================== 00105 SUBROUTINE SPOT01( UPLO, N, A, LDA, AFAC, LDAFAC, RWORK, RESID ) 00106 * 00107 * -- LAPACK test routine (version 3.4.0) -- 00108 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00109 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00110 * November 2011 00111 * 00112 * .. Scalar Arguments .. 00113 CHARACTER UPLO 00114 INTEGER LDA, LDAFAC, N 00115 REAL RESID 00116 * .. 00117 * .. Array Arguments .. 00118 REAL A( LDA, * ), AFAC( LDAFAC, * ), RWORK( * ) 00119 * .. 00120 * 00121 * ===================================================================== 00122 * 00123 * .. Parameters .. 00124 REAL ZERO, ONE 00125 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 ) 00126 * .. 00127 * .. Local Scalars .. 00128 INTEGER I, J, K 00129 REAL ANORM, EPS, T 00130 * .. 00131 * .. External Functions .. 00132 LOGICAL LSAME 00133 REAL SDOT, SLAMCH, SLANSY 00134 EXTERNAL LSAME, SDOT, SLAMCH, SLANSY 00135 * .. 00136 * .. External Subroutines .. 00137 EXTERNAL SSCAL, SSYR, STRMV 00138 * .. 00139 * .. Intrinsic Functions .. 00140 INTRINSIC REAL 00141 * .. 00142 * .. Executable Statements .. 00143 * 00144 * Quick exit if N = 0. 00145 * 00146 IF( N.LE.0 ) THEN 00147 RESID = ZERO 00148 RETURN 00149 END IF 00150 * 00151 * Exit with RESID = 1/EPS if ANORM = 0. 00152 * 00153 EPS = SLAMCH( 'Epsilon' ) 00154 ANORM = SLANSY( '1', UPLO, N, A, LDA, RWORK ) 00155 IF( ANORM.LE.ZERO ) THEN 00156 RESID = ONE / EPS 00157 RETURN 00158 END IF 00159 * 00160 * Compute the product U'*U, overwriting U. 00161 * 00162 IF( LSAME( UPLO, 'U' ) ) THEN 00163 DO 10 K = N, 1, -1 00164 * 00165 * Compute the (K,K) element of the result. 00166 * 00167 T = SDOT( K, AFAC( 1, K ), 1, AFAC( 1, K ), 1 ) 00168 AFAC( K, K ) = T 00169 * 00170 * Compute the rest of column K. 00171 * 00172 CALL STRMV( 'Upper', 'Transpose', 'Non-unit', K-1, AFAC, 00173 $ LDAFAC, AFAC( 1, K ), 1 ) 00174 * 00175 10 CONTINUE 00176 * 00177 * Compute the product L*L', overwriting L. 00178 * 00179 ELSE 00180 DO 20 K = N, 1, -1 00181 * 00182 * Add a multiple of column K of the factor L to each of 00183 * columns K+1 through N. 00184 * 00185 IF( K+1.LE.N ) 00186 $ CALL SSYR( 'Lower', N-K, ONE, AFAC( K+1, K ), 1, 00187 $ AFAC( K+1, K+1 ), LDAFAC ) 00188 * 00189 * Scale column K by the diagonal element. 00190 * 00191 T = AFAC( K, K ) 00192 CALL SSCAL( N-K+1, T, AFAC( K, K ), 1 ) 00193 * 00194 20 CONTINUE 00195 END IF 00196 * 00197 * Compute the difference L*L' - A (or U'*U - A). 00198 * 00199 IF( LSAME( UPLO, 'U' ) ) THEN 00200 DO 40 J = 1, N 00201 DO 30 I = 1, J 00202 AFAC( I, J ) = AFAC( I, J ) - A( I, J ) 00203 30 CONTINUE 00204 40 CONTINUE 00205 ELSE 00206 DO 60 J = 1, N 00207 DO 50 I = J, N 00208 AFAC( I, J ) = AFAC( I, J ) - A( I, J ) 00209 50 CONTINUE 00210 60 CONTINUE 00211 END IF 00212 * 00213 * Compute norm( L*U - A ) / ( N * norm(A) * EPS ) 00214 * 00215 RESID = SLANSY( '1', UPLO, N, AFAC, LDAFAC, RWORK ) 00216 * 00217 RESID = ( ( RESID / REAL( N ) ) / ANORM ) / EPS 00218 * 00219 RETURN 00220 * 00221 * End of SPOT01 00222 * 00223 END