2
SUBROUTINE DCHEX (R, LDR, P, K, L, Z, LDZ, NZ, C, S, JOB)
3
C***BEGIN PROLOGUE DCHEX
4
C***PURPOSE Update the Cholesky factorization A=TRANS(R)*R of a
5
C positive definite matrix A of order P under diagonal
6
C permutations of the form TRANS(E)*A*E, where E is a
8
C***LIBRARY SLATEC (LINPACK)
10
C***TYPE DOUBLE PRECISION (SCHEX-S, DCHEX-D, CCHEX-C)
11
C***KEYWORDS CHOLESKY DECOMPOSITION, EXCHANGE, LINEAR ALGEBRA, LINPACK,
12
C MATRIX, POSITIVE DEFINITE
13
C***AUTHOR Stewart, G. W., (U. of Maryland)
16
C DCHEX updates the Cholesky factorization
20
C of a positive definite matrix A of order P under diagonal
21
C permutations of the form
25
C where E is a permutation matrix. Specifically, given
26
C an upper triangular matrix R and a permutation matrix
27
C E (which is specified by K, L, and JOB), DCHEX determines
28
C an orthogonal matrix U such that
32
C where RR is upper triangular. At the users option, the
33
C transformation U will be multiplied into the array Z.
34
C If A = TRANS(X)*X, so that R is the triangular part of the
35
C QR factorization of X, then RR is the triangular part of the
36
C QR factorization of X*E, i.e. X with its columns permuted.
37
C For a less terse description of what DCHEX does and how
38
C it may be applied, see the LINPACK guide.
40
C The matrix Q is determined as the product U(L-K)*...*U(1)
41
C of plane rotations of the form
47
C where C(I) is double precision. The rows these rotations operate
48
C on are described below.
50
C There are two types of permutations, which are determined
51
C by the value of JOB.
53
C 1. Right circular shift (JOB = 1).
55
C The columns are rearranged in the following order.
57
C 1,...,K-1,L,K,K+1,...,L-1,L+1,...,P.
59
C U is the product of L-K rotations U(I), where U(I)
60
C acts in the (L-I,L-I+1)-plane.
62
C 2. Left circular shift (JOB = 2).
63
C The columns are rearranged in the following order
65
C 1,...,K-1,K+1,K+2,...,L,K,L+1,...,P.
67
C U is the product of L-K rotations U(I), where U(I)
68
C acts in the (K+I-1,K+I)-plane.
72
C R DOUBLE PRECISION(LDR,P), where LDR .GE. P.
73
C R contains the upper triangular factor
74
C that is to be updated. Elements of R
75
C below the diagonal are not referenced.
78
C LDR is the leading dimension of the array R.
81
C P is the order of the matrix R.
84
C K is the first column to be permuted.
87
C L is the last column to be permuted.
88
C L must be strictly greater than K.
90
C Z DOUBLE PRECISION(LDZ,N)Z), where LDZ .GE. P.
91
C Z is an array of NZ P-vectors into which the
92
C transformation U is multiplied. Z is
93
C not referenced if NZ = 0.
96
C LDZ is the leading dimension of the array Z.
99
C NZ is the number of columns of the matrix Z.
102
C JOB determines the type of permutation.
103
C JOB = 1 right circular shift.
104
C JOB = 2 left circular shift.
108
C R contains the updated factor.
110
C Z contains the updated matrix Z.
112
C C DOUBLE PRECISION(P).
113
C C contains the cosines of the transforming rotations.
115
C S DOUBLE PRECISION(P).
116
C S contains the sines of the transforming rotations.
118
C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
119
C Stewart, LINPACK Users' Guide, SIAM, 1979.
120
C***ROUTINES CALLED DROTG
121
C***REVISION HISTORY (YYMMDD)
122
C 780814 DATE WRITTEN
123
C 890531 Changed all specific intrinsics to generic. (WRB)
124
C 890831 Modified array declarations. (WRB)
125
C 890831 REVISION DATE from Version 3.2
126
C 891214 Prologue converted to Version 4.0 format. (BAB)
127
C 900326 Removed duplicate information from DESCRIPTION section.
129
C 920501 Reformatted the REFERENCES section. (WRB)
130
C***END PROLOGUE DCHEX
131
INTEGER LDR,P,K,L,LDZ,NZ,JOB
132
DOUBLE PRECISION R(LDR,*),Z(LDZ,*),S(*)
133
DOUBLE PRECISION C(*)
135
INTEGER I,II,IL,IU,J,JJ,KM1,KP1,LMK,LM1
140
C***FIRST EXECUTABLE STATEMENT DCHEX
146
C PERFORM THE APPROPRIATE TASK.
150
C RIGHT CIRCULAR SHIFT.
154
C REORDER THE COLUMNS.
167
IF (K .EQ. 1) GO TO 60
174
C CALCULATE THE ROTATIONS.
178
CALL DROTG(S(I+1),T,C(I),S(I))
186
T = C(II)*R(I,J) + S(II)*R(I+1,J)
187
R(I+1,J) = C(II)*R(I+1,J) - S(II)*R(I,J)
192
C IF REQUIRED, APPLY THE TRANSFORMATIONS TO Z.
194
IF (NZ .LT. 1) GO TO 120
198
T = C(II)*Z(I,J) + S(II)*Z(I+1,J)
199
Z(I+1,J) = C(II)*Z(I+1,J) - S(II)*Z(I,J)
206
C LEFT CIRCULAR SHIFT
210
C REORDER THE COLUMNS
234
IF (J .EQ. K) GO TO 200
236
C APPLY THE ROTATIONS.
241
T = C(II)*R(I,J) + S(II)*R(I+1,J)
242
R(I+1,J) = C(II)*R(I+1,J) - S(II)*R(I,J)
246
IF (J .GE. L) GO TO 210
249
CALL DROTG(R(J,J),T,C(JJ),S(JJ))
253
C APPLY THE ROTATIONS TO Z.
255
IF (NZ .LT. 1) GO TO 250
259
T = C(II)*Z(I,J) + S(II)*Z(I+1,J)
260
Z(I+1,J) = C(II)*Z(I+1,J) - S(II)*Z(I,J)