2
SUBROUTINE SSPCO (AP, N, KPVT, RCOND, Z)
3
C***BEGIN PROLOGUE SSPCO
4
C***PURPOSE Factor a real symmetric matrix stored in packed form
5
C by elimination with symmetric pivoting and estimate the
6
C condition number of the matrix.
7
C***LIBRARY SLATEC (LINPACK)
9
C***TYPE SINGLE PRECISION (SSPCO-S, DSPCO-D, CHPCO-C, CSPCO-C)
10
C***KEYWORDS CONDITION NUMBER, LINEAR ALGEBRA, LINPACK,
11
C MATRIX FACTORIZATION, PACKED, SYMMETRIC
12
C***AUTHOR Moler, C. B., (U. of New Mexico)
15
C SSPCO factors a real symmetric matrix stored in packed
16
C form by elimination with symmetric pivoting and estimates
17
C the condition of the matrix.
19
C If RCOND is not needed, SSPFA is slightly faster.
20
C To solve A*X = B , follow SSPCO by SSPSL.
21
C To compute INVERSE(A)*C , follow SSPCO by SSPSL.
22
C To compute INVERSE(A) , follow SSPCO by SSPDI.
23
C To compute DETERMINANT(A) , follow SSPCO by SSPDI.
24
C To compute INERTIA(A), follow SSPCO by SSPDI.
29
C the packed form of a symmetric matrix A . The
30
C columns of the upper triangle are stored sequentially
31
C in a one-dimensional array of length N*(N+1)/2 .
32
C See comments below for details.
35
C the order of the matrix A .
39
C AP a block diagonal matrix and the multipliers which
40
C were used to obtain it stored in packed form.
41
C The factorization can be written A = U*D*TRANS(U)
42
C where U is a product of permutation and unit
43
C upper triangular matrices , TRANS(U) is the
44
C transpose of U , and D is block diagonal
45
C with 1 by 1 and 2 by 2 blocks.
48
C an integer vector of pivot indices.
51
C an estimate of the reciprocal condition of A .
52
C For the system A*X = B , relative perturbations
53
C in A and B of size EPSILON may cause
54
C relative perturbations in X of size EPSILON/RCOND .
55
C If RCOND is so small that the logical expression
56
C 1.0 + RCOND .EQ. 1.0
57
C is true, then A may be singular to working
58
C precision. In particular, RCOND is zero if
59
C exact singularity is detected or the estimate
63
C a work vector whose contents are usually unimportant.
64
C If A is close to a singular matrix, then Z is
65
C an approximate null vector in the sense that
66
C NORM(A*Z) = RCOND*NORM(A)*NORM(Z) .
70
C The following program segment will pack the upper
71
C triangle of a symmetric matrix.
81
C***REFERENCES J. J. Dongarra, J. R. Bunch, C. B. Moler, and G. W.
82
C Stewart, LINPACK Users' Guide, SIAM, 1979.
83
C***ROUTINES CALLED SASUM, SAXPY, SDOT, SSCAL, SSPFA
84
C***REVISION HISTORY (YYMMDD)
86
C 890531 Changed all specific intrinsics to generic. (WRB)
87
C 890831 Modified array declarations. (WRB)
88
C 891107 Modified routine equivalence list. (WRB)
89
C 891107 REVISION DATE from Version 3.2
90
C 891214 Prologue converted to Version 4.0 format. (BAB)
91
C 900326 Removed duplicate information from DESCRIPTION section.
93
C 920501 Reformatted the REFERENCES section. (WRB)
94
C***END PROLOGUE SSPCO
99
REAL AK,AKM1,BK,BKM1,SDOT,DENOM,EK,T
100
REAL ANORM,S,SASUM,YNORM
101
INTEGER I,IJ,IK,IKM1,IKP1,INFO,J,JM1,J1
102
INTEGER K,KK,KM1K,KM1KM1,KP,KPS,KS
104
C FIND NORM OF A USING ONLY UPPER HALF
106
C***FIRST EXECUTABLE STATEMENT SSPCO
109
Z(J) = SASUM(J,AP(J1),1)
113
IF (JM1 .LT. 1) GO TO 20
115
Z(I) = Z(I) + ABS(AP(IJ))
122
ANORM = MAX(ANORM,Z(J))
127
CALL SSPFA(AP,N,KPVT,INFO)
129
C RCOND = 1/(NORM(A)*(ESTIMATE OF NORM(INVERSE(A)))) .
130
C ESTIMATE = NORM(Z)/NORM(Y) WHERE A*Z = Y AND A*Y = E .
131
C THE COMPONENTS OF E ARE CHOSEN TO CAUSE MAXIMUM LOCAL
132
C GROWTH IN THE ELEMENTS OF W WHERE U*D*W = E .
133
C THE VECTORS ARE FREQUENTLY RESCALED TO AVOID OVERFLOW.
143
60 IF (K .EQ. 0) GO TO 120
147
IF (KPVT(K) .LT. 0) KS = 2
150
IF (KP .EQ. KPS) GO TO 70
155
IF (Z(K) .NE. 0.0E0) EK = SIGN(EK,Z(K))
157
CALL SAXPY(K-KS,Z(K),AP(IK+1),1,Z(1),1)
158
IF (KS .EQ. 1) GO TO 80
159
IF (Z(K-1) .NE. 0.0E0) EK = SIGN(EK,Z(K-1))
161
CALL SAXPY(K-KS,Z(K-1),AP(IKM1+1),1,Z(1),1)
163
IF (KS .EQ. 2) GO TO 100
164
IF (ABS(Z(K)) .LE. ABS(AP(KK))) GO TO 90
165
S = ABS(AP(KK))/ABS(Z(K))
169
IF (AP(KK) .NE. 0.0E0) Z(K) = Z(K)/AP(KK)
170
IF (AP(KK) .EQ. 0.0E0) Z(K) = 1.0E0
174
KM1KM1 = IKM1 + K - 1
176
AKM1 = AP(KM1KM1)/AP(KM1K)
178
BKM1 = Z(K-1)/AP(KM1K)
179
DENOM = AK*AKM1 - 1.0E0
180
Z(K) = (AKM1*BK - BKM1)/DENOM
181
Z(K-1) = (AK*BKM1 - BK)/DENOM
185
IF (KS .EQ. 2) IK = IK - (K + 1)
188
S = 1.0E0/SASUM(N,Z,1)
191
C SOLVE TRANS(U)*Y = W
195
130 IF (K .GT. N) GO TO 160
197
IF (KPVT(K) .LT. 0) KS = 2
198
IF (K .EQ. 1) GO TO 150
199
Z(K) = Z(K) + SDOT(K-1,AP(IK+1),1,Z(1),1)
202
1 Z(K+1) = Z(K+1) + SDOT(K-1,AP(IKP1+1),1,Z(1),1)
204
IF (KP .EQ. K) GO TO 140
211
IF (KS .EQ. 2) IK = IK + (K + 1)
215
S = 1.0E0/SASUM(N,Z,1)
224
170 IF (K .EQ. 0) GO TO 230
228
IF (KPVT(K) .LT. 0) KS = 2
229
IF (K .EQ. KS) GO TO 190
232
IF (KP .EQ. KPS) GO TO 180
237
CALL SAXPY(K-KS,Z(K),AP(IK+1),1,Z(1),1)
238
IF (KS .EQ. 2) CALL SAXPY(K-KS,Z(K-1),AP(IKM1+1),1,Z(1),1)
240
IF (KS .EQ. 2) GO TO 210
241
IF (ABS(Z(K)) .LE. ABS(AP(KK))) GO TO 200
242
S = ABS(AP(KK))/ABS(Z(K))
246
IF (AP(KK) .NE. 0.0E0) Z(K) = Z(K)/AP(KK)
247
IF (AP(KK) .EQ. 0.0E0) Z(K) = 1.0E0
251
KM1KM1 = IKM1 + K - 1
253
AKM1 = AP(KM1KM1)/AP(KM1K)
255
BKM1 = Z(K-1)/AP(KM1K)
256
DENOM = AK*AKM1 - 1.0E0
257
Z(K) = (AKM1*BK - BKM1)/DENOM
258
Z(K-1) = (AK*BKM1 - BK)/DENOM
262
IF (KS .EQ. 2) IK = IK - (K + 1)
265
S = 1.0E0/SASUM(N,Z,1)
269
C SOLVE TRANS(U)*Z = V
273
240 IF (K .GT. N) GO TO 270
275
IF (KPVT(K) .LT. 0) KS = 2
276
IF (K .EQ. 1) GO TO 260
277
Z(K) = Z(K) + SDOT(K-1,AP(IK+1),1,Z(1),1)
280
1 Z(K+1) = Z(K+1) + SDOT(K-1,AP(IKP1+1),1,Z(1),1)
282
IF (KP .EQ. K) GO TO 250
289
IF (KS .EQ. 2) IK = IK + (K + 1)
294
S = 1.0E0/SASUM(N,Z,1)
298
IF (ANORM .NE. 0.0E0) RCOND = YNORM/ANORM
299
IF (ANORM .EQ. 0.0E0) RCOND = 0.0E0