BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Mdcxmatinv.cxx
Go to the documentation of this file.
1#include "MdcxReco/Mdcxmatinv.h"
2#include <iostream>
3#include <math.h>
4using std::cout;
5using std::endl;
6
7extern int Mdcxmatinv( double* array, int* norder, double* det ) {
8 /* System generated locals */
9 int i__3;
10 double d__1;
11
12 /* Local variables */
13 const int nmax = 10;
14 // cout << "norder in Mdcxmatinv = " << *norder << endl;
15 if ( *norder > nmax )
16 {
17 cout << "In Mdcxmatinv, norder ( = " << *norder << " ) > nmax ( = " << nmax << " ); error"
18 << endl;
19 return 1000;
20 }
21 static double amax, save;
22 static int i, j, k, l, ik[nmax], jk[nmax];
23
24 /* Parameter adjustments */
25 array -= ( nmax + 1 );
26
27 /* Function Body */
28 *det = (double)1.;
29 for ( k = 1; k <= *norder; ++k )
30 {
31
32 /* FIND LARGEST ELEMENT ARRAY(I, J) IN REST OF MATRIX */
33
34 amax = (double)0.;
35 L21:
36 for ( i = k; i <= *norder; ++i )
37 {
38 for ( j = k; j <= *norder; ++j )
39 {
40 d__1 = array[i + j * nmax];
41 if ( ( fabs( amax ) - fabs( d__1 ) ) <= 0. )
42 {
43 amax = array[i + j * nmax];
44 ik[k - 1] = i;
45 jk[k - 1] = j;
46 }
47 }
48 }
49
50 /* INTERCHANGE ROWS AND COLUMNS TO PUT AMAX IN ARRAY(K, K) */
51
52 if ( amax == 0. )
53 {
54 *det = (double)0.;
55 return 1001;
56 }
57
58 i = ik[k - 1];
59 if ( ( i__3 = i - k ) < 0 ) { goto L21; }
60 else if ( i__3 == 0 ) { goto L51; }
61 else { goto L43; }
62 L43:
63 for ( j = 1; j <= *norder; ++j )
64 {
65 save = array[k + j * nmax];
66 array[k + j * nmax] = array[i + j * nmax];
67 array[i + j * nmax] = -save;
68 }
69 L51:
70 j = jk[k - 1];
71 if ( ( i__3 = j - k ) < 0 ) { goto L21; }
72 else if ( i__3 == 0 ) { goto L61; }
73 else { goto L53; }
74 L53:
75 for ( i = 1; i <= *norder; ++i )
76 {
77 save = array[i + k * nmax];
78 array[i + k * nmax] = array[i + j * nmax];
79 array[i + j * nmax] = -save;
80 }
81
82 /* ACCUMULATE ELEMENTS OF INVERSE MATRIX */
83
84 L61:
85 for ( i = 1; i <= *norder; ++i )
86 {
87 if ( i - k != 0 ) { array[i + k * nmax] = -array[i + k * nmax] / amax; }
88 }
89 for ( i = 1; i <= *norder; ++i )
90 {
91 for ( j = 1; j <= *norder; ++j )
92 {
93 if ( i - k != 0 ) { goto L74; }
94 else { goto L80; }
95 L74:
96 if ( j - k != 0 ) { goto L75; }
97 else { goto L80; }
98 L75:
99 array[i + j * nmax] += array[i + k * nmax] * array[k + j * nmax];
100 L80:;
101 }
102 }
103 for ( j = 1; j <= *norder; ++j )
104 {
105 if ( j - k != 0 ) { array[k + j * nmax] /= amax; }
106 }
107 array[k + k * nmax] = (double)1. / amax;
108 *det *= amax;
109 }
110
111 /* RESTORE ORDERING OF MATRIX */
112
113 for ( l = 1; l <= *norder; ++l )
114 {
115 k = *norder - l + 1;
116 j = ik[k - 1];
117 if ( j - k <= 0 ) { goto L111; }
118 else { goto L105; }
119 L105:
120 for ( i = 1; i <= *norder; ++i )
121 {
122 save = array[i + k * nmax];
123 array[i + k * nmax] = -array[i + j * nmax];
124 array[i + j * nmax] = save;
125 }
126 L111:
127 i = jk[k - 1];
128 if ( i - k <= 0 ) { goto L130; }
129 else { goto L113; }
130 L113:
131 for ( j = 1; j <= *norder; ++j )
132 {
133 save = array[k + j * nmax];
134 array[k + j * nmax] = -array[i + j * nmax];
135 array[i + j * nmax] = save;
136 }
137 L130:;
138 }
139 return 0;
140} /* Mdcxmatinv */
int Mdcxmatinv(double *array, int *norder, double *det)
Definition Mdcxmatinv.cxx:7