LAPACK 3.3.1
Linear Algebra PACKage

spbstf.f

Go to the documentation of this file.
00001       SUBROUTINE SPBSTF( UPLO, N, KD, AB, LDAB, INFO )
00002 *
00003 *  -- LAPACK routine (version 3.2) --
00004 *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
00005 *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
00006 *     November 2006
00007 *
00008 *     .. Scalar Arguments ..
00009       CHARACTER          UPLO
00010       INTEGER            INFO, KD, LDAB, N
00011 *     ..
00012 *     .. Array Arguments ..
00013       REAL               AB( LDAB, * )
00014 *     ..
00015 *
00016 *  Purpose
00017 *  =======
00018 *
00019 *  SPBSTF computes a split Cholesky factorization of a real
00020 *  symmetric positive definite band matrix A.
00021 *
00022 *  This routine is designed to be used in conjunction with SSBGST.
00023 *
00024 *  The factorization has the form  A = S**T*S  where S is a band matrix
00025 *  of the same bandwidth as A and the following structure:
00026 *
00027 *    S = ( U    )
00028 *        ( M  L )
00029 *
00030 *  where U is upper triangular of order m = (n+kd)/2, and L is lower
00031 *  triangular of order n-m.
00032 *
00033 *  Arguments
00034 *  =========
00035 *
00036 *  UPLO    (input) CHARACTER*1
00037 *          = 'U':  Upper triangle of A is stored;
00038 *          = 'L':  Lower triangle of A is stored.
00039 *
00040 *  N       (input) INTEGER
00041 *          The order of the matrix A.  N >= 0.
00042 *
00043 *  KD      (input) INTEGER
00044 *          The number of superdiagonals of the matrix A if UPLO = 'U',
00045 *          or the number of subdiagonals if UPLO = 'L'.  KD >= 0.
00046 *
00047 *  AB      (input/output) REAL array, dimension (LDAB,N)
00048 *          On entry, the upper or lower triangle of the symmetric band
00049 *          matrix A, stored in the first kd+1 rows of the array.  The
00050 *          j-th column of A is stored in the j-th column of the array AB
00051 *          as follows:
00052 *          if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
00053 *          if UPLO = 'L', AB(1+i-j,j)    = A(i,j) for j<=i<=min(n,j+kd).
00054 *
00055 *          On exit, if INFO = 0, the factor S from the split Cholesky
00056 *          factorization A = S**T*S. See Further Details.
00057 *
00058 *  LDAB    (input) INTEGER
00059 *          The leading dimension of the array AB.  LDAB >= KD+1.
00060 *
00061 *  INFO    (output) INTEGER
00062 *          = 0: successful exit
00063 *          < 0: if INFO = -i, the i-th argument had an illegal value
00064 *          > 0: if INFO = i, the factorization could not be completed,
00065 *               because the updated element a(i,i) was negative; the
00066 *               matrix A is not positive definite.
00067 *
00068 *  Further Details
00069 *  ===============
00070 *
00071 *  The band storage scheme is illustrated by the following example, when
00072 *  N = 7, KD = 2:
00073 *
00074 *  S = ( s11  s12  s13                     )
00075 *      (      s22  s23  s24                )
00076 *      (           s33  s34                )
00077 *      (                s44                )
00078 *      (           s53  s54  s55           )
00079 *      (                s64  s65  s66      )
00080 *      (                     s75  s76  s77 )
00081 *
00082 *  If UPLO = 'U', the array AB holds:
00083 *
00084 *  on entry:                          on exit:
00085 *
00086 *   *    *   a13  a24  a35  a46  a57   *    *   s13  s24  s53  s64  s75
00087 *   *   a12  a23  a34  a45  a56  a67   *   s12  s23  s34  s54  s65  s76
00088 *  a11  a22  a33  a44  a55  a66  a77  s11  s22  s33  s44  s55  s66  s77
00089 *
00090 *  If UPLO = 'L', the array AB holds:
00091 *
00092 *  on entry:                          on exit:
00093 *
00094 *  a11  a22  a33  a44  a55  a66  a77  s11  s22  s33  s44  s55  s66  s77
00095 *  a21  a32  a43  a54  a65  a76   *   s12  s23  s34  s54  s65  s76   *
00096 *  a31  a42  a53  a64  a64   *    *   s13  s24  s53  s64  s75   *    *
00097 *
00098 *  Array elements marked * are not used by the routine.
00099 *
00100 *  =====================================================================
00101 *
00102 *     .. Parameters ..
00103       REAL               ONE, ZERO
00104       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
00105 *     ..
00106 *     .. Local Scalars ..
00107       LOGICAL            UPPER
00108       INTEGER            J, KLD, KM, M
00109       REAL               AJJ
00110 *     ..
00111 *     .. External Functions ..
00112       LOGICAL            LSAME
00113       EXTERNAL           LSAME
00114 *     ..
00115 *     .. External Subroutines ..
00116       EXTERNAL           SSCAL, SSYR, XERBLA
00117 *     ..
00118 *     .. Intrinsic Functions ..
00119       INTRINSIC          MAX, MIN, SQRT
00120 *     ..
00121 *     .. Executable Statements ..
00122 *
00123 *     Test the input parameters.
00124 *
00125       INFO = 0
00126       UPPER = LSAME( UPLO, 'U' )
00127       IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
00128          INFO = -1
00129       ELSE IF( N.LT.0 ) THEN
00130          INFO = -2
00131       ELSE IF( KD.LT.0 ) THEN
00132          INFO = -3
00133       ELSE IF( LDAB.LT.KD+1 ) THEN
00134          INFO = -5
00135       END IF
00136       IF( INFO.NE.0 ) THEN
00137          CALL XERBLA( 'SPBSTF', -INFO )
00138          RETURN
00139       END IF
00140 *
00141 *     Quick return if possible
00142 *
00143       IF( N.EQ.0 )
00144      $   RETURN
00145 *
00146       KLD = MAX( 1, LDAB-1 )
00147 *
00148 *     Set the splitting point m.
00149 *
00150       M = ( N+KD ) / 2
00151 *
00152       IF( UPPER ) THEN
00153 *
00154 *        Factorize A(m+1:n,m+1:n) as L**T*L, and update A(1:m,1:m).
00155 *
00156          DO 10 J = N, M + 1, -1
00157 *
00158 *           Compute s(j,j) and test for non-positive-definiteness.
00159 *
00160             AJJ = AB( KD+1, J )
00161             IF( AJJ.LE.ZERO )
00162      $         GO TO 50
00163             AJJ = SQRT( AJJ )
00164             AB( KD+1, J ) = AJJ
00165             KM = MIN( J-1, KD )
00166 *
00167 *           Compute elements j-km:j-1 of the j-th column and update the
00168 *           the leading submatrix within the band.
00169 *
00170             CALL SSCAL( KM, ONE / AJJ, AB( KD+1-KM, J ), 1 )
00171             CALL SSYR( 'Upper', KM, -ONE, AB( KD+1-KM, J ), 1,
00172      $                 AB( KD+1, J-KM ), KLD )
00173    10    CONTINUE
00174 *
00175 *        Factorize the updated submatrix A(1:m,1:m) as U**T*U.
00176 *
00177          DO 20 J = 1, M
00178 *
00179 *           Compute s(j,j) and test for non-positive-definiteness.
00180 *
00181             AJJ = AB( KD+1, J )
00182             IF( AJJ.LE.ZERO )
00183      $         GO TO 50
00184             AJJ = SQRT( AJJ )
00185             AB( KD+1, J ) = AJJ
00186             KM = MIN( KD, M-J )
00187 *
00188 *           Compute elements j+1:j+km of the j-th row and update the
00189 *           trailing submatrix within the band.
00190 *
00191             IF( KM.GT.0 ) THEN
00192                CALL SSCAL( KM, ONE / AJJ, AB( KD, J+1 ), KLD )
00193                CALL SSYR( 'Upper', KM, -ONE, AB( KD, J+1 ), KLD,
00194      $                    AB( KD+1, J+1 ), KLD )
00195             END IF
00196    20    CONTINUE
00197       ELSE
00198 *
00199 *        Factorize A(m+1:n,m+1:n) as L**T*L, and update A(1:m,1:m).
00200 *
00201          DO 30 J = N, M + 1, -1
00202 *
00203 *           Compute s(j,j) and test for non-positive-definiteness.
00204 *
00205             AJJ = AB( 1, J )
00206             IF( AJJ.LE.ZERO )
00207      $         GO TO 50
00208             AJJ = SQRT( AJJ )
00209             AB( 1, J ) = AJJ
00210             KM = MIN( J-1, KD )
00211 *
00212 *           Compute elements j-km:j-1 of the j-th row and update the
00213 *           trailing submatrix within the band.
00214 *
00215             CALL SSCAL( KM, ONE / AJJ, AB( KM+1, J-KM ), KLD )
00216             CALL SSYR( 'Lower', KM, -ONE, AB( KM+1, J-KM ), KLD,
00217      $                 AB( 1, J-KM ), KLD )
00218    30    CONTINUE
00219 *
00220 *        Factorize the updated submatrix A(1:m,1:m) as U**T*U.
00221 *
00222          DO 40 J = 1, M
00223 *
00224 *           Compute s(j,j) and test for non-positive-definiteness.
00225 *
00226             AJJ = AB( 1, J )
00227             IF( AJJ.LE.ZERO )
00228      $         GO TO 50
00229             AJJ = SQRT( AJJ )
00230             AB( 1, J ) = AJJ
00231             KM = MIN( KD, M-J )
00232 *
00233 *           Compute elements j+1:j+km of the j-th column and update the
00234 *           trailing submatrix within the band.
00235 *
00236             IF( KM.GT.0 ) THEN
00237                CALL SSCAL( KM, ONE / AJJ, AB( 2, J ), 1 )
00238                CALL SSYR( 'Lower', KM, -ONE, AB( 2, J ), 1,
00239      $                    AB( 1, J+1 ), KLD )
00240             END IF
00241    40    CONTINUE
00242       END IF
00243       RETURN
00244 *
00245    50 CONTINUE
00246       INFO = J
00247       RETURN
00248 *
00249 *     End of SPBSTF
00250 *
00251       END
 All Files Functions