![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DPPT01 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 DPPT01( UPLO, N, A, AFAC, RWORK, RESID ) 00012 * 00013 * .. Scalar Arguments .. 00014 * CHARACTER UPLO 00015 * INTEGER N 00016 * DOUBLE PRECISION RESID 00017 * .. 00018 * .. Array Arguments .. 00019 * DOUBLE PRECISION A( * ), AFAC( * ), RWORK( * ) 00020 * .. 00021 * 00022 * 00023 *> \par Purpose: 00024 * ============= 00025 *> 00026 *> \verbatim 00027 *> 00028 *> DPPT01 reconstructs a symmetric positive definite packed matrix A 00029 *> from 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 DOUBLE PRECISION array, dimension (N*(N+1)/2) 00056 *> The original symmetric matrix A, stored as a packed 00057 *> triangular matrix. 00058 *> \endverbatim 00059 *> 00060 *> \param[in,out] AFAC 00061 *> \verbatim 00062 *> AFAC is DOUBLE PRECISION array, dimension (N*(N+1)/2) 00063 *> On entry, the factor L or U from the L*L' or U'*U 00064 *> factorization of A, stored as a packed triangular matrix. 00065 *> Overwritten with the reconstructed matrix, and then with the 00066 *> difference L*L' - A (or U'*U - A). 00067 *> \endverbatim 00068 *> 00069 *> \param[out] RWORK 00070 *> \verbatim 00071 *> RWORK is DOUBLE PRECISION array, dimension (N) 00072 *> \endverbatim 00073 *> 00074 *> \param[out] RESID 00075 *> \verbatim 00076 *> RESID is DOUBLE PRECISION 00077 *> If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS ) 00078 *> If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS ) 00079 *> \endverbatim 00080 * 00081 * Authors: 00082 * ======== 00083 * 00084 *> \author Univ. of Tennessee 00085 *> \author Univ. of California Berkeley 00086 *> \author Univ. of Colorado Denver 00087 *> \author NAG Ltd. 00088 * 00089 *> \date November 2011 00090 * 00091 *> \ingroup double_lin 00092 * 00093 * ===================================================================== 00094 SUBROUTINE DPPT01( UPLO, N, A, AFAC, RWORK, RESID ) 00095 * 00096 * -- LAPACK test routine (version 3.4.0) -- 00097 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00098 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00099 * November 2011 00100 * 00101 * .. Scalar Arguments .. 00102 CHARACTER UPLO 00103 INTEGER N 00104 DOUBLE PRECISION RESID 00105 * .. 00106 * .. Array Arguments .. 00107 DOUBLE PRECISION A( * ), AFAC( * ), RWORK( * ) 00108 * .. 00109 * 00110 * ===================================================================== 00111 * 00112 * .. Parameters .. 00113 DOUBLE PRECISION ZERO, ONE 00114 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 ) 00115 * .. 00116 * .. Local Scalars .. 00117 INTEGER I, K, KC, NPP 00118 DOUBLE PRECISION ANORM, EPS, T 00119 * .. 00120 * .. External Functions .. 00121 LOGICAL LSAME 00122 DOUBLE PRECISION DDOT, DLAMCH, DLANSP 00123 EXTERNAL LSAME, DDOT, DLAMCH, DLANSP 00124 * .. 00125 * .. External Subroutines .. 00126 EXTERNAL DSCAL, DSPR, DTPMV 00127 * .. 00128 * .. Intrinsic Functions .. 00129 INTRINSIC DBLE 00130 * .. 00131 * .. Executable Statements .. 00132 * 00133 * Quick exit if N = 0 00134 * 00135 IF( N.LE.0 ) THEN 00136 RESID = ZERO 00137 RETURN 00138 END IF 00139 * 00140 * Exit with RESID = 1/EPS if ANORM = 0. 00141 * 00142 EPS = DLAMCH( 'Epsilon' ) 00143 ANORM = DLANSP( '1', UPLO, N, A, RWORK ) 00144 IF( ANORM.LE.ZERO ) THEN 00145 RESID = ONE / EPS 00146 RETURN 00147 END IF 00148 * 00149 * Compute the product U'*U, overwriting U. 00150 * 00151 IF( LSAME( UPLO, 'U' ) ) THEN 00152 KC = ( N*( N-1 ) ) / 2 + 1 00153 DO 10 K = N, 1, -1 00154 * 00155 * Compute the (K,K) element of the result. 00156 * 00157 T = DDOT( K, AFAC( KC ), 1, AFAC( KC ), 1 ) 00158 AFAC( KC+K-1 ) = T 00159 * 00160 * Compute the rest of column K. 00161 * 00162 IF( K.GT.1 ) THEN 00163 CALL DTPMV( 'Upper', 'Transpose', 'Non-unit', K-1, AFAC, 00164 $ AFAC( KC ), 1 ) 00165 KC = KC - ( K-1 ) 00166 END IF 00167 10 CONTINUE 00168 * 00169 * Compute the product L*L', overwriting L. 00170 * 00171 ELSE 00172 KC = ( N*( N+1 ) ) / 2 00173 DO 20 K = N, 1, -1 00174 * 00175 * Add a multiple of column K of the factor L to each of 00176 * columns K+1 through N. 00177 * 00178 IF( K.LT.N ) 00179 $ CALL DSPR( 'Lower', N-K, ONE, AFAC( KC+1 ), 1, 00180 $ AFAC( KC+N-K+1 ) ) 00181 * 00182 * Scale column K by the diagonal element. 00183 * 00184 T = AFAC( KC ) 00185 CALL DSCAL( N-K+1, T, AFAC( KC ), 1 ) 00186 * 00187 KC = KC - ( N-K+2 ) 00188 20 CONTINUE 00189 END IF 00190 * 00191 * Compute the difference L*L' - A (or U'*U - A). 00192 * 00193 NPP = N*( N+1 ) / 2 00194 DO 30 I = 1, NPP 00195 AFAC( I ) = AFAC( I ) - A( I ) 00196 30 CONTINUE 00197 * 00198 * Compute norm( L*U - A ) / ( N * norm(A) * EPS ) 00199 * 00200 RESID = DLANSP( '1', UPLO, N, AFAC, RWORK ) 00201 * 00202 RESID = ( ( RESID / DBLE( N ) ) / ANORM ) / EPS 00203 * 00204 RETURN 00205 * 00206 * End of DPPT01 00207 * 00208 END