LAPACK 3.3.1
Linear Algebra PACKage

VARIANTS/cholesky/TOP/dpotrf.f

Go to the documentation of this file.
00001       SUBROUTINE DPOTRF ( UPLO, N, A, LDA, INFO )
00002 *
00003 *  -- LAPACK routine (version 3.1) --
00004 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00005 *     March 2008
00006 *
00007 *     .. Scalar Arguments ..
00008       CHARACTER          UPLO
00009       INTEGER            INFO, LDA, N
00010 *     ..
00011 *     .. Array Arguments ..
00012       DOUBLE PRECISION   A( LDA, * )
00013 *     ..
00014 *
00015 *  Purpose
00016 *  =======
00017 *
00018 *  DPOTRF computes the Cholesky factorization of a real symmetric
00019 *  positive definite matrix A.
00020 *
00021 *  The factorization has the form
00022 *     A = U**T * U,  if UPLO = 'U', or
00023 *     A = L  * L**T,  if UPLO = 'L',
00024 *  where U is an upper triangular matrix and L is lower triangular.
00025 *
00026 *  This is the top-looking block version of the algorithm, calling Level 3 BLAS.
00027 *
00028 *  Arguments
00029 *  =========
00030 *
00031 *  UPLO    (input) CHARACTER*1
00032 *          = 'U':  Upper triangle of A is stored;
00033 *          = 'L':  Lower triangle of A is stored.
00034 *
00035 *  N       (input) INTEGER
00036 *          The order of the matrix A.  N >= 0.
00037 *
00038 *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
00039 *          On entry, the symmetric matrix A.  If UPLO = 'U', the leading
00040 *          N-by-N upper triangular part of A contains the upper
00041 *          triangular part of the matrix A, and the strictly lower
00042 *          triangular part of A is not referenced.  If UPLO = 'L', the
00043 *          leading N-by-N lower triangular part of A contains the lower
00044 *          triangular part of the matrix A, and the strictly upper
00045 *          triangular part of A is not referenced.
00046 *
00047 *          On exit, if INFO = 0, the factor U or L from the Cholesky
00048 *          factorization A = U**T*U or A = L*L**T.
00049 *
00050 *  LDA     (input) INTEGER
00051 *          The leading dimension of the array A.  LDA >= max(1,N).
00052 *
00053 *  INFO    (output) INTEGER
00054 *          = 0:  successful exit
00055 *          < 0:  if INFO = -i, the i-th argument had an illegal value
00056 *          > 0:  if INFO = i, the leading minor of order i is not
00057 *                positive definite, and the factorization could not be
00058 *                completed.
00059 *
00060 *  =====================================================================
00061 *
00062 *     .. Parameters ..
00063       DOUBLE PRECISION   ONE
00064       PARAMETER          ( ONE = 1.0D+0 )
00065 *     ..
00066 *     .. Local Scalars ..
00067       LOGICAL            UPPER
00068       INTEGER            J, JB, NB
00069 *     ..
00070 *     .. External Functions ..
00071       LOGICAL            LSAME
00072       INTEGER            ILAENV
00073       EXTERNAL           LSAME, ILAENV
00074 *     ..
00075 *     .. External Subroutines ..
00076       EXTERNAL           DGEMM, DPOTF2, DSYRK, DTRSM, XERBLA
00077 *     ..
00078 *     .. Intrinsic Functions ..
00079       INTRINSIC          MAX, MIN
00080 *     ..
00081 *     .. Executable Statements ..
00082 *
00083 *     Test the input parameters.
00084 *
00085       INFO = 0
00086       UPPER = LSAME( UPLO, 'U' )
00087       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00088          INFO = -1
00089       ELSE IF( N.LT.0 ) THEN
00090          INFO = -2
00091       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
00092          INFO = -4
00093       END IF
00094       IF( INFO.NE.0 ) THEN
00095          CALL XERBLA( 'DPOTRF', -INFO )
00096          RETURN
00097       END IF
00098 *
00099 *     Quick return if possible
00100 *
00101       IF( N.EQ.0 )
00102      $   RETURN
00103 *
00104 *     Determine the block size for this environment.
00105 *
00106       NB = ILAENV( 1, 'DPOTRF', UPLO, N, -1, -1, -1 )
00107       IF( NB.LE.1 .OR. NB.GE.N ) THEN
00108 *
00109 *        Use unblocked code.
00110 *
00111          CALL DPOTF2( UPLO, N, A, LDA, INFO )
00112       ELSE
00113 *
00114 *        Use blocked code.
00115 *
00116          IF( UPPER ) THEN
00117 *
00118 *           Compute the Cholesky factorization A = U'*U.
00119 *
00120             DO 10 J = 1, N, NB
00121 
00122                JB = MIN( NB, N-J+1 )
00123 *
00124 *              Compute the current block.
00125 *
00126                CALL DTRSM( 'Left', 'Upper', 'Transpose', 'Non-unit',
00127      $                      J-1, JB, ONE, A( 1, 1 ), LDA,
00128      $                      A( 1, J ), LDA )
00129 
00130                CALL DSYRK( 'Upper', 'Transpose', JB, J-1, -ONE,
00131      $                      A( 1, J ), LDA, 
00132      $                      ONE, A( J, J ), LDA )
00133 *
00134 *              Update and factorize the current diagonal block and test
00135 *              for non-positive-definiteness.
00136 *
00137                CALL DPOTF2( 'Upper', JB, A( J, J ), LDA, INFO )
00138                IF( INFO.NE.0 )
00139      $            GO TO 30
00140 
00141    10       CONTINUE
00142 *
00143          ELSE
00144 *
00145 *           Compute the Cholesky factorization A = L*L'.
00146 *
00147             DO 20 J = 1, N, NB
00148 
00149                JB = MIN( NB, N-J+1 )
00150 *
00151 *              Compute the current block.
00152 *
00153                CALL DTRSM( 'Right', 'Lower', 'Transpose', 'Non-unit',
00154      $                     JB, J-1, ONE, A( 1, 1 ), LDA,
00155      $                     A( J, 1 ), LDA )
00156 
00157                CALL DSYRK( 'Lower', 'No Transpose', JB, J-1, 
00158      $                     -ONE, A( J, 1 ), LDA, 
00159      $                     ONE, A( J, J ), LDA )
00160                
00161 *
00162 *              Update and factorize the current diagonal block and test
00163 *              for non-positive-definiteness.
00164 *
00165                CALL DPOTF2( 'Lower', JB, A( J, J ), LDA, INFO )
00166                IF( INFO.NE.0 )
00167      $            GO TO 30
00168 
00169    20       CONTINUE
00170          END IF
00171       END IF
00172       GO TO 40
00173 *
00174    30 CONTINUE
00175       INFO = INFO + J - 1
00176 *
00177    40 CONTINUE
00178       RETURN
00179 *
00180 *     End of DPOTRF
00181 *
00182       END
 All Files Functions