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