1
C @(#)invert.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 INVERT version 1.0 830818
32
C A. Kruszewski ESO Garching
34
C inverts a symmetrical positively defined array SMTR
35
C and keeps the result in the same array SMTR
36
C it was written and tested in the case when array SMTR represents
37
C a covariance matrix of a multimensional random variable
38
C it may fail in other applications
41
C SMTR real*4 array symmetrical array
42
C N integer*4 dimension of array SMTR
44
C SMTR real*4 array inverted input array
45
C-----------------------------------------------------------------------
46
SUBROUTINE INVERT(SMTR,N)
58
C calculates triangular square root of the input array
60
SMTR(1,1) = SQRT(SMTR(1,1))
67
TEMP = TEMP - SMTR(I,K)*SMTR(J,K)
69
SMTR(I,J) = TEMP/SMTR(J,J)
73
TEMP = TEMP - SMTR(I,K)*SMTR(I,K)
75
SMTR(I,I) = SQRT(TEMP)
78
C inverts the triangular square root matrix
81
SMTR(I,I) = 1.0/SMTR(I,I)
90
TEMP = TEMP + SMTR(I,K)*SMTR(J,K)
92
SMTR(I,J) = -TEMP*SMTR(J,J)
96
C squares inverted triangular matrix
102
TEMP = TEMP + SMTR(I,K)*SMTR(J,K)