2
SUBROUTINE ORTHOL (A, M, N, NRDA, IFLAG, IRANK, ISCALE, DIAG,
3
+ KPIVOT, SCALES, COLS, CS)
4
C***BEGIN PROLOGUE ORTHOL
6
C***PURPOSE Subsidiary to BVSUP
8
C***TYPE SINGLE PRECISION (ORTHOL-S)
9
C***AUTHOR Watts, H. A., (SNLA)
12
C Reduction of the matrix A to upper triangular form by a sequence of
13
C orthogonal HOUSEHOLDER transformations pre-multiplying A
15
C Modeled after the ALGOL codes in the articles in the REFERENCES
18
C **********************************************************************
20
C **********************************************************************
22
C A -- Contains the matrix to be decomposed, must be dimensioned
24
C M -- Number of rows in the matrix, M greater or equal to N
25
C N -- Number of columns in the matrix, N greater or equal to 1
26
C IFLAG -- Indicates the uncertainty in the matrix data
27
C = 0 when the data is to be treated as exact
28
C =-K when the data is assumed to be accurate to about
30
C ISCALE -- Scaling indicator
31
C =-1 if the matrix A is to be pre-scaled by
32
C columns when appropriate.
33
C Otherwise no scaling will be attempted
34
C NRDA -- Row dimension of A, NRDA greater or equal to M
35
C DIAG,KPIVOT,COLS -- Arrays of length at least n used internally
38
C **********************************************************************
40
C **********************************************************************
42
C IFLAG - Status indicator
43
C =1 for successful decomposition
44
C =2 if improper input is detected
45
C =3 if rank of the matrix is less than N
46
C A -- Contains the reduced matrix in the strictly upper triangular
47
C part and transformation information in the lower part
48
C IRANK -- Contains the numerically determined matrix rank
49
C DIAG -- Contains the diagonal elements of the reduced
51
C KPIVOT -- Contains the pivotal information, the column
52
C interchanges performed on the original matrix are
54
C SCALES -- Contains the column scaling parameters
56
C **********************************************************************
59
C***REFERENCES G. Golub, Numerical methods for solving linear least
60
C squares problems, Numerische Mathematik 7, (1965),
62
C P. Businger and G. Golub, Linear least squares
63
C solutions by Householder transformations, Numerische
64
C Mathematik 7, (1965), pp. 269-276.
65
C***ROUTINES CALLED CSCALE, R1MACH, SDOT, XERMSG
66
C***REVISION HISTORY (YYMMDD)
68
C 890531 Changed all specific intrinsics to generic. (WRB)
69
C 890831 Modified array declarations. (WRB)
70
C 891214 Prologue converted to Version 4.0 format. (BAB)
71
C 900315 CALLs to XERROR changed to CALLs to XERMSG. (THJ)
72
C 900402 Added TYPE section. (WRB)
73
C 910408 Updated the AUTHOR and REFERENCES sections. (WRB)
74
C 920501 Reformatted the REFERENCES section. (WRB)
75
C***END PROLOGUE ORTHOL
76
DIMENSION A(NRDA,*),DIAG(*),KPIVOT(*),COLS(*),CS(*),SCALES(*)
78
C **********************************************************************
80
C MACHINE PRECISION (COMPUTER UNIT ROUNDOFF VALUE) IS DEFINED
81
C BY THE FUNCTION R1MACH.
83
C***FIRST EXECUTABLE STATEMENT ORTHOL
86
C **********************************************************************
88
IF (M .GE. N .AND. N .GE. 1 .AND. NRDA .GE. M) GO TO 1
90
CALL XERMSG ('SLATEC', 'ORTHOL', 'INVALID INPUT PARAMETERS.', 2,
95
IF (IFLAG .LT. 0) ACC=MAX(ACC,10.**IFLAG)
100
C COMPUTE NORM**2 OF JTH COLUMN AND A MATRIX NORM
105
COLS(J)=SDOT(M,A(1,J),1,A(1,J),1)
110
C PERFORM COLUMN SCALING ON A WHEN SPECIFIED
112
CALL CSCALE(A,NRDA,M,N,COLS,CS,DUM,DUM,ANORM,SCALES,ISCALE,0)
117
C CONSTRUCTION OF UPPER TRIANGULAR MATRIX AND RECORDING OF
118
C ORTHOGONAL TRANSFORMATIONS
123
IF (K .EQ. N) GO TO 25
126
C SEARCHING FOR PIVOTAL COLUMN
129
IF (COLS(J) .GE. SRURO*CS(J)) GO TO 5
130
COLS(J)=SDOT(MK,A(K,J),1,A(K,J),1)
132
5 IF (J .EQ. K) GO TO 7
133
IF (SIGMA .GE. 0.99*COLS(J)) GO TO 10
137
IF (JCOL .EQ. K) GO TO 25
139
C PERFORM COLUMN INTERCHANGE
142
KPIVOT(K)=KPIVOT(JCOL)
150
SCALES(K)=SCALES(JCOL)
157
C CHECK RANK OF THE MATRIX
159
25 SIG=SDOT(MK,A(K,K),1,A(K,K),1)
161
IF (DIAGK .GT. ACC*ANORM) GO TO 30
163
C RANK DEFICIENT PROBLEM
166
CALL XERMSG ('SLATEC', 'ORTHOL',
167
+ 'RANK OF MATRIX IS LESS THAN THE NUMBER OF COLUMNS.', 1, 1)
170
C CONSTRUCT AND APPLY TRANSFORMATION TO MATRIX A
173
IF (AKK .GT. 0.) DIAGK=-DIAGK
176
IF (K .EQ. N) GO TO 50
179
AS=SDOT(MK,A(K,K),1,A(K,J),1)/SAD
181
35 A(L,J)=A(L,J)+AS*A(L,K)
182
40 COLS(J)=COLS(J)-A(K,J)**2