Dfact. Function to compute the determinant from a square matrix ($\det(A)$) of dimension $idim$ and order $n$.
35 {
36
37#ifdef XXX
38 if (idim < n || n <= 0) {
39 return false;
40 }
41#endif
42
43
44
45
46 typename Matrix::value_type*
a = rhs.Array();
47
48
49 static unsigned int nxch, i, j, k, l;
50 static typename Matrix::value_type
p,
q, tf;
51
52
54
55
56
57
58
59 nxch = 0;
60 det = 1.;
61 for (j = 1; j <= n; ++j) {
62 const unsigned int ji = j * idim;
63 const unsigned int jj = j + ji;
64
65 k = j;
67
68 if (j != n) {
69 for (i = j + 1; i <= n; ++i) {
72 k = i;
74 }
75 }
76 if (k != j) {
77 for (l = 1; l <= n; ++l) {
78 const unsigned int li = l*idim;
79 const unsigned int jli = j + li;
80 const unsigned int kli = k + li;
84 }
85 ++nxch;
86 }
87 }
88
90 det = 0;
91 return false;
92 }
93
95#ifdef XXX
97 if (t < 1e-19 || t > 1e19) {
98 det = 0;
99 return false;
100 }
101#endif
102
104 if (j == n) {
105 continue;
106 }
107
108 const unsigned int jm1 = j - 1;
109 const unsigned int jpi = (j + 1) * idim;
110 const unsigned int jjpi = j + jpi;
111
112 for (k = j + 1; k <= n; ++k) {
113 const unsigned int ki = k * idim;
114 const unsigned int jki = j + ki;
115 const unsigned int kji = k + jpi;
116 if (j != 1) {
117 for (i = 1; i <= jm1; ++i) {
118 const unsigned int ii = i * idim;
119 a[jki] -=
a[i + ki] *
a[j + ii];
120 a[kji] -=
a[i + jpi] *
a[k + ii];
121 }
122 }
124 a[kji] -=
a[jjpi] *
a[k + ji];
125 }
126 }
127
128 if (nxch % 2 != 0) {
129 det = -(det);
130 }
131 return true;
132}
Expr< UnaryOp< Fabs< T >, Expr< A, T, D >, T >, T, D > fabs(const Expr< A, T, D > &rhs)
Definition: UnaryOperators.hh:96
void a()
Definition: check_aligned.C:59
TTree * t
Definition: check_shower.C:4
q
Definition: testBGReduction_AllMethods.C:55
p
Definition: testBGReduction_AllMethods.C:8