BOSS 7.0.3
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/MdcxReco/MdcxReco/Mdcxmatinv.h File Reference

Go to the source code of this file.

Functions

int Mdcxmatinv (double *array, int *norder, double *det)
 

Function Documentation

◆ Mdcxmatinv()

int Mdcxmatinv ( double *  array,
int *  norder,
double *  det 
)

Definition at line 7 of file Mdcxmatinv.cxx.

7 {
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 cout << "In Mdcxmatinv, norder ( = " << *norder << " ) > nmax ( = "
17 << nmax << " ); error" << endl; return 1000;
18 }
19 static double amax, save;
20 static int i, j, k, l, ik[nmax], jk[nmax];
21
22 /* Parameter adjustments */
23 array -= (nmax+1);
24
25 /* Function Body */
26 *det = (double)1.;
27 for (k = 1; k <= *norder; ++k) {
28
29/* FIND LARGEST ELEMENT ARRAY(I, J) IN REST OF MATRIX */
30
31 amax = (double)0.;
32L21:
33 for (i = k; i <= *norder; ++i) {
34 for (j = k; j <= *norder; ++j) {
35 d__1 = array[i + j * nmax];
36 if ((fabs(amax)-fabs(d__1)) <= 0.) {
37 amax = array[i + j * nmax];
38 ik[k - 1] = i;
39 jk[k - 1] = j;
40 }
41 }
42 }
43
44/* INTERCHANGE ROWS AND COLUMNS TO PUT AMAX IN ARRAY(K, K) */
45
46 if (amax == 0.) {*det = (double)0.; return 1001;}
47
48 i = ik[k - 1];
49 if ((i__3 = i - k) < 0) {
50 goto L21;
51 } else if (i__3 == 0) {
52 goto L51;
53 } else {
54 goto L43;
55 }
56L43:
57 for (j = 1; j <= *norder; ++j) {
58 save = array[k + j * nmax];
59 array[k + j * nmax] = array[i + j * nmax];
60 array[i + j * nmax] = -save;
61 }
62L51:
63 j = jk[k - 1];
64 if ((i__3 = j - k) < 0) {
65 goto L21;
66 } else if (i__3 == 0) {
67 goto L61;
68 } else {
69 goto L53;
70 }
71L53:
72 for (i = 1; i <= *norder; ++i) {
73 save = array[i + k * nmax];
74 array[i + k * nmax] = array[i + j * nmax];
75 array[i + j * nmax] = -save;
76 }
77
78/* ACCUMULATE ELEMENTS OF INVERSE MATRIX */
79
80L61:
81 for (i = 1; i <= *norder; ++i) {
82 if (i - k != 0) {
83 array[i + k * nmax] = -array[i + k * nmax] / amax;
84 }
85 }
86 for (i = 1; i <= *norder; ++i) {
87 for (j = 1; j <= *norder; ++j) {
88 if (i - k != 0) {
89 goto L74;
90 } else {
91 goto L80;
92 }
93L74:
94 if (j - k != 0) {
95 goto L75;
96 } else {
97 goto L80;
98 }
99L75:
100 array[i+j*nmax] += array[i+k*nmax] * array[k+j*nmax];
101L80:
102 ;
103 }
104 }
105 for (j = 1; j <= *norder; ++j) {
106 if (j - k != 0) {
107 array[k + j * nmax] /= amax;
108 }
109 }
110 array[k + k * nmax] = (double)1. / amax;
111 *det *= amax;
112 }
113
114/* RESTORE ORDERING OF MATRIX */
115
116 for (l = 1; l <= *norder; ++l) {
117 k = *norder - l + 1;
118 j = ik[k - 1];
119 if (j - k <= 0) {
120 goto L111;
121 } else {
122 goto L105;
123 }
124L105:
125 for (i = 1; i <= *norder; ++i) {
126 save = array[i + k * nmax];
127 array[i + k * nmax] = -array[i + j * nmax];
128 array[i + j * nmax] = save;
129 }
130L111:
131 i = jk[k - 1];
132 if (i - k <= 0) {
133 goto L130;
134 } else {
135 goto L113;
136 }
137L113:
138 for (j = 1; j <= *norder; ++j) {
139 save = array[k + j * nmax];
140 array[k + j * nmax] = -array[i + j * nmax];
141 array[i + j * nmax] = save;
142 }
143L130:
144 ;
145 }
146 return 0;
147} /* Mdcxmatinv */

Referenced by MdcxFittedHel::DoFit().