1
C @(#)lsqsol.for 19.1 (ES0-DMD) 02/25/03 13:25:35
2
C===========================================================================
3
C Copyright (C) 1995 European Southern Observatory (ESO)
5
C This program is free software; you can redistribute it and/or
6
C modify it under the terms of the GNU General Public License as
7
C published by the Free Software Foundation; either version 2 of
8
C the License, or (at your option) any later version.
10
C This program is distributed in the hope that it will be useful,
11
C but WITHOUT ANY WARRANTY; without even the implied warranty of
12
C MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
C GNU General Public License for more details.
15
C You should have received a copy of the GNU General Public
16
C License along with this program; if not, write to the Free
17
C Software Foundation, Inc., 675 Massachusetss Ave, Cambridge,
20
C Corresponding concerning ESO-MIDAS should be addressed as follows:
21
C Internet e-mail: midas@eso.org
22
C Postal address: European Southern Observatory
23
C Data Management Division
24
C Karl-Schwarzschild-Strasse 2
25
C D 85748 Garching bei Muenchen
27
C===========================================================================
29
C+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
31
C subroutine LSQSOL version 1.0 870130
32
C A. Kruszewski Obs. de Geneve
34
C Solves a set of normal equations given by array A.
35
C Results are stored in array X. The last element of array X
36
C contains a sum of squared deviations. Mean errors are stored in
37
C array S. The last element of array S contains the mean error
38
C of an observation of unit weight. The dimension N1 is equal to
39
C number of unknowns plus one.
42
C A real*8 array symmetrical array
43
C N1 integer*4 dimension of array
44
C M integer*4 number of conditional equations
46
C X real*8 array unknowns + vv
47
C S real*8 array mean errors + sigma0
48
C-----------------------------------------------------------------------
49
SUBROUTINE LSQSOL ( N1 , A , M , X , S )
53
DOUBLE PRECISION A(N1,N1)
55
DOUBLE PRECISION X(N1)
56
DOUBLE PRECISION S(N1)
64
C *** N - number of unknowns.
68
C *** Calculate triangular square root of the input array.
70
IF ( A(1,1) .LE. 0.0 ) THEN
74
A(1,1) = SQRT( A(1,1) )
78
IF ( A(J,J) .LE. 0.0 ) THEN
85
TEMP = TEMP - A(I,K) * A(J,K)
87
A(I,J) = TEMP / A(J,J)
91
TEMP = TEMP - A(I,K) * A(I,K)
93
IF ( TEMP .LE. 0.0 ) THEN
100
C *** Invert the triangular square root matrix of size N.
103
A(I,I) = 1.0 / A(I,I)
112
TEMP = TEMP + A(I,K) * A(J,K)
114
A(I,J) = -TEMP * A(J,J)
118
C *** Calculate unknowns.
123
TEMP=TEMP + A(I,J) * A(N1,J)
128
C *** Calculate vv and sigma0.
131
X(N1) = SNGL( TEMP * TEMP )
132
S(N1) = SNGL( TEMP / SQRT( DBLE( M-N ) ) )
134
C *** Calculate mean errors of unknowns.
139
TEMP = TEMP + A(I,J) * A(I,J)
141
S(I) = SNGL( SQRT(TEMP) * S(N1) )