1
C @(#)simul.for 19.1 (ES0-DMD) 02/25/03 13:30:48
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
SUBROUTINE SIMUL(N,A,X)
31
C THE GAUSS-JORDAN COMPLETE ELIMINATION METHOD IS EMPLOYED
32
C WITH THE MAXIMUM PIVOT STRATEGY.
36
DOUBLE PRECISION A(4,4)
41
INTEGER I, ISCAN, IROWI, IROWK
42
INTEGER J, JSCAN, JCOLI, JCOLK
46
DOUBLE PRECISION AIJCK, PIVOT
48
PARAMETER (EPS=1.D-15)
51
C BEGIN ELIMINATION PROCEDURE
54
C SEARCH FOR THE PIVOT ELEMENT
58
C SEARCH IROW AND JCOL ARRAYS FOR INVALID PIVOT SUBSCRIPTS
62
IF(I.EQ.IROW(ISCAN))GOTO 11
63
IF(J.EQ.JCOL(JSCAN))GOTO 11
67
IF(DABS(A(I,J)).LE.DABS(PIVOT))GOTO 11
73
C INSURE THAT SELECTED PIVOT IS LARGER THAN EPS
74
IF(DABS(PIVOT).GT.EPS)GOTO 13
75
CALL STTPUT(' WARNING! SINGULAR MATRIX',' ',' ',ISTAT)
79
C NORMALIZE PIVOT ROW ELEMENTS
81
14 A(IROWK,J)=A(IROWK,J)/PIVOT
82
C CARRY OUT ELIMINATION
83
A(IROWK,JCOLK)=1.D0/PIVOT
87
A(I,JCOLK)=-AIJCK/PIVOT
89
IF(J.NE.JCOLK) A(I,J)=A(I,J)-AIJCK*A(IROWK,J)
93
C ORDER SOLUTION VALUES
97
X(JCOLI)= A(IROWI,MAX)