KTH framework for Nek5000 toolboxes; testing version  0.0.1
dpbtf2.f
Go to the documentation of this file.
1  SUBROUTINE dpbtf2( UPLO, N, KD, AB, LDAB, INFO )
2 *
3 * -- LAPACK routine (version 3.0) --
4 * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
5 * Courant Institute, Argonne National Lab, and Rice University
6 * February 29, 1992
7 *
8 * .. Scalar Arguments ..
9  CHARACTER UPLO
10  INTEGER INFO, KD, LDAB, N
11 * ..
12 * .. Array Arguments ..
13  DOUBLE PRECISION AB( LDAB, * )
14 * ..
15 *
16 * Purpose
17 * =======
18 *
19 * DPBTF2 computes the Cholesky factorization of a real symmetric
20 * positive definite band matrix A.
21 *
22 * The factorization has the form
23 * A = U' * U , if UPLO = 'U', or
24 * A = L * L', if UPLO = 'L',
25 * where U is an upper triangular matrix, U' is the transpose of U, and
26 * L is lower triangular.
27 *
28 * This is the unblocked version of the algorithm, calling Level 2 BLAS.
29 *
30 * Arguments
31 * =========
32 *
33 * UPLO (input) CHARACTER*1
34 * Specifies whether the upper or lower triangular part of the
35 * symmetric matrix A is stored:
36 * = 'U': Upper triangular
37 * = 'L': Lower triangular
38 *
39 * N (input) INTEGER
40 * The order of the matrix A. N >= 0.
41 *
42 * KD (input) INTEGER
43 * The number of super-diagonals of the matrix A if UPLO = 'U',
44 * or the number of sub-diagonals if UPLO = 'L'. KD >= 0.
45 *
46 * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
47 * On entry, the upper or lower triangle of the symmetric band
48 * matrix A, stored in the first KD+1 rows of the array. The
49 * j-th column of A is stored in the j-th column of the array AB
50 * as follows:
51 * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
52 * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
53 *
54 * On exit, if INFO = 0, the triangular factor U or L from the
55 * Cholesky factorization A = U'*U or A = L*L' of the band
56 * matrix A, in the same storage format as A.
57 *
58 * LDAB (input) INTEGER
59 * The leading dimension of the array AB. LDAB >= KD+1.
60 *
61 * INFO (output) INTEGER
62 * = 0: successful exit
63 * < 0: if INFO = -k, the k-th argument had an illegal value
64 * > 0: if INFO = k, the leading minor of order k is not
65 * positive definite, and the factorization could not be
66 * completed.
67 *
68 * Further Details
69 * ===============
70 *
71 * The band storage scheme is illustrated by the following example, when
72 * N = 6, KD = 2, and UPLO = 'U':
73 *
74 * On entry: On exit:
75 *
76 * * * a13 a24 a35 a46 * * u13 u24 u35 u46
77 * * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
78 * a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
79 *
80 * Similarly, if UPLO = 'L' the format of A is as follows:
81 *
82 * On entry: On exit:
83 *
84 * a11 a22 a33 a44 a55 a66 l11 l22 l33 l44 l55 l66
85 * a21 a32 a43 a54 a65 * l21 l32 l43 l54 l65 *
86 * a31 a42 a53 a64 * * l31 l42 l53 l64 * *
87 *
88 * Array elements marked * are not used by the routine.
89 *
90 * =====================================================================
91 *
92 * .. Parameters ..
93  DOUBLE PRECISION ONE, ZERO
94  parameter( one = 1.0d+0, zero = 0.0d+0 )
95 * ..
96 * .. Local Scalars ..
97  LOGICAL UPPER
98  INTEGER J, KLD, KN
99  DOUBLE PRECISION AJJ
100 * ..
101 * .. External Functions ..
102  LOGICAL LSAME
103  EXTERNAL lsame
104 * ..
105 * .. External Subroutines ..
106  EXTERNAL dscal, dsyr, xerbla
107 * ..
108 * .. Intrinsic Functions ..
109  INTRINSIC max, min, sqrt
110 * ..
111 * .. Executable Statements ..
112 *
113 * Test the input parameters.
114 *
115  info = 0
116  upper = lsame( uplo, 'U' )
117  IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
118  info = -1
119  ELSE IF( n.LT.0 ) THEN
120  info = -2
121  ELSE IF( kd.LT.0 ) THEN
122  info = -3
123  ELSE IF( ldab.LT.kd+1 ) THEN
124  info = -5
125  END IF
126  IF( info.NE.0 ) THEN
127  CALL xerbla( 'DPBTF2', -info )
128  RETURN
129  END IF
130 *
131 * Quick return if possible
132 *
133  IF( n.EQ.0 )
134  $ RETURN
135 *
136  kld = max( 1, ldab-1 )
137 *
138  IF( upper ) THEN
139 *
140 * Compute the Cholesky factorization A = U'*U.
141 *
142  DO 10 j = 1, n
143 *
144 * Compute U(J,J) and test for non-positive-definiteness.
145 *
146  ajj = ab( kd+1, j )
147  IF( ajj.LE.zero )
148  $ GO TO 30
149  ajj = sqrt( ajj )
150  ab( kd+1, j ) = ajj
151 *
152 * Compute elements J+1:J+KN of row J and update the
153 * trailing submatrix within the band.
154 *
155  kn = min( kd, n-j )
156  IF( kn.GT.0 ) THEN
157  CALL dscal( kn, one / ajj, ab( kd, j+1 ), kld )
158  CALL dsyr( 'Upper', kn, -one, ab( kd, j+1 ), kld,
159  $ ab( kd+1, j+1 ), kld )
160  END IF
161  10 CONTINUE
162  ELSE
163 *
164 * Compute the Cholesky factorization A = L*L'.
165 *
166  DO 20 j = 1, n
167 *
168 * Compute L(J,J) and test for non-positive-definiteness.
169 *
170  ajj = ab( 1, j )
171  IF( ajj.LE.zero )
172  $ GO TO 30
173  ajj = sqrt( ajj )
174  ab( 1, j ) = ajj
175 *
176 * Compute elements J+1:J+KN of column J and update the
177 * trailing submatrix within the band.
178 *
179  kn = min( kd, n-j )
180  IF( kn.GT.0 ) THEN
181  CALL dscal( kn, one / ajj, ab( 2, j ), 1 )
182  CALL dsyr( 'Lower', kn, -one, ab( 2, j ), 1,
183  $ ab( 1, j+1 ), kld )
184  END IF
185  20 CONTINUE
186  END IF
187  RETURN
188 *
189  30 CONTINUE
190  info = j
191  RETURN
192 *
193 * End of DPBTF2
194 *
195  END
subroutine dpbtf2(UPLO, N, KD, AB, LDAB, INFO)
Definition: dpbtf2.f:2
subroutine dscal(n, da, dx, incx)
Definition: dscal.f:2
subroutine dsyr(UPLO, N, ALPHA, X, INCX, A, LDA)
Definition: dsyr.f:2
subroutine xerbla(SRNAME, INFO)
Definition: xerbla.f:2