Some function moved to AliZDC
[u/mrichter/AliRoot.git] / GEANT321 / ghutils / minv.F
CommitLineData
fe4da5cc 1*
2* $Id$
3*
4* $Log$
5* Revision 1.1.1.1 1995/10/24 10:21:14 cernlib
6* Geant
7*
8*
9#include "geant321/pilot.h"
10*CMZ : 3.21/02 29/03/94 15.41.40 by S.Giani
11*-- Author :
12 SUBROUTINE MINV(A,N,D,L,M)
13 DIMENSION A(1),L(1),M(1)
14C
15C *** NVE 18-MAR-1988 CERN GENEVA ***
16C
17C ORIGIN : H.FESEFELDT (27-OCT-1983)
18C
19C ...............................................................
20C
21C IF A DOUBLE PRECISION VERSION OF THIS ROUTINE IS DESIRED, THE
22C C IN COLUMN 1 SHOULD BE REMOVED FROM THE DOUBLE PRECISION
23C STATEMENT WHICH FOLLOWS.
24C
25C DOUBLE PRECISION A,D,BIGA,HOLD
26C
27C THE C MUST ALSO BE REMOVED FROM DOUBLE PRECISION STATEMENTS
28C APPEARING IN OTHER ROUTINES USED IN CONJUNCTION WITH THIS
29C ROUTINE.
30C
31C ...............................................................
32C
33C SEARCH FOR LARGEST ELEMENT
34C
35 D=1.0
36 NK=-N
37 DO 80 K=1,N
38 NK=NK+N
39 L(K)=K
40 M(K)=K
41 KK=NK+K
42 BIGA=A(KK)
43 DO 20 J=K,N
44 IZ=N*(J-1)
45 DO 20 I=K,N
46 IJ=IZ+I
47 10 IF( ABS(BIGA)- ABS(A(IJ))) 15,20,20
48 15 BIGA=A(IJ)
49 L(K)=I
50 M(K)=J
51 20 CONTINUE
52C
53C INTERCHANGE ROWS
54C
55 J=L(K)
56 IF(J-K) 35,35,25
57 25 KI=K-N
58 DO 30 I=1,N
59 KI=KI+N
60 HOLD=-A(KI)
61 JI=KI-K+J
62 A(KI)=A(JI)
63 30 A(JI) =HOLD
64C
65C INTERCHANGE COLUMNS
66C
67 35 I=M(K)
68 IF(I-K) 45,45,38
69 38 JP=N*(I-1)
70 DO 40 J=1,N
71 JK=NK+J
72 JI=JP+J
73 HOLD=-A(JK)
74 A(JK)=A(JI)
75 40 A(JI) =HOLD
76C
77C DIVIDE COLUMN BY MINUS PIVOT (VALUE OF PIVOT ELEMENT IS
78C CONTAINED IN BIGA)
79C
80 45 IF(BIGA) 48,46,48
81 46 D=0.0
82 RETURN
83 48 DO 55 I=1,N
84 IF(I-K) 50,55,50
85 50 IK=NK+I
86 A(IK)=A(IK)/(-BIGA)
87 55 CONTINUE
88C
89C REDUCE MATRIX
90C
91 DO 65 I=1,N
92 IK=NK+I
93 HOLD=A(IK)
94 IJ=I-N
95 DO 65 J=1,N
96 IJ=IJ+N
97 IF(I-K) 60,65,60
98 60 IF(J-K) 62,65,62
99 62 KJ=IJ-I+K
100 A(IJ)=HOLD*A(KJ)+A(IJ)
101 65 CONTINUE
102C
103C DIVIDE ROW BY PIVOT
104C
105 KJ=K-N
106 DO 75 J=1,N
107 KJ=KJ+N
108 IF(J-K) 70,75,70
109 70 A(KJ)=A(KJ)/BIGA
110 75 CONTINUE
111C
112C PRODUCT OF PIVOTS
113C
114 D=D*BIGA
115C
116C REPLACE PIVOT BY RECIPROCAL
117C
118 A(KK)=1.0/BIGA
119 80 CONTINUE
120C
121C FINAL ROW AND COLUMN INTERCHANGE
122C
123 K=N
124 100 K=(K-1)
125 IF(K) 150,150,105
126 105 I=L(K)
127 IF(I-K) 120,120,108
128 108 JQ=N*(K-1)
129 JR=N*(I-1)
130 DO 110 J=1,N
131 JK=JQ+J
132 HOLD=A(JK)
133 JI=JR+J
134 A(JK)=-A(JI)
135 110 A(JI) =HOLD
136 120 J=M(K)
137 IF(J-K) 100,100,125
138 125 KI=K-N
139 DO 130 I=1,N
140 KI=KI+N
141 HOLD=A(KI)
142 JI=KI-K+J
143 A(KI)=-A(JI)
144 130 A(JI) =HOLD
145 GO TO 100
146 150 RETURN
147 END